Issues with using a score keeper in quiz app

I’ve been using Thunkable for about a week. After following a few different YouTube videos I have created a basic quiz app. I am trying to add a scoring box to keep track of correct answers. For every correct answer it should increase the points by 4. I am having 2 issues with it.

  1. I have got it to keep track of the score and write it to the label, however even on incorrect answers it still increases the score by 4. I have tried different variables and leaving out variables to no avail.

  2. For some reason once you choose an answer it displays NULL for a second or two before switching to the score.

Here’s a link to my project, any help would be greatly appreciated.

https://x.thunkable.com/projectPage/6317bd4dc0fd8702294fd824

Thank you to @tatiang and @manyone for help with this solution. It is now working as intended. I have to work on disabling the buttons after click now so they can’t be clicked more than once and increase the score. If i need help with that step I’ll start a new thread. Now on to the studying for the next step.

1 Like

your AfterClickFunction is comparing CorrectAnswer to “A” or "B or “C” or “D” - when it should be comparing it to the value of the pressed answer.

you can save the pressed answer by doing something like this at every button press (button1 gives A, button2 gives B, etc):
image

THEN you can compare CorrectAnswer to app variable ans_ltr (the actual button presssed)

2 Likes

Thank you for the quick reply. The reason my answers are A B C is I already have an excel with about 500 questions and answers and the correct answer column already has A B C as the correct answer listed. I did not want to have to go through all 500 and copy/paste the correct answer into the last column.

As for your suggestion, I tried that and it did not make any difference. Did I do it correctly or ?? Remember I am only 2 weeks of experience in this so any explanations should be dumbed down for me. :slight_smile:

Can we see the “After Click Answer” function?

Here is the full code. You can also few it from the link in my first post. Thanks.

Those are hard to read… Here it is in 2 parts.

These rest of the entire coding.

Here is the sample database I am using for testing. The questions and answers and the changing of the button colors work as they should. Its just the score that I am having issues with.

One thing is that accessing the rows isnt 1/2/3 it’s a unique id. Check this part out. It shows you how to list the rows

It looks like you’re checking to see if the correct answer matches the string “A” or “B” or “C” or “D”. But you want to see if the correct answer matches the user’s input instead.

You correctly set the variable ans_ltr to one of those values but then you didn’t use it in your After Click Answer function. You just need one if/else block. It should check to see if app variable ans_ltr = get value from sheet. You don’t need to check A and B and C and D. Because the variable will already have one of those values. So just check the variable to see if it matches the correct answer from the spreadsheet.

Sorry… I am new and know very little. I read the entire page you linked and not sure how this effects the score. The score is only calculated on a Click Button Event… where as I have it set to advance by 4 points for each correct button.

My setup as I believe…

After click
“IF” button A is clicked check to see if General Knowledge DB, Sheet 1, Column Correct Answer contains letter A. If so “DO” set BG color GREEN and “SET” score to current score plus 4 and display score in label box.

“ELSE” set BG color RED and SET score to current score plus 0 and display score in label box. This should keep the score the same as it was before the Click Event?

In the way I have it set the words in the questions and answer columns shouldn’t matter as long as the button pressed, either is or is not, the same letter shown in the correct answer column. Am I missing something?

If your above solution is the fix I have no idea how to implement it into my code to make score work as it should.

Sorry I am just learning this and ALL my knowledge so far comes from research and youtube. What blocks would I ad to the After Answer Clicked section? Would they be added to the existing IF / ELSE blocks or do I need a new one for a new event?

when i said, " THEN you can compare CorrectAnswer to app variable ans_ltr (the actual button presssed)", i thought you were going to apply those changes yourself

you were supposed to make these changes also for all buttons

1 Like

Ok making that change did 3 things.

  1. It no longer adds to the score on wrong answers.

  2. Now it adds the score 4x… so instead of increasing it by 4 points per correct answer it now adds 16.

  3. Now it changes the color off ALL buttons to red or green based on the answer you choose and if it is correct or not.

If you re-read my last post, I mentioned that you only need one if/else block in the After Click Answer function. You’re checking to see if the variable equals the spreadsheet value. If it does, then the question was answered correctly. So just check once, not four times.

1 Like

sorry about that - you need to change aftercilickanswer to have 2 parts, first part to turn on the proper colors to reveal the correct answer, second part to check ans_ltr against correctanswer and update the score appropriatley and maybe a third part to indicate whether the asnwer was right or wrong. ill include the sample later. or you can start working on it
here is sampe with 2 buttons filled"

2 Likes

This has the old, incorrect code for checking the answers. @luellencm4dtjv, make sure to still use the variable ans_ltr, not the strings “A” and “B”. And again, only one if/else block.

the way i see it, it looks like he still wants to see the correct colors of the answers whether the entered answer was correct or not. if we go by ans_ltr and suppose its got a value of ‘A’ but correct answers is ‘B’, all buttons will turn to red! he needs to reveal the correct letters aways, then announce ‘right’ or ‘wrong’

2 Likes

Thank you all for the help. The score is working as it should. Appreciate all your suggestions.

1 Like