klappt leider noch nicht. Jetzt, wo ich die Klammern wieder umgestellt habe, habe ich wieder die Fehlermeldung vom Anfang:
Fehler im Fragebogen: Die PHP-Variable $itemBlocks wurde verwendet, in diesem PHP-Code aber noch nicht definiert (sie enthält noch keinen Wert).
PHP-Code
139 registerVariable('itemBlocks');
140 }
141
142 $i = loopPage(count($itemBlocks));
143
144
145 question('TN01', 'spacing=0', 'show-items=no');
Fehler im Fragebogen: count(): Parameter must be an array or an object that implements Countable
Zeile: 142
PHP-Code
139 registerVariable('itemBlocks');
140 }
141
142 $i = loopPage(count($itemBlocks));
143
144
145 question('TN01', 'spacing=0', 'show-items=no');
Fehler im Fragebogen: Die PHP-Variable $itemBlocks wurde verwendet, in diesem PHP-Code aber noch nicht definiert (sie enthält noch keinen Wert).
PHP-Code
145 question('TN01', 'spacing=0', 'show-items=no');
146
147
148 $items = $itemBlocks[$i];
149 foreach ($items as $item) {
150 question($item[0], $item[1], $item[2], $item[3], $item[4], 'spacing=0', 'show-title=no', 'show-explanation=no');
151 }
Fehler im Fragebogen: Invalid argument supplied for foreach()
Zeile: 149
PHP-Code
146
147
148 $items = $itemBlocks[$i];
149 foreach ($items as $item) {
150 question($item[0], $item[1], $item[2], $item[3], $item[4], 'spacing=0', 'show-title=no', 'show-explanation=no');
151 }
152 return 'ok';
Der Code lautet jetzt:
if (isset($itemBlocks)) {
$questions = ['TN01', 'TN02', 'TN03', 'TN04', 'TN05'];
// Liste mit allen Items erstellen
$items = [
['TN01', 1],
['TN01', 2],
['TN01', 3],
['TN01', 4],
['TN01', 5],
['TN01', 6],
['TN01', 7],
['TN01', 8],
['TN01', 9],
['TN01', 10],
['TN01', 11],
['TN01', 12],
['TN01', 13],
['TN01', 14],
['TN01', 15],
['TN01', 16],
['TN01', 17],
['TN01', 18],
['TN01', 19],
['TN01', 20],
['TN01', 21],
['TN01', 22],
['TN02', 1],
['TN02', 2],
['TN02', 3],
['TN02', 4],
['TN02', 5],
['TN02', 6],
['TN02', 7],
['TN02', 8],
['TN02', 9],
['TN02', 10],
['TN02', 11],
['TN02', 12],
['TN02', 13],
['TN02', 14],
['TN02', 15],
['TN02', 16],
['TN02', 17],
['TN02', 18],
['TN02', 19],
['TN02', 20],
['TN02', 21],
['TN02', 22],
['TN02', 23],
['TN02', 24],
['TN02', 25],
['TN02', 26],
['TN02', 27],
['TN02', 28],
['TN02', 29],
['TN02', 30],
['TN03', 1],
['TN03', 2],
['TN03', 3],
['TN03', 4],
['TN03', 5],
['TN03', 6],
['TN03', 7],
['TN03', 8],
['TN03', 9],
['TN03', 10],
['TN03', 11],
['TN03', 12],
['TN03', 13],
['TN03', 14],
['TN03', 15],
['TN03', 16],
['TN03', 17],
['TN03', 18],
['TN03', 19],
['TN03', 20],
['TN03', 21],
['TN03', 22],
['TN03', 23],
['TN03', 24],
['TN03', 25],
['TN03', 26],
['TN03', 27],
['TN03', 28],
['TN03', 29],
['TN03', 30],
['TN04', 1],
['TN04', 2],
['TN04', 3],
['TN04', 4],
['TN04', 5],
['TN04', 6],
['TN04', 7],
['TN04', 8],
['TN04', 9],
['TN04', 10],
['TN04', 11],
['TN04', 12],
['TN04', 13],
['TN04', 14],
['TN04', 15],
['TN04', 16],
['TN04', 17],
['TN04', 18],
['TN05', 1],
['TN05', 2],
['TN05', 3],
['TN05', 4],
['TN05', 5],
['TN05', 6],
['TN05', 7],
['TN05', 8],
['TN05', 9],
['TN05', 10],
['TN05', 11],
['TN05', 12],
['TN05', 13],
['TN05', 14],
['TN05', 15],
['TN05', 16],
['TN05', 17],
['TN05', 18],
['TN05', 19],
['TN05', 20],
['TN05', 21],
['TN05', 22],
['TN05', 23],
['TN05', 24],
['TN05', 25]
];
// Liste mischen
shuffle($items);
// Liste aufteilen
$itemBlocks = array_chunk($items, 25);
registerVariable($itemBlocks);
}
// Auf mehreren Seiten präsentieren
$i = loopPage(count($itemBlocks));
// Fragetext anzeigen
question('TN01', 'spacing=0', 'show-items=no');
// Items anzeigen
$items = $itemBlocks[$i];
foreach ($items as $item) {
question($item[0], $item[1], $item[2], $item[3], $item[4], 'spacing=0', 'show-title=no', 'show-explanation=no');
}