Hello!
I am trying to create a multiple choice quiz using the radiobuttons feature. The issue I am encountering is that when I complete the quiz, it should go to either a "re-do" page if all questions are not answered correctly, or move on to another page if all questions are answered correctly (5/5). Instead of going to either of those options, the quiz displays your score as 1/5 no matter what you answer, and I can't seem to change the calculation settings to make it add to the legitimate score.
Our code is based off this original post, with a few modifications:
https://forums.millisecond.com/Topic12915.aspxPlease note, some things are commented out because we were trying to discover where exactly the error is. We suspect it is the /surveypage with /ontrialend.
This is the code we have so far:
<block quizcheck>
/trials = [1 = surveypage.quiz]
</block>
<radiobuttons quiz1>
/ caption = "What is the main goal of this task?"
/ options = ("Click the button as fast as possible", "Stop the circle before it is maximum size so you get the most points", "Make the circle as small as possible so you get the most points")
/ optionvalues = ("0", "1", "0")
// correctResponse = ("1")
</radiobuttons>
<radiobuttons quiz2>
/ caption = "True or False: A yellow background means you are SAFE and a blue background means you are UNSAFE"
/ options = ("True", "False")
/ optionvalues = ("0", "1")
// correctResponse = ("1")
</radiobuttons>
<radiobuttons quiz3>
/ caption = "What happens if the circle reaches maximum size?"
/ options = ("You lose points", "The game will end", "It depends if you are SAFE or UNSAFE, safe means nothing, but UNSAFE means you'll hear a noise")
/ optionvalues = ("0", "0", "1")
// correctResponse = ("1")
</radiobuttons>
<radiobuttons quiz4>
/ caption = "True or False: You may hear an unpleasant sound if the circle reaches maximum size on a yellow screen"
/ options = ("True", "False")
/ optionvalues = ("1", "0")
// correctResponse = ("1")
</radiobuttons>
<radiobuttons quiz5>
/ caption = "How do you stop the circle?"
/ options = ("By doing nothing, you cannot stop the circle", "By pressing the space bar", "By pressing the #1 key")
/ optionvalues = ("0", "1", "0")
// correctResponse = ("1")
</radiobuttons>
<values>
/totalQuizCorrect = 0
/ total = 0
</values>
<text quizFeedback>
/ items = ("You got <%values.total%> out of 5 correct on the comprehension quiz. Below is how you did on each question.\nIf you answered any incorrectly, you will have to re-do the quiz until you answer all questions correctly.")
/ position = (50%, 10%)
/ size = (90%, 15%)
/ txcolor = black
/ hjustify = left
/ vjustify = top
</text>
<text redoQuizPrompt>
/ items = ("Press the space bar to re-take the comprehension quiz.")
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
/ position = (50%, 80%)
/ size = (90%, 10%)
</text>
<text goToTask>
/ items = ("Congrats! Now that you understand the instructions, let's go through some practice trials.")
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
/ position = (50%, 80%)
/ size = (90%, 10%)
</text>
<text quiz1corr>
/ items = ("Correct! Your goal is to stop the circle before it is maximum size to get the most points possible.")
/ position = (50%, 25%)
/ size = (90%, 10%)
/ txcolor = black
</text>
<text quiz1wrong>
/ items = ("Incorrect: Make the circle as small as possible.")
/ position = (50%, 25%)
/ size = (90%, 10%)
/ txcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>
<text quiz2corr>
/ items = ("True! Yellow means UNSAFE and blue means SAFE.")
/ position = (50%, 35%)
/ size = (90%, 10%)
/ txcolor = black
</text>
<text quiz2wrong>
/ items = ("False: Yellow means SAFE and blue means UNSAFE.")
/ position = (50%, 35%)
/ size = (90%, 10%)
/ txcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>
<text quiz3corr>
/ items = ("Correct! It depends if you are SAFE or UNSAFE")
/ position = (50%, 45%)
/ size = (90%, 10%)
/ txcolor = black
</text>
<text quiz3wrong>
/ items = ("Incorrect! If the circle reaches maximum size, the game will not end.")
/ position = (50%, 45%)
/ size = (90%, 10%)
/ txcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>
<text quiz4corr>
/ items = ("True! You will hear an unpleasant noise if the circle grows to maximum size on a yellow screen")
/ position = (50%, 55%)
/ size = (90%, 10%)
/ txcolor = black
</text>
<text quiz4wrong>
/ items = ("Incorrect: A blue background indicates a threat trial.")
/ position = (50%, 55%)
/ size = (90%, 10%)
/ txcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>
<text quiz5corr>
/ items = ("Correct! You stop the circle by pressing the space bar.")
/ position = (50%, 65%)
/ size = (90%, 10%)
/ txcolor = black
</text>
<text quiz5wrong>
/ items = ("Incorrect: You stop the circle by pressing the number #1 key.")
/ position = (50%, 65%)
/ size = (90%, 10%)
/ txcolor = black
/ fontstyle = ("Arial", 3%, true, false, false, false, 5, 1)
</text>
<surveypage quiz>
/ caption = "Please answer the following questions. Before you can continue to the game, you'll need to answer all 5 correctly. If you are viewing this on a smaller screen, you may need to scroll down to answer all the questions."
/ fontstyle = ("Arial", 2%, false, false, false, false, 5, 1)
/ questions = [ 1=quiz1; 2=quiz2; 3=quiz3; 4=quiz4; 5=quiz5 ]
/ onTrialEnd = {
//if (radioButtons.quiz1.response == "1") {values.total += 1;}
//if (radioButtons.quiz2.response == "1") {values.total += 1;}
//if (radioButtons.quiz3.response == "1") {values.total =+1;}
//if (radioButtons.quiz4.response == "1") {values.total =+1;}
//if (radioButtons.quiz5.response == "1") {values.total =+1;}
values.total = radioButtons.quiz1.response + radioButtons.quiz2.response + radioButtons.quiz3.response + radioButtons.quiz4.response+ radioButtons.quiz5.response;
}
//values.totalQuizCorrect =
// radioButtons.quiz1.selectedValue+
// radioButtons.quiz2.selectedValue+
// radioButtons.quiz3.selectedValue+
// radioButtons.quiz4.selectedValue+
// radioButtons.quiz5.selectedValue
/ branch = {
return trial.redoQuiz
}
</surveypage>
<trial redoQuiz>
/ ontrialbegin = {
if (radioButtons.quiz1.selectedValue == 1) { text.quiz1wrong.skip = true; } else { text.quiz1corr.skip = true; }
if (radioButtons.quiz2.selectedValue == 1) { text.quiz2wrong.skip = true; } else { text.quiz2corr.skip = true; }
if (radioButtons.quiz3.selectedValue == 1) { text.quiz3wrong.skip = true; } else { text.quiz3corr.skip = true; }
if (radioButtons.quiz4.selectedValue == 1) { text.quiz4wrong.skip = true; } else { text.quiz4corr.skip = true; }
if (radioButtons.quiz5.selectedValue == 1) { text.quiz5wrong.skip = true; } else { text.quiz5corr.skip = true; }
if (values.totalQuizCorrect > 4) {
text.redoQuizPrompt.skip = true;
} else {
text.goToTask.skip = true;
}
}
/ stimulustimes = [0 =
text.quiz1corr, text.quiz1wrong,
text.quiz2corr, text.quiz2wrong,
text.quiz3corr, text.quiz3wrong,
text.quiz4corr, text.quiz4wrong,
text.quiz5corr, text.quiz5wrong,
text.redoQuizPrompt, text.goToTask,
text.quizFeedback
]
/ validresponse = (" ")
/ ontrialend = {
text.quiz1wrong.skip = false; text.quiz1corr.skip = false;
text.quiz2wrong.skip = false; text.quiz2corr.skip = false;
text.quiz3wrong.skip = false; text.quiz3corr.skip = false;
text.quiz4wrong.skip = false; text.quiz4corr.skip = false;
text.quiz5wrong.skip = false; text.quiz5corr.skip = false;
text.redoQuizPrompt.skip = false; text.goToTask.skip = false;
}
/ branch = {if (values.totalQuizCorrect != 11111) return surveyPage.quiz}
</trial>