From 2c78402837c501a131a9cc61000127e8255cc996 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 5 Mar 2020 14:13:56 +0100 Subject: [PATCH] fix: handle certificate challenges separately --- .../translation-parser/translation-parser.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/challenge-md-parser/translation-parser/translation-parser.js b/tools/challenge-md-parser/translation-parser/translation-parser.js index 44049dbae5..ecc675d06e 100644 --- a/tools/challenge-md-parser/translation-parser/translation-parser.js +++ b/tools/challenge-md-parser/translation-parser/translation-parser.js @@ -37,11 +37,18 @@ exports.mergeChallenges = (engChal, transChal) => { title: ${engChal.title} localeTitle: ${transChal.localeTitle}` ); - const translatedTests = transChal.tests.map(({ text }, id) => ({ - text, - testString: engChal.tests[id].testString - })); - return { + + const translatedTests = + engChal.challengeType === 7 + ? transChal.tests.map(({ title }, i) => ({ + title, + id: engChal.tests[i].id + })) + : transChal.tests.map(({ text }, i) => ({ + text, + testString: engChal.tests[i].testString + })); + const challenge = { ...engChal, description: transChal.description, instructions: transChal.instructions, @@ -49,6 +56,9 @@ exports.mergeChallenges = (engChal, transChal) => { forumTopicId: transChal.forumTopicId, tests: translatedTests }; + // certificates do not have forumTopicIds + if (challenge.challengeType === 7) delete challenge.forumTopicId; + return challenge; }; // bare urls could be interpreted as comments, so we have to lookbehind for