0 votes
in SoSci Survey (English) by s106223 (120 points)
closed by SoSci Survey

Hi,

I have two separate sections with 72 questions each.
I need to present specific 24 questions from one section and specific 24 questions from the other section in a random order on the same page.

I know how to do it if drawing the questions from one section only.
I tried to adapt the code to draw the questions from both sections (I'm pasting it below).

However, I never get presented all 48 items and I cannot find the error. I can think of that e.g. $questionsNN is not registered as an array, therefore array_merge is inappropriate, and tried to combine it as variables, but that doesn't work either.

Please help!
Thank you in advance.

    if (!isset($questionsNN)) {
  $questionsNN = array(
    'NN01', 'NN02', 'NN11', 'NN12', 
	'NN15',	'NN16', 'NN19', 'NN20', 
	'NN29', 'NN30', 'NN33', 'NN34', 
	'NN37', 'NN38', 'NN47', 'NN48', 
	'NN51', 'NN52', 'NN55', 'NN56', 
	'NN65', 'NN66', 'NN69', 'NN70'
  );
  registerVariable('questionsNN');
}
if (!isset($questionsNQ)) {
  $questionsNQ = array(
    'NQ01', 'NQ02', 'NQ11', 'NQ12', 
	'NQ15',	'NQ16', 'NQ19', 'NQ20', 
	'NQ29', 'NQ30', 'NQ33', 'NQ34', 
	'NQ37', 'NQ38', 'NQ47', 'NQ48', 
	'NQ51', 'NQ52', 'NQ55', 'NQ56', 
	'NQ65', 'NQ66', 'NQ69', 'NQ70'
  ); 
  registerVariable('questionsNQ');
}
if (!isset($NE_all)) {
    $NE_all = array_merge($questionsNN, $questionsNQ);
    shuffle($NE_all);
    registerVariable('NE_all');
}
$ne = loopPage(count($NE_all));
question($NE_all[$ne]);
for ($i=0; $i<count($NE_all); $i++) {
  $id = id('NN75', $i + 1);
  put($id, $NE_all[$i]);
}
closed with the note: Problem solved :)
by s106223 (120 points)
What actually happens (I followed it in the debug window) is that it skips loops.
E.g. it stands loopPage() i=8, and than it shows 9 but quickly skips to 10 without showing the question from page 9.
by s106223 (120 points)
Solved it and changed the code in the original message to the one that works, if somebody needed this ever.

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

...