File tree Expand file tree Collapse file tree 3 files changed +9
-13
lines changed Expand file tree Collapse file tree 3 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -781,12 +781,15 @@ function setupInfo() {
781781 } ;
782782 } ;
783783 if ( info . correct != null ) {
784- if ( correct . length > 0 ) {
784+ if ( correctRe . length > 0 ) {
785785 alert ( "Error: Info defines correct value but it's overridden." ) ;
786786 } else if ( ! ( info . correct instanceof Array ) ) {
787787 alert ( 'Error: Info correct hints must be array.' ) ;
788788 } else {
789- correct = info . correct . map ( ( s ) => trimNewlines ( s ) ) ;
789+ let correct = info . correct . map ( ( s ) => trimNewlines ( s ) ) ;
790+ // Set global variable with compiled correct answer
791+ correctRe = correct . map ( ( s ) =>
792+ processRegex ( s , `correct answer ${ s } ` , true ) ) ;
790793 } ;
791794 } ;
792795}
Original file line number Diff line number Diff line change 1111< link rel ="license " href ="https://creativecommons.org/licenses/by/4.0/ ">
1212
1313<!-- See create_labs.md for how to create your own lab! -->
14-
15- <!-- Sample expected answer -->
16- < script id ="expected0 " type ="plain/text ">
17- console . log ( "Hello, world!" ) ;
18- </ script >
19-
20- <!-- Full pattern of correct answer -->
21- < script id ="correct0 " type ="plain/text ">
22- \s * console \. log \( ( [ "'`])Hello,\x20world!\1 \) ; \s*
23- </ script >
24-
2514</ head >
2615< body >
2716<!-- For GitHub Pages formatting: -->
Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ info =
6565 examples : [ [ " console.log(\"Hello, world!\") " ] ]
6666 }
6767 ] ,
68+ expected : [ 'console.log("Hello, world!");' ] ,
69+ correct :
70+ [ String . raw `\s* console \. log \(
71+ (["'${ BACKQUOTE } ])Hello,\x20world!\1 \) ; \s*` ] ,
6872 successes : [
6973 [ " console . log( \"Hello, world!\" ) ; " ] ,
7074 [ " console . log( 'Hello, world!' ) ; " ] ,
You can’t perform that action at this time.
0 commit comments