How to randomize the order of questions?

Hi everyone,

I want to create a random list of questions with passing a maximum number. And I need it in the format of 3,8,12,22,76… How can I do this? What I am going to do is once the random list is created as a string I am going to save it in one field in a table. Then just go through the numbers and load the questions in that order. I need to save the list in a table so I can stop and continue the questions. I’ll save the last question number each time.

Thanks!

Warren

Found the answer in case anyone needs it.

local myArray = {} local valueArray = {1,2,3,4,5,6,7,8,9,10} -- let it be the array with values 1,2...M local index = 0 local isFetched = {} for i=1,#valueArray do isFetched[i] = 0 end local randomValue = 0 local function addTomyArray() randomValue = math.random(#valueArray) if(isFetched[randomValue]==0)then index = index + 1 isFetched[randomValue] = 1 myArray[index] = valueArray[randomValue] if(index==#valueArray)then for i=1,#myArray do print(myArray[i]) -- result : shuffled array end end else addTomyArray() end end timer.performWithDelay(0,addTomyArray,#valueArray)

Found the answer in case anyone needs it.

local myArray = {} local valueArray = {1,2,3,4,5,6,7,8,9,10} -- let it be the array with values 1,2...M local index = 0 local isFetched = {} for i=1,#valueArray do isFetched[i] = 0 end local randomValue = 0 local function addTomyArray() randomValue = math.random(#valueArray) if(isFetched[randomValue]==0)then index = index + 1 isFetched[randomValue] = 1 myArray[index] = valueArray[randomValue] if(index==#valueArray)then for i=1,#myArray do print(myArray[i]) -- result : shuffled array end end else addTomyArray() end end timer.performWithDelay(0,addTomyArray,#valueArray)