Current project includes a ten page quiz.
Each question has a choice of three answers, each is related to a colour ( red,amber,green)
When a question choice is made a box is populated by a colour fill and goes to the next
question frame. As the questions are answered the boxes progress across the stage until the final box.
I need to find a way to add up which colour has filled the most boxes and the move to the appropriate frame with a statement that relates to total.
###### Who is Participating?

Commented:
The 'box fill' is a visual cue for the user, I'm guessing - telling them how they did for that question. But 'underneath' the visual skin of the program you just need some sort of counter that keeps track of the responses.

So I can think of 2 ways to do this.

1) You initialise a variable to record a score - let's call the variable 'totalScore'. You assign a value to each of the colours - for example, red = 0, amber = 1, green = 2. So when a user answers with a 'green' answer your code would be

totalScore = totalScore + 2;

totalScore = totalScore + 1;

You keep track of the score, and end up with a total score after all the questions have been asked. You can then take a decision on what feedback to give based on what score they got versus the maximum score possible.

You say there are 10 pages, so if we used this marking scheme, the maximum score would be 20 - all green. So you might 'split' the feedback at a score of 5, 10 and 15. You then just need a bunch of 'if' statements something like

if (totalScore <= 5) {
...take some actions here
}

if ((totalScore > 5) && (totalScore < 10)) {
...take some actions here
}

if ((totalScore >= 10) && (totalScore < 15)) {
...take some actions here
}

if (totalScore >= 15) {
...take some actions here
}

or

2) Setup three variables to record the 'colour' of each answer - we'll call them 'redAnswer' 'amberAnswer' and 'greenAnswer'. Before the quiz starts we set them all to 0

Then each time you get a 'red' answer you use the code

and if you get an amber answer you use

and I'm sure you can work out what code you need if you get a green answer.

At the end of the quiz, you just need to compare the three variables to see which is largest. Bear in mind that using this method, it's quite likely that two of the variables will be the same value, so you'll have to think what decision needs to happen in that case. Note that all three variables can never be the same since 10 (the number of questions) cannot be divided equally when using whole numbers only.
0

Author Commented:
Thanks a lot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.