Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix exercise-runner to work with all the secrecy

  • Loading branch information...
commit a4b83a662c7b652ab64549953e7a51d897cb1c26 1 parent 0f95fd2
Ben Alpert spicyj authored
Showing with 10 additions and 6 deletions.
  1. +2 −2 khan-exercise.js
  2. +8 −4 test/exercise-runner.js
4 khan-exercise.js
View
@@ -912,8 +912,8 @@ function makeProblem( id, seed ) {
}
// Hook out for exercise test runner
- if ( parent !== window && typeof parent.jQuery !== "undefined" ) {
- parent.jQuery( parent.document ).trigger( "problemLoaded" );
+ if ( testMode && parent !== window && typeof parent.jQuery !== "undefined" ) {
+ parent.jQuery( parent.document ).trigger( "problemLoaded", [ makeProblem, validator.solution ] );
}
// Save problem info in dump data for testers
12 test/exercise-runner.js
View
@@ -4,6 +4,7 @@ jQuery.extend(Khan, {
testExercise: function( json ) {
var exerciseName = json.exercise;
var iframe;
+ var makeProblem;
var testsRemaining = json.problems.length;
module( exerciseName, {
@@ -13,7 +14,10 @@ jQuery.extend(Khan, {
// Wait for the first problem to be made but throw it out
stop();
- jQuery( document ).one( "problemLoaded", start );
+ jQuery( document ).one( "problemLoaded", function( e, mp ) {
+ makeProblem = mp;
+ start();
+ } );
iframe.attr( "src", "../exercises/" + exerciseName + ".html" );
}
},
@@ -37,7 +41,7 @@ jQuery.extend(Khan, {
expect( varCount + 2 );
- jQuery( document ).one( "problemLoaded", function() {
+ jQuery( document ).one( "problemLoaded", function( e, mp, solution ) {
var VARS = iwindow.jQuery.tmpl.VARS;
for ( var key in problem.VARS ) {
@@ -46,13 +50,13 @@ jQuery.extend(Khan, {
deepEqual( vark, problem.VARS[key], "var " + key );
}
- deepEqual( iKhan.validator.solution, problem.solution, "solution" );
+ deepEqual( solution, problem.solution, "solution" );
strictEqual( problem.pass, true, "pass" );
start();
} );
- iKhan.makeProblem( problem.type, problem.seed );
+ makeProblem( problem.type, problem.seed );
} );
} );
}
Please sign in to comment.
Something went wrong with that request. Please try again.