Task 8: Controlling question navigation (2)

1.

Find the Hot Potatoes source folder, and copy the jquiz6.js_ file into your custom source folder.

2.

Open the file in your text editor, and search for the JavaScript ChangeQ function. It's about a quarter of the way through the file, and it starts like this:

function ChangeQ(ChangeBy){

3.

Look at the next three lines. They all start with two slashes (//). This is one way to make a comment in JavaScript; two slashes at the beginning of a line will comment out the whole line. These are the lines:

//The following line prevents moving to another question until the current
//question is answered correctly. Uncomment it to enable this behaviour.
// if (State[CurrQNum][0] == -1){return;}

4.

First, we're going to add our own comment to explain what we're doing. Add it after the first two lines, and before the JavaScript line:

//The following line prevents moving to another question until the current
//question is answered correctly. Uncomment it to enable this behaviour.
//MDH_Custom: Uncommented the next line to enable behaviour described above.
// if (State[CurrQNum][0] == -1){return;}

5.

Finally, we just need to uncomment that line of code to make the page work the way we want it to:

//The following line prevents moving to another question until the current
//question is answered correctly. Uncomment it to enable this behaviour.
//MDH_Custom: Uncommented the next line to enable behaviour described above.
if (State[CurrQNum][0] == -1){return;}

6.

Save the file, then create an exercise in JQuiz and view it in your browser. Remember NOT to set the exercise to "Shuffle questions". If the questions are shuffled, this hack won't work. Here's an example.