I have developed an application for Taking an online quiz which has questions and multiple choice answers each data is displayed in a page using pagination. I want to generate random questions with options so that each user gets a different set of questions. I am sharing my OML. I have also added randomizer from forge but I am unable to use it my aggregate. I am relatively new on this platform. Thanks in Advance.
Kindly find attached OML.
Please check page "Questionnaire_Modified" and FetchData action inside it.
Hello,
Please refer to the below post with similar requirement.
https://www.outsystems.com/forums/discussion/79540/random-item-from-a-list-aggregate/
Hope that helps.
Regards,
Anees
Hi I have tried it but unable to use it. I have shared the Oml, Can you please modify and help me with it. Thanks
Sure,
I have updated your oml and created a new button "Generate Random question" on click of that you will get new random question in the list.
I was wondering will it repeat the records and I dont want on button click I want to show random records as soon as the page is loaded. I was trying to open the Oml and I am getting an error whose screebshot is attatched.Thanks
Hey,I tried the steps defined by you but it is not working yet
I will assume that each Quiz has 10 questions and you have 100 questions into your database.
You will need to generate random numbers from 1 to 100 and make sure each time that generated number is not duplicated or generated before. You can do that by saving generated numbers into list of integer and each time generate new number check if its existing into this list or not until you generate 10 unique integers.
Now you can implement one of following options:
- First option, select all questions by aggregate then filter results based on generated numbers for example (Id = GeneratedNumbersList.Current) and save result to final questions list which will be used to display questions.
- Second option, you can use advanced SQL with inline parameter Ids and use action BuildSafe_InClauseIntegerList to create your inline paramter value.
You can read more about BuildSafe_InClauseIntegerList here : https://success.outsystems.com/documentation/11/reference/outsystems_apis/sanitization_api/#BuildSafe_InClauseIntegerList
- Third option, you can use same function BuildSafe_InClauseIntegerList after generating 10 numbers then add "," to start and end of returned result from action BuildSafe_InClauseIntegerList (final result will be like ",1,5,10,22,") then use following line into filter of aggregate:
Index(OutputString , Questions.Id) > -1
Yes, this is exactly what I want. I want it load as soon as the page loads.I am very new to outsystems. Can you please modify my oml