Hallo Allerseits
ich nutze folgenden Code zusammen mit der loopPage()-Funktion, da ich 18 verschiedene Seiten für je 5 Versuchsgruppen brauche. Also 90 Seiten, die vom Aufbau ähnlich sind.
Je nach Versuchsgruppe und Zufallsziehung der Reihenfolge werden im PHP die variablennamen erzeugt, die Bilder, Text und Fragen aufrufen sollen. Das funktioniert auch alles korrekt und ohne Fehlermeldung. Allerdings kann man sich durch den Fragebogen klicken, obwohl man Fragen nicht beantwortet hat, diese aber eigentlich mit Antwortpflicht eingestellt sind.
Vielen Dank für die Hilfe
Erst der wichtige Codeteil, der die Fragebogenseite erstellt:
[...]
//START HTML TABLE
// the [' .] combination ends html and code enables to enter PHP code
html('
<table style="width:80%" align="center">
<tr>
<td width="60%">
<img src=' . $picture_id . ' width="100%">
</td>
<td>
');
//ADD TEXT
if ($id_number == 3 || $id_number == 7 || $id_number == 11 ||
$id_number == 15 || $id_number == 18) {
text($delete_text_id, 'spacing=default');
question($delete_text_id);
} else {
if ($group != 1) {
html('<h3>Erklärung:</h3>');
text($text_id, 'spacing=default');
html('<br>');
}
text($delete_text_id, 'spacing=default');
question($delete_text_id);
}
//END TABLE
html('
</td>
</tr>
</table>
');
Und der Gesamte Code:
$int_loop = loopPage(1,18,1); //loop page 18 times
$text = (string)$int_loop; //loop_counter to string
// get random group value (gleichverteilung abgeschlossener fragebögen)
$group = value('ZF01');
// create base-string depending on experimental-group
if ($group == 1) {
$id_base = "TPNO"; //base_ID_string for "testphase, nicht, ohne"
} elseif ($group == 2) {
$id_base = "TPKO"; //base_ID_string for "testphase, kurz, ohne"
} elseif ($group == 3) {
$id_base = "TPKF"; //base_ID_string for "testphase, kurz, farbig"
} elseif ($group == 4) {
$id_base = "TPLO"; //base_ID_string for "testphase, lang, ohne"
} elseif ($group == 5) {
$id_base = "TPLF"; //base_ID_string for "testphase, lang, farbig"
}
// base-ID for "delete a file" textbausteine
$delete_text_id_base = "TP";
// id number variable set to -99 to find code errors
$id_number = -99;
// Creation of variables
// reistration as global variables
if ($int_loop == 1) {
$countA = 1; // 2+1
$countB = 4; // 3+1
$countC = 8; // 3+1
$countD = 12; // 3+1
$countE = 16; // 2+1
registerVariable($countA);
registerVariable($countB);
registerVariable($countC);
registerVariable($countD);
registerVariable($countE);
$folder1 = value('ZF02x01', 'label');
$folder2 = value('ZF02x02', 'label');
$folder3 = value('ZF02x03', 'label');
$folder4 = value('ZF02x04', 'label');
$folder5 = value('ZF02x05', 'label');
registerVariable($folder1);
registerVariable($folder2);
registerVariable($folder3);
registerVariable($folder4);
registerVariable($folder5);
$folderSwitch = 1;
registerVariable($folderSwitch);
}
// Conditions to get correct number for IDcreation
if ($folderSwitch == 1) {
if ($folder1 == 1) {
$id_number = $countA;
$countA = $countA + 1;
registerVariable($countA);
if ($countA == 4) {
$folderSwitch = $folderSwitch + 1;
registerVariable($folderSwitch);
}
} elseif ($folder1 == 2) {
$id_number = $countB;
$countB = $countB + 1;
registerVariable($countB);
if ($countB == 8) {
$folderSwitch = $folderSwitch + 1;
registerVariable($folderSwitch);
}
} elseif ($folder1 == 3) {
$id_number = $countC;
$countC = $countC + 1;
registerVariable($countC);
if ($countC == 12) {
$folderSwitch = $folderSwitch + 1;
registerVariable($folderSwitch);
}
[...]
}
}
// Creation of IDs
$text_id = $id_base . sprintf('%02d', $id_number);
$delete_text_id = $delete_text_id_base . sprintf('%02d', $id_number);
if ($group == 1 || $group == 2 || $group == 4 || $id_number == 3 ||
$id_number == 7 || $id_number == 11 || $id_number == 15 ||
$id_number == 18) {
if ($id_number <= 3) {
$picture_id = "TPNO01.png";
} elseif ($id_number <= 7) {
$picture_id = "TPNO04.png";
} elseif ($id_number <= 11) {
$picture_id = "TPNO08.png";
} elseif ($id_number <= 11) {
$picture_id = "TPNO08.png";
} elseif ($id_number <= 15) {
$picture_id = "TPNO12.png";
} elseif ($id_number <= 18) {
$picture_id = "TPNO16.png";
}
} else {
$picture_id = $text_id . ".png";
}
//START HTML TABLE
// the [' .] combination ends html and code enables to enter PHP code
html('
<table style="width:80%" align="center">
<tr>
<td width="60%">
<img src=' . $picture_id . ' width="100%">
</td>
<td>
');
//ADD TEXT
if ($id_number == 3 || $id_number == 7 || $id_number == 11 ||
$id_number == 15 || $id_number == 18) {
text($delete_text_id, 'spacing=default');
question($delete_text_id);
} else {
if ($group != 1) {
html('<h3>Erklärung:</h3>');
text($text_id, 'spacing=default');
html('<br>');
}
text($delete_text_id, 'spacing=default');
question($delete_text_id);
}
//END TABLE
html('
</td>
</tr>
</table>
');