diff --git a/curriculum/getChallenges.js b/curriculum/getChallenges.js index dd29320fe7..eabd1e01e5 100644 --- a/curriculum/getChallenges.js +++ b/curriculum/getChallenges.js @@ -12,6 +12,7 @@ const { const { COMMENT_TRANSLATIONS } = require('./comment-dictionary'); const { dasherize } = require('../utils/slugs'); +const { isAuditedCert } = require('../utils/is-audited'); const challengesDir = path.resolve(__dirname, './challenges'); const metaDir = path.resolve(challengesDir, '_meta'); @@ -121,10 +122,17 @@ async function createChallenge(fullPath, maybeMeta) { meta = require(metaPath); } const { name: superBlock } = superBlockInfoFromFullPath(fullPath); - if (!isAcceptedLanguage(getChallengeLang(fullPath))) - throw Error(`${getChallengeLang(fullPath)} is not a accepted language. + const lang = getChallengeLang(fullPath); + if (!isAcceptedLanguage(lang)) + throw Error(`${lang} is not a accepted language. Trying to parse ${fullPath}`); - const challenge = await (isEnglishChallenge(fullPath) + // assumes superblock names are unique + // while the auditing is ongoing, we default to English for un-audited certs + // once that's complete, we can revert to using isEnglishChallenge(fullPath) + const isEnglish = + isEnglishChallenge(fullPath) || !isAuditedCert(lang, superBlock); + if (isEnglish) fullPath = getEnglishPath(fullPath); + const challenge = await (isEnglish ? parseMarkdown(fullPath) : parseTranslation( getEnglishPath(fullPath), diff --git a/utils/is-audited.js b/utils/is-audited.js new file mode 100644 index 0000000000..1648719a97 --- /dev/null +++ b/utils/is-audited.js @@ -0,0 +1,15 @@ +// this can go once all certs have been audited. +function isAuditedCert(lang, cert) { + if (!lang || !cert) + throw Error('Both arguments must be provided for auditing'); + // in order to see the challenges in the client, add the certification that + // contains those challenges to this array: + const auditedCerts = [ + 'responsive-web-design', + 'javascript-algorithms-and-data-structures', + 'certificates' + ]; + return lang === 'english' || auditedCerts.includes(cert); +} + +exports.isAuditedCert = isAuditedCert;