0 votes
in SoSci Survey (English) by s300574 (110 points)
edited by SoSci Survey

Each question consists out of 4 items. I want to be able to analyse those afterwards seperately but show them in my survey in one question with in a random order.
My PHP-Code shows just the text ofthe first question, not the items of all 4 questions. What do I need to adjust?

$fragen = ['HU01', 'HU02', 'HU03', 'HU04'];
$itemliste = [];
foreach ($fragen as $frage) {
  foreach (getItems($frage, 'all') as $item) {
    $itemsliste[] = [$frage, $item];
  }
}

// Mischen
if (!isset($itemMix)) {
  $itemMix = $itemliste;
  registerVariable($itemMix);
}

// Fragetext anzeigen
question('HU01', 'show-items=no', 'spacing=0');
foreach ($itemliste as $info) {
  $frage = $info[0];
  $item = $info[1];
  question($frage, $item, 'show-title=no', 'show-explanation=no', 'spacing=0');
}

// Items einzeln anzeigen
foreach ($itemMix as $info) {
  $frage = $info[0];
  $item = $info[1];
  question($frage, $item, 'show-title=no', 'show-explanation=no', 'spacing=0');
}

1 Answer

0 votes
by SoSci Survey (327k points)

I want to be able to analyse those afterwards seperately but show them in my survey in one question

You can put them into one question, and (if you like, it's technically not necessary) give the variables custom names, so can can more easily distinguish the separate variable sets.

My PHP-Code shows just the text ofthe first question

It seems you have som duplication there. Try this one:

if (!isset($itemsliste)) {

  $fragen = ['HU01', 'HU02', 'HU03', 'HU04'];
  $itemliste = [];
  foreach ($fragen as $frage) {
    foreach (getItems($frage, 'all') as $item) {
      $itemsliste[] = [$frage, $item];
    }
  }

  shuffle($itemsliste);
  registerVariable($itemsliste);
  debug($itemsliste);
}

// Fragetext anzeigen
question('HU01', 'show-items=no', 'spacing=0');
foreach ($itemliste as $info) {
  $frage = $info[0];
  $item = $info[1];
  question($frage, $item, 'show-title=no', 'show-explanation=no', 'spacing=0');
}

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

...