Hey! I'm currently creating a Quiz that needs to check if the answer is correctly or not. It will kind of look like this:The current problem I have is that I do not know how to properly check which Radio option is currently chosen, neither do I know what the most efficient way is to check for the correct answer. I'm currently creating a CorrectAnswer variable that does a database call looking for the Entity with the bool (isCorrect = true).
- How do I check the current selected radio button option
- What is the most efficient way to check if that option is correct.
Thanks in advance! :)
Hi Noah,
as per my understanding u can use on click action to get the answer.
Also could u pls share your OML?
I will be happy to help u.
Thanks
Hey @Asiyah Munawwar . I do not know how to get the value of the current selected radio button, which is my problem.
Like this
and assign that value to a local variable and show that on button click
to know what is chosen by user, absolutely no need for any on click event capturing, the currently selected value is stored in the Variable you bind to the radio group (it's a mandatory property of the radio group)
to verify the chosen value against the correct one, it depends on whether this needs to be secured against cheating. If not, you can retrieve the correct answer up front while retrieving the options. Then you can quickly compare the given answer with the correct one at any time on the client without having to go to server again.
But in most cases you probably want it to be harder to cheat, so in that case you need to postpone reading the correct answer until after the user has given his own answer. So a separate aggregate, that doesn't run at start, but only after user says he's ready with his answer (on button click maybe)
"If not, you can retrieve the correct answer up front while retrieving the options. Then you can quickly compare the given answer with the correct one at any time on the client without having to go to server again. "
Do not do this if you want to make sure people are not cheating. Nothing is more simple then to check the network tab in de browser tools to check the payloads. If the correct option is listed in the output then people can intercept this. Also do not put the correct answer in a JavaScript or variable with an initial value. These can all be read via the browser tools.
Use a service action to validate the answer for the question by inputting the question Id and the Answer Id (use a GUID instead of a record identifier to prevent scanning). The return should only be an "IsCorrect" or something like that. Do not share any details other then that.
Hope this helps,
Vincent
Edit: @Noah Kok: Forgot to tag you so you will get a notification. This should solve that :)
Hi @Noah Kok
please check with the attached OML
Hope it will be help full
regards
Sudarshan
Hey! I do not understand how the RadioGroup1OnChange chanegs the selected value. It is empty for me.
hey In my example when he select first radio button the value assigned to that variable in default value "Modi", second variable default value "Trump" so when radio button on change the value u selected will assign to "radio group" variable automatically
Hi! I don't think I'm able to pre-define all the vars since it's from a UI LIST. How would i do this?
please share Your OML will check
Hi @Noah Kok,First you can create a local variable in your web-block, which data type must be set answer-identifier entity type.Looks like this:-
After that, set the value of RadioButton, Answer entity id.
This is bind now with the list.
I hope this solves your problem.
Regards,
Amar Chand
Hi @Noah Kok ,
You have to use one local variable to access radio button selected option and based on that you can check your selected option.
I hope this attached oml file will help you to resolve the problem.
@Noah Kok ,
i can see in your screenprint that you approach this wrong : the radio group / radio buttons widget doesn't work together with a list (unfortunately).
The intended use is that there is only a single radiogroup widgetn and that there are a fixed number of options, and that for each option, a radiobutton sits inside one single radiogroup widget.
In that case, whatever option gets chosen, makes the variable attached to the group get the right value. So what you are trying, adding a list, with a radio group in it, and then a single radio button in the group, is not going to work. All options should be part of a single radio group.
Dorine
check out this component
Check documentation https://success.outsystems.com/documentation/11/reference/outsystems_language/interfaces/designing_screens/radio_button/