Page 1 of 1

Random Questions

Posted: September 8th, 2017, 5:46 am
by prabhustat
Hi,

I want to develop a quiz survey. The survey contains 200 set of questions, I have to pick 10 questions randomly each time. anyone tried, please let me know.

Thanks in advance,

Prabhu

Re: Random Questions

Posted: September 8th, 2017, 7:29 am
by josh
That is an interesting one. Will be a little tricky to do in CSPro but I think you could get it to work. I can think of two different approaches:

1) Have a variable in your dictionary that repeats 10 times. Make the CAPI text just be replacement with a logic variable: "%QUESTIONTEXT%. Then in the onfocus of the variable choose a random question from your list of questions and set the QUESTIONTEXT and value set (using setvalueset) based on the random question you picked. You will need some logic to track which questions have been picked previously so that you can avoid picking the same question twice.

2) Have a variable for each of the 200 questions. Pick the 10 questions you are going to answer at the start of the questionnaire and store the question numbers in an array. In the preproc of each question check if the current question number is in the array of picked questions and if not skip it. You can use getsymbol() to get the current variable name so if you name the variables based on the question numbers you can figure out which question number you are on. That will let you put the code to do the skipping in a function so you don't have to copy and paste it 200 times.

Re: Random Questions

Posted: September 8th, 2017, 10:55 am
by prabhustat
Thanks Josh, let me try second option suits me.

Thanks,

Prabhu

Re: Random Questions

Posted: September 8th, 2017, 11:54 am
by josh
Sounds good. Let me know if you run into any issues.

When you get it to work please post a bit of the code here in case others need to do the same.

Re: Random Questions

Posted: September 10th, 2017, 9:03 am
by Saint
I did something similar before, but settle for systematic sampling of the questions. So I only needed to pick the first question randomly (using systime ranges) and then the subsequent questions were determined.

Re: Random Questions

Posted: September 10th, 2017, 10:46 pm
by prabhustat
Thanks Josh, sure I will share.