Help with Quiz coding

I created this quiz game based on a quiz game that I found here... but when I try to add (or remove) a question it stops working. I added a 5th question and then I edited the "check ansers ()" but then when I click on the 5th "submit" button, I get no reaction. Heres the orignal (CF-teeth-QUIZ) which works properly and my edit (CF-teeth-QUIZ-mod)

CF-teeth-QUIZ.hype.zip (611.7 KB)
CF-teeth-QUIZ-mod.hype.zip (682.7 KB)

You've modified the checkAnswer() function correctly, but the missing part is needing to associate your new scene with the various submitBtn5, a5, b5, and c5 elements IDs it references. To fix this, go to your "5" scene, and on the Rectangle element that has the checkboxes/submit, choose Edit > Edit Element's Inner HTML or click the pencil button. When the code pops up, change the element names or copy/paste this end result:

<br><br><br><br><input type="radio" name="day" value="One" id="a5" style="font-size: 24px;"><span style="font-size: 24px;"> A.&nbsp;Wrong1</span><br>
<input type="radio" name="day" value="Two" id="b5" style="font-size: 24px;"><span style="font-size: 24px;"> B. Wrong2</span><br>
<input type="radio" name="day" value="Three" id="c5" style="font-size: 24px;"><span style="font-size: 24px;"> C. Right</span><br>


<p></p>


<button id="submitBtn5" style="font-size: 24px;">Submit</button>

Then it will work correctly.

1 Like

Thank you Jonathan! That worked. But now for some reason, the polygons (on scenes "5th right" and "5th wrong") won't respond when clicked. Do you know why?
CF-teeth-QUIZ-mod3.hype.zip (692.0 KB)

The issue is in this line:

hypeDocument.showSceneNamed(hypeDocument.page+'', hypeDocument.kSceneTransitionCrossfade, 0.2)

Basically this means transition to the scene that has the name of the value for hypeDocument.page. This is a number, like 1, 2, 3, 4, 5, 6, etc.

There's a variable that keeps track of the hypeDocument.page. This gets incremented by the lines in the checkAnswer() function that look like hypeDocument.page++. (++ means add one to the value).

The issue is that you added a page, page 5. The script goes to that, and you have your additional question. However once you answer it, the page is incremented to 6. But right now there's no scene with the name "6". There's two with the name of "5" which includes the final scene.

So to fix this, you need to rename that final scene from "5" to "6". Then it will work.

Screenshot 2024-12-17 at 10.20.35 AM

1 Like

Thanks agian!

1 Like