122
Views
15
Comments
Finding the right answer in a Radio Group.

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! :)


2023-10-27 12-06-14
Asiyah Munawwar

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

UserImage.jpg
Noah Kok

Hey @Asiyah Munawwar . I do not know how to get the value of the current selected radio button, which is my problem.

EduForEveryone.oml
2023-10-27 12-06-14
Asiyah Munawwar

Like this

and assign that value to a local variable and show that on button click

2021-09-06 15-09-53
Dorine Boudry
 
MVP

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)


2020-09-21 08-42-47
Vincent Koning

"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 :) 

UserImage.jpg
Sudarshan HD

Hi @Noah Kok 

please check with the attached OML 

Hope it will be help full


regards

Sudarshan

neww.oml
UserImage.jpg
Noah Kok

Hey! I do not understand how the RadioGroup1OnChange chanegs the selected value. It is empty for me.

UserImage.jpg
Sudarshan HD

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 

UserImage.jpg
Noah Kok

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?

UserImage.jpg
Sudarshan HD
2024-07-02 11-22-02
Amar Chand Suthar

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.


For anyway, I have create a demo quiz app for you, where you may choose your answers and see your score. For demonstration purposes, I've attached the OML file and application link(Click here).

I hope this solves your problem.


Regards,

Amar Chand

EduForEveryone.oml
2024-03-11 09-26-19
Rahul Shrivastava

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.

QUIZ.oml
2021-09-06 15-09-53
Dorine Boudry
 
MVP

@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

2021-09-06 15-09-53
Dorine Boudry
 
MVP

check out this component

2024-10-03 23-27-42
Aleff Francisco Correia

Check documentation https://success.outsystems.com/documentation/11/reference/outsystems_language/interfaces/designing_screens/radio_button/

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.