17
Views
2
Solved
###### Randomize the order of buttons in a block
Question

I am brand new to outsystems. I am trying to create a quiz the issues that I am having is that I have 4 vertical buttons in a block and I am trying to find a way to randomize the order of the buttons if there is a way to do it please can someone put in a solution for this.

So in the second image shows that in the first block in the image has the answer at the bottom, and below block I would like the answer bottom to be rearranged. So can someone help me out with this issue.

Solution

Hi Jack,

1) make sure it is a list widget of buttons (you are probably already doing that, as you are probably retrieving a list of possible answers from somewhere)

3) give a random sort value to each sort attribute in your list

4) do a listSort on that sort attribute

So for step 3, there are forge components that produce random numbers. If you think this is too much, or you enjoy coming up whith something creative yourself, you could make up your own randomizing logic making use of some random things like date, time, user information, time the user has taken to take the quizz so far, anything that separates one quiz taker from the next.

Dorine

Edit : I´ m not sure, but I think SQL Server might offer a function to generate random numbers, maybe you´ d need a sql widget to make use of it, maybe someone else knows this ???

Hi, jack

I believe these options are coming from the table so in the same table you can have one more attribute named order(integer Datatype) and based on this order attribute you can sort the data and display the expressions in the list.

Solution

Hi Jack,

1) make sure it is a list widget of buttons (you are probably already doing that, as you are probably retrieving a list of possible answers from somewhere)

3) give a random sort value to each sort attribute in your list

4) do a listSort on that sort attribute

So for step 3, there are forge components that produce random numbers. If you think this is too much, or you enjoy coming up whith something creative yourself, you could make up your own randomizing logic making use of some random things like date, time, user information, time the user has taken to take the quizz so far, anything that separates one quiz taker from the next.

Dorine

Edit : I´ m not sure, but I think SQL Server might offer a function to generate random numbers, maybe you´ d need a sql widget to make use of it, maybe someone else knows this ???

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