0 votes
in SoSci Survey (English) by s076476 (135 points)
edited by SoSci Survey

I am trying to randomize combined questions. Unfortunately it is not working, I have the following code:

$a = array(question('RC01', 'combine=RC40', 'gap=line'),  
question('RC03', 'combine=RC50', 'gap=line'),
question('RC04', 'combine=RC51', 'gap=line'),
question('RC06', 'combine=RC48', 'gap=line'),
question('RC05', 'combine=RC37', 'gap=line'), 
question('RC07', 'combine=RC49', 'gap=line'),
question('RC08', 'combine=RC52', 'gap=line'),
question('RC09', 'combine=RC53', 'gap=line'),
question('RC10', 'combine=RC42', 'gap=line'), 
question('RC11', 'combine=RC54', 'gap=line'),
question('RC12', 'combine=RC55', 'gap=line'),
question('RC24', 'combine=RC43', 'gap=line'),  
question('RC25', 'combine=RC56', 'gap=line'),
question('RC26', 'combine=RC57', 'gap=line'),
question('RC28', 'combine=RC58', 'gap=line'),
question('RC29', 'combine=RC59', 'gap=line'),
question('RC20', 'combine=RC41', 'gap=line'),  
question('RC27', 'combine=RC44', 'gap=line'),  
question('RC35', 'combine=RC60', 'gap=line'),
question('RC36', 'combine=RC61', 'gap=line'),
question('RC34', 'combine=RC45', 'gap=line')); 

shuffle($a);

$a[0];
$a[1];
$a[2];
$a[3];
$a[4];
$a[5];
$a[6];
$a[7];
$a[8];
$a[9];
$a[10];
$a[11];
$a[12];
$a[13];
$a[14];
$a[15];
$a[16];
$a[17];
$a[18];
$a[19];
$a[20];

Could someone please help?

1 Answer

0 votes
by SoSci Survey (306k points)
selected by s076476
 
Best answer

Please be sure NOT du put the question() function into your array, but only the question IDs.

Would you like to display all questions on the same page or on different pages?

Here's some PHP code to start with:

$questions = [
  ['RC03', 'RC50'],
  ['RC04', 'RC51'],
  // ...
];
if (!isset($order)) {
  $order = array_keys($questions);
  shuffle($order);
  registerVariable($order);
}
$i = loopPage($order);
question($questions[$i], 'gap=line');
by s076476 (135 points)
Thank you so much! That was very helpful! And it is working.
I just need them to be on one page.
What do I have to change?
by SoSci Survey (306k points)
Please replace

$i = loopPage($order);
question($questions[$i], 'gap=line');

by this PHP code

foreach ($order as $i) {
  question($questions[$i], 'gap=line');
}
by s076476 (135 points)
You have been such a big help! Thank you so much!!

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

...