Working on a quiz app and need a little help to end the quiz

The quiz works great however when I reach the end it just stays at the last question. It does not return to the home page or loop to the beginning. I have followed several tutorials however many are several years old and the blocks are slightly different so I think I missed something. I am new so please be as detailed as possible on steps needed to fix this, or show a screenshot would be best. Thank you.

Here is my link Thunkable

Here are images to what I have so far.

Have you watched this?

1 Like

Before the if condition in when next question button is pressed, add a change app variable block by 1 and set the variable to index

Is this what you mean? If so it made no change.

Quiz5

1 Like

What you have in theory should work. So What I would do to debug this, is have both the value of index and question list display on the screen, that way you can see if they are updating correctly.

Thank you @shrey for the fix and @zander for pointing me to the final issue…

Yes @zander you was correct that it should be working. It worked flawless… I just had another error and your test idea pointed me to it… I forgot the “Set app variable questionlist to 1 block” at screen start. So it had nothing to compare the index to.

Quiz6

3 Likes

I was making cosmetic changes (button backgrounds and shadows) and tested it again and its no longer going to home screen after end of quiz. I have gone over all the code and I cannot see the issue. Here are current screenshots of the blocks and the link to the project. I am racking my brain trying to figure out why its no longer working. I added a test message to the header to keep track of the Index and QuestionList numbers and they update accordingly.

https://x.thunkable.com/projectPage/631de7de92ae990225274397

1 Like

Try removing the length of block before the app variable QuestionList block

Another thing, remove the change app variable QuestionList by 1 block.

Also, at set the app variable QuestionList block to the number of questions there are (variable block located in the GK T1 opens block)

1 Like

Ok I changed the 1st and 2nd things you said and it now goes to home screen after the 1st question is answered. As for the 3rd thing you mentioned I am not exactly sure what your asking me to do. Please clarify. Thanks.

I meant the variable block named Questionlist, the one that is in the screen opens block.

Set that variable to the number of questions you have in the quiz

OK I changed that and now it only shows the 3rd question, however it shows it 3 times then continues to the home screen as it should.

My other issue will be if I set that to the number of questions then I have to make edits to the blocks any time I want to add or remove questions to the database. This is not ideal. I think that is why the tutorial I followed put the “length of” block in the IF statement.

Ok set that back to 1 and add the the change variable block.

Let me think about the ending part

Instead of the app variable questionlist block in the if condition put this:
image
(instead of table 1 it’s supposed to be GK T1)

Also, delete the unused rows

Ok now it cycles through all 3 questions but it just stays and does not continue to home screen.

I highlighted and deleted all rows from 4-50 in the database.

The project will halt and will not move to next block if you try to force a type casting.

The app variable QuestionList is initialized as an integer (a number) and then within the codes you use Length of block which is used specifically for lists and not numbers.

Replace this block with another more appropriate block. For instance, check if the variable equals to zero or greater than a number but avoid getting the length of that variable.

See the comment just above yours. I think we addressed that issue and have moved on to the issue of staying at the last question. I cannot get it to move on to the home page after last question. I am new so I’m still learning. Im not sure how to check if variable equals zero or greater.

1 Like

Did you press sync with source?

To get to it, go to design, press data, and then click on the google sheet you want to update. Then you will see the button.

1 Like

Yes and just for good measure I did it again just now and it still stops at last question.

can you share the link to the latest version?

Yes of course… I believe this is the link. Thunkable

If you can get it to work let me know thanks