Skip to content

Commit

Permalink
Merge branch 'master' into lib
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienTainon committed Apr 24, 2024
2 parents b7fda7a + 80012ba commit aba18a0
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions frontend/stepper/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,14 @@ export const checkBlocklyCode = function (answer: Document, context: QuickAlgoLi
return;
}

const blocks = getBlocksFromXml(blockly);
let blocks;
try {
// This method can fail if Blockly is not loaded in the DOM. In this case it's ok we don't make the check
blocks = getBlocksFromXml(blockly);
} catch (e) {
console.error(e);
return;
}

const maxInstructions = context.infos.maxInstructions ? context.infos.maxInstructions : Infinity;
const totalCount = blocklyCount(blocks, context);
Expand Down Expand Up @@ -276,7 +283,18 @@ export const getBlocklyBlocksUsage = function (answer: Document, context: QuickA

log.getLogger('blockly_runner').debug('blocks usage', answer);

const blocks = getBlocksFromXml(blockly);
let blocks;
try {
// This method can fail if Blockly is not loaded in the DOM. In this case it's ok we don't make the check
blocks = getBlocksFromXml(blockly);
} catch (e) {
console.error(e);
return {
blocksCurrent: 0,
limitations: [],
};
}

const blocksUsed = blocklyCount(blocks, context);
const limitations = (context.infos.limitedUses ? blocklyFindLimited(blocks, context.infos.limitedUses, context) : []) as {type: string, name: string, current: number, limit: number}[];

Expand Down

0 comments on commit aba18a0

Please sign in to comment.