0 votes
in SoSci Survey (English) by s112403 (110 points)

Hello,

I designed a survey with 48 questions and I want them to be randomly rotated. It works but once the questions are finished, the survey indicates a completion rate of 50% and it shows the questions again together with the answers provided.

I used the following code:

if (!isset($questions)) {
  $questions = array(  // list of question IDs
    'TR01',
    'TR02',
    'TR03',
    'TR04',
    'TR05',
    'TR06',
    'TR07',
    'TR08',
    'TR09',
    'TR10',
    'TR11',
    'TR12',
    'TR13',
    'TR14',
    'TR15',
    'TR16',
    'TH01',
    'TH02',
    'TH03',
    'TH04',
    'TH05',
    'TH06',
    'TH07',
    'TH08',
    'TH09',
    'TH10',
    'TH11',
    'TH12',
    'TH13',
    'TH14',
    'TH15',
    'TH16',
    'SA01',
    'SA02',
    'SA03',
    'SA04',
    'SA05',
    'SA06',
    'SA07',
    'SA08',
    'SA09',
    'SA10',
    'SA11',
    'SA12',
    'SA13',
    'SA14',
    'SA15',
    'SA16'
  );
  // shuffle list randomly
  shuffle($questions);
  registerVariable('questions'); 

}


$i = loopPage(count($questions));
question($questions[$i]);

What I am doing wrong?
Thank you in advance for your help.

by SoSci Survey (305k points)
The PHP code seems good. Could it be, you're using another PHP code in your survey? Maybe one that also uses the variable $questions?

Did you drag (!) the questions on any page in the questionnaire?
by s112403 (110 points)
Thanks for your reply. Yes, when I composed the survey I dragged the questions one by one, one per page. Is that the reason why it repeats itself? How can I correct it?

1 Answer

0 votes
by SoSci Survey (305k points)

Yes, when I composed the survey I dragged the questions one by one, one per page. Is that the reason why it repeats itself?

Dragging a question into a page and using question() does the same thing: It tells SoSci Survey to display the question on the page. If you do both, it is displayed twice.

Please drag all the questions from your questionnaire (or simple copy the PHP code to a new page an delete the other page/s). Then it should work.

by s112403 (110 points)
It worked! Thank you for your help.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...