Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Fix exercise-runner to work with all the secrecy
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebits committed Jul 21, 2011
1 parent 0f95fd2 commit a4b83a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions khan-exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions test/exercise-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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" );
}
},
Expand All @@ -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 ) {
Expand All @@ -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 );
} );
} );
}
Expand Down

0 comments on commit a4b83a6

Please sign in to comment.