for example, I am having 10 questions in my DB for that each question has a unique question id
If I enter 5 then 5 question id should be come randomly help me out on this
Discussion posts and replies are publicly visible
My quick solution is to fetch all the IDs from DB, then randomly remove items until only 5 are left.
a!localVariables( local!dbIds: {3,7,42,6,9,13,123,45,889,657}, reduce( rule!TST_RemoveRandomItemFromList(_,_), local!dbIds, enumerate(5) ) ) TST_RemoveRandomItemFromList( list(Integer Array), dummy(Integer) remove( ri!list, ceiling(rand() * count(ri!list)) )
This code is not working
Works for me. Can you explain the issue?
what is the purpose for the rule u used in that line no 4
It does what the name implies. It removes a random item from a given list.