Checking user answer in a quiz
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 1
- Joined: Wed Apr 03, 2024 4:05 am
- Contact:
Checking user answer in a quiz
Hi everyone,
I'm working on a quiz application in LiveCode. I can display the questions and allow users to select answers, but I'm having trouble checking if the chosen answer is correct and displaying feedback accordingly.
I've tried using conditional statements (if/else) but I'm not sure how to access the selected answer and compare it to the correct answer.
Can anyone point me in the right direction?
I'm working on a quiz application in LiveCode. I can display the questions and allow users to select answers, but I'm having trouble checking if the chosen answer is correct and displaying feedback accordingly.
I've tried using conditional statements (if/else) but I'm not sure how to access the selected answer and compare it to the correct answer.
Can anyone point me in the right direction?
Re: Checking user answer in a quiz
Hi.
So if you ask a certain question, do I assume that there is an answer already loaded somewhere? In other words, if you have a button with:
That sort of thing?
Craig
So if you ask a certain question, do I assume that there is an answer already loaded somewhere? In other words, if you have a button with:
Code: Select all
on mouseUp
answer "What is 2 + 2?" with "3" or "4" or "5"
if it = "4" then answer "RIGHT!" else answer "Wrong"
end mouseUp
Craig
Last edited by dunbarx on Wed Apr 03, 2024 2:41 pm, edited 2 times in total.
Re: Checking user answer in a quiz
Much depends on how your program interacts with the user. If you pose a question, like "What is 2 + 2", how do you want the user to respond? To enter a value in a field? To click on a line in a list? To click on one button of many?
What went wrong with your own code?
Craig
What went wrong with your own code?
Craig
Re: Checking user answer in a quiz
Rereading, maybe your real issue is:
Craig
Is that so?"How do I store the answer to the current question so I can compare it to whatever and however the user responds"
Craig
Re: Checking user answer in a quiz
I am assuming I am correct. Try out this test stack.
Craig
Craig
Re: Checking user answer in a quiz
The reality is that the OP's question is too vague to answer.
What kind of questions are asked? how is the information structured/stored.
There are a large number of ways to tackle this - but without knowing more people will just be guessing...
Asking the right question in the right way is half the road to enlightenment
What kind of questions are asked? how is the information structured/stored.
There are a large number of ways to tackle this - but without knowing more people will just be guessing...
Asking the right question in the right way is half the road to enlightenment

Re: Checking user answer in a quiz
According to your suggestions I have made some corrections in my codes of Livecode. Now I am having only one problem that the quiz summary is not showing the correct score. It is showing the score equal to total number of questions each time. I am unable to write the code for it.
Re: Checking user answer in a quiz
<html>
< body>
<div class="start">
<h1> Welcome to Livecode </h1>
<a class="btn" href="#"> Get Started </a>
</div>
<div class="quiz">
<input type="text" class="input" />
<input type="text" class="output" />
<a class="sub" href="#" onclick="checkAnswer()"> Submit </a>
</div>
<div class="summary">
<h2> Summary Screen </h2>
<p> Congrats you scored x out of y correct ! </p>
<a class="rst" href="#" onclick="restartQuiz()"> Restart Quiz </a>
</div>
</body>
</html>
Re: Checking user answer in a quiz
Thank you for confirming your humanity!
However you failed the LiveCode aspect of things. This is a forum for LiveCode - a cross platform development platform, and uses LiveCode Script as its language.
The code you posted is HTML - so you're not asking the question in the right place I'm afraid. You'll probably need to search elsewhere for help with that.
However you failed the LiveCode aspect of things. This is a forum for LiveCode - a cross platform development platform, and uses LiveCode Script as its language.
The code you posted is HTML - so you're not asking the question in the right place I'm afraid. You'll probably need to search elsewhere for help with that.
Last edited by stam on Thu Nov 21, 2024 5:23 pm, edited 1 time in total.
Re: Checking user answer in a quiz
Oooopsie!?
This is NO html forum, but a forum for users of the programming language "Livecode" (https://livecode.com)
Or are you using the HTML output of Livecode?
If yes, we need to take a look at the Livecode scripts, not the HTML code of the loading page!

This is NO html forum, but a forum for users of the programming language "Livecode" (https://livecode.com)
Or are you using the HTML output of Livecode?
If yes, we need to take a look at the Livecode scripts, not the HTML code of the loading page!
Re: Checking user answer in a quiz
I don't speak HTML, but reading the last OP's post, it looks like there is not nearly enough "meat" in the HTML code to set up, ask a question somehow, receive an answer somehow, and then validate and report that answer. What I mean is that I think there is a LC script somewhere.
kakocer?
Craig
kakocer?
Craig
Re: Checking user answer in a quiz
SparkOut_paraphrased wrote: ↑Thu Nov 21, 2024 7:17 pmWhat I mean is that I think there is only more generic material in that post, possibly AI generated again.
kakocer?
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: Checking user answer in a quiz
What's the connexion between 'natalie123' and 'kakocer'?
'kakocer' is 'replying' as if they share the same identity as 'natalie123'.
No Artificial Intelligences were harmed in the production of this post.
'kakocer' is 'replying' as if they share the same identity as 'natalie123'.
No Artificial Intelligences were harmed in the production of this post.
