I'm thinking my way through a test-question database. I'd like a question bank and users be able to either 1. pick random questions, or 2. select types of questions. Right now, I'm trying to understand how the first option works.
I want to do a test. Since I teach math on top of trying to develop and maintain a school database, I want to create a database that has questions and answers. I'd like the user (right now me) to pick a certain number of questions and have the button pick random ones and then print them on the form i've got. I don't care if when I print it two or three times i get the same question. I'd like it to just pick x number of questions and print them on a page and then print the answer key for me.
In the table I have a question, answer field, as well as a randomNumber field. I think this will be useful
Here's what I think. I should have a script that:
SetVariable $Max = question::g_MaxNumberQuestions
SetVariable $Count = 0
SetField Questions::RandomNumber (round(random),0) // Not sure if this works. I want to set it to either 0 or 1 all the time.
If RandomNumber = 1 // if this field is 1, it has been selected for use.
SetVariable ($Count + 1) //add one to the count variable to keep track of how many questions have been chosen
If$Count = $Max
The next steps would be to print the questions, then print the answers, then clear the questions::randomNumber field to reset it for next time.
Is this an efficent way to do this? I'll give it a try, and it seems like it will work, but is there a better way?