Creating a quiz (How to tally up results and display a final score)


#1

Hi everyone!

I am creating a quiz (5 questions only, 4 possible answers each question).
The idea is that as users click one of the options, the colour of the buttons change to show if they are right/wrong. That has been the easy part.

I want, however, to display the final result after the users click on their answer for the final question.
This sketch may help you understand:

For each possible answer I have set the following interactions:

  • “OnClick”, Set Panel State to “Q1 Answer x” (and that then changes the colour of the button, depending on weather the answer is right or wrong)
  • “OnClick” Set variable Value “Q1 Answer to” 1 (if correct) or “” (if wrong).

Now the logic behind this would be that the results would tally up as the options are clicked once the user answers the last question, the panel with the result would show up.

Does any one know how to do this?
How do I create the logic for this?

Any input is appreciated.
Thanks a lot!
Rita P.


#2

It sounds like you have a variable for each question that is set to “1” if correct, or empty if incorrect. That’s a good start and just what you need. This will work, but you could also have a single variable that tracks the score cumulatively as well, which will be easier to use later. You might have a runningScore variable and just add 1 to it each time they get a question right.

Next you need to determine what specific event will trigger the completion message. One obvious possibility is completing the final question (this is ignoring any logic that makes sure all questions are answered). On your final question you could add an action that shows the completion message and sets its text, like so:

OnSomeEvent
...some final question stuff
Show CompletionMessage
Set text on CompletionMessage to: You've got [[runningScore]]/10 right! Hurray!!!

If you don’t implement something like a runningScore variable, you’ll just have to add all your question-specific variables together instead.

You've got [[QuestionAnswer1 + QuestionAnswer2 + QuestionAnswer3]]/3 right! Hurray!!!

#3

Good work so far. Regarding the calculation, I would run it on clicking a submit button, a) because the user knowa that they have finished the quiz and shouldn’t be changing answers anymore and b) it allows the quiz to check that every question has been answered.

You then have two options. The first is abit long which is to have a case which adds every score and then presents it. The benefit of this this is that you piggy back this case with an “If” cae which checks to see that an option for each question has been selected. The second quicker option is to have a global variable which gets updated whenever an answer is clicked. Some will add 1, others will keep the number the same. Again, you won’t an “If” case that checks that an option for each question has been selected.

Hopefully this help?


#4

Thanks for replying!
I believe there was a missing word in your last sentence…?
Using a submit button sounds reasonable, especially because then the users commit to their answers and don’t try to change the answer in order to alter the result.
In that case, I would need to create a group selection so that the user is allowed to change their mind before submitting (as they are not getting feedback as soon as they click each option), and to avoid them selecting multiple options, is that correct?

I’ll try to make that submit button work, thanks!


#5

Hi Nkrisc,
Thanks for your reply, I made it work by creating a global variable TotalScore and then using the formula to add up [[Q1+Q2+Q3…]] in each button.

Now, you mentioned something very interesting: the logic to make sure all questions are answered. How do you create the logic for that?

Thank you so much for helping this noob here! :slight_smile:


#6

That part is actually not too much more work from what you’re already done. If you think about it, if a question has been answered, it has a score. If it hasn’t been answered, there shouldn’t be any score. So if we just check if every question variable (that you’ve already created) has a score, then you know all questions have been answered (or if not all have a score, you know they haven’t all been answered).

So perhaps on the final submit button you might have a case like this:

IF Q1 does not equal "" AND Q2 does not equal "" and Q3 does not equal "" AND etc...
Do success thing
Else
Do error thing

For the conditions here, you just add multiple conditions, one for each question variable. Then make sure the small dropdown in the top-left of the condition editor is set to “ALL” which requires that all the conditions are satisfied to continue, instead of only at least one.


closed #7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.