Random Questions

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Random Questions

Post 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
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Random Questions

Post 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.
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Random Questions

Post by prabhustat »

Thanks Josh, let me try second option suits me.

Thanks,

Prabhu
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Random Questions

Post 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.
Saint
Posts: 63
Joined: November 22nd, 2013, 4:59 am

Re: Random Questions

Post 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.
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Random Questions

Post by prabhustat »

Thanks Josh, sure I will share.
Post Reply