Can someone please sense check my logic

Get help using Construct 2

Post » Thu Mar 30, 2017 6:28 pm

Hi,

I am making a simple quiz game for language learners to learn vocab.
It reads a list of English words from one text file, and a list of the corresponding words in another language from another text file. Each set is placed into an array.
The word in the foreign language is displayed
The user is then given a choice of 4 possible answers in English (3 randomly chosen + right answer).
Whenever they click an answer the quiz goes to the next question.

I have it all working, except that when I add in the code to load a new question if the user selected the wrong answer, I seem to get random skipping of my questions, and the score keeping becomes erratic. If I remove that check, then there doesn't seem to be a problem.
It seems to be that my function (DisplayQ) to display the next question seems to run more than once, but not always, and not be the same amount, sometimes it will skip 1 question, other times 2 questions.

But I cant see for the life of me where it is going wrong - any help would be much appreciated

http://www.filedropper.com/quiztry
B
6
S
1
Posts: 32
Reputation: 476

Post » Thu Mar 30, 2017 8:01 pm

https://www.dropbox.com/s/ill28s11g3b1f ... .capx?dl=0

Fixed 4 things for you.

1/ This one is just for the logic. In your case not an important one. But, when using Ajax, you should wait until all Ajax stuff is done before continuing the events. Fixed this with setting group "QUIZ".

2/ Changed starting Qnum to - 1. Now it starts to display Qnum from zero, the array is zero based. That, or you got to rethink the moment that there is 1 added to Qnum.

3/ Now the first question is displayed immediately (no click required) . And all texts stay invisible until Ajax is done loading for BOTH lists. It was not necessary so that first by Ajax loaded list also was the first list to be ready and usable. But loads happened at kinda the same time, and it is not really known which one is ready to use as last, and could call the display function.

4/ The logic flaw you had. Actual your question.
When you clicked the text field. It called the function, that function changed the rAssign value. So the next (supposed to be the opposite checking) condition got a different rAssign feeded (then the first condition).
Solved it with a plain 'else'.

I left the browser object in there. To show you how you can use it so eassssy to debug. You can delete it.

Hope this helps you and learns you something.
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Thu Mar 30, 2017 9:30 pm

1/ This one is just for the logic. In your case not an important one. But, when using Ajax, you should wait until all Ajax stuff is done before continuing the events. Fixed this with setting group "QUIZ".


Thank you, I didn't know you could de-activate groups

4/ The logic flaw you had. Actual your question.
When you clicked the text field. It called the function, that function changed the rAssign value. So the next (supposed to be the opposite checking) condition got a different rAssign feeded (then the first condition).
Solved it with a plain 'else'.


Ah, OK I see, I did originally have an else statement in there but in a slightly different configuration, which explains why it didn't work for me. Thank you so much for this.

Hope this helps you and learns you something.


Yes definitely this has helped me a lot, thank you so much, you really didn't have to go to all that trouble!

Kind Regards
B
6
S
1
Posts: 32
Reputation: 476

Post » Thu Mar 30, 2017 9:43 pm

No trouble, just happy someone shared a .capx.
B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874


Return to How do I....?

Who is online

Users browsing this forum: JaredX and 9 guests