@@ -84,7 +84,6 @@ let init = async () => {
8484 let moduleDefinitions = getDefinitionsForModule ( moduleId ) ;
8585 var modulePath = getModulePath ( moduleId ) ;
8686 for ( let level of moduleDefinitions ) {
87- challengeDefinitions . push ( level ) ;
8887 for ( let challenge of level . challenges ) {
8988 if ( ! util . isNullOrUndefined ( challengeNames [ challenge . id ] ) ) {
9089 throw new Error ( `Duplicate challenge id: '${ challenge . id } '!` ) ;
@@ -206,6 +205,7 @@ let getChallengeDefinitions = async (moduleId) => {
206205
207206 if ( util . isNullOrUndefined ( moduleId ) ) return [ ] ;
208207 if ( util . isNullOrUndefined ( modules [ moduleId ] ) ) return [ ] ;
208+ if ( ! util . isNullOrUndefined ( challengeDefinitions [ moduleId ] ) ) return challengeDefinitions [ moduleId ] ;
209209
210210 var modulePath = getModulePath ( moduleId ) ;
211211 var moduleDefinitions = getDefinitionsForModule ( moduleId ) ;
@@ -224,12 +224,17 @@ let getChallengeDefinitions = async (moduleId) => {
224224 challenge . description = path . join ( modulePath , description ) ;
225225 }
226226 if ( challenge . type === "quiz" ) {
227- challenge . question = qna . getCode ( challenge . id ) ;
227+ if ( util . isNullOrUndefined ( challenge . options ) ) {
228+ challenge . question = qna . getCode ( challenge . id ) ;
229+ }
230+ else if ( ! util . isNullOrUndefined ( challenge . answer ) ) {
231+ challenge . question = { "digest" : qna . getDigest ( challenge . answer ) }
232+ }
228233 }
229234 }
230235 returnChallenges . push ( level ) ;
231236 }
232-
237+ challengeDefinitions [ moduleId ] = returnChallenges ;
233238 return returnChallenges ;
234239}
235240
@@ -452,8 +457,8 @@ let apiChallengeCode = async (req) => {
452457 }
453458
454459 let answer = null ;
455- if ( ! util . isNullOrUndefined ( req . body . answer ) ) {
456- answer = req . body . answer . trim ( ) ;
460+ if ( ! util . isNullOrUndefined ( req . body . answer ) && typeof req . body . answer === "string" ) {
461+ answer = req . body . answer . trim ( ) . toLowerCase ( ) ;
457462 }
458463
459464 if ( util . isNullOrUndefined ( challengeCode ) ||
0 commit comments