Im Fragebogen habe ich folgenden PHP Code als ARRAY angelegt.
$fragen = [
'IN01' => [1 => 0],
'AL02' => [1 => 0, 2 => 0],
'AL02' => [1 => 0, 2 => 0],
'GS01' => [1 => 2, 2 => 0],
'GA01' => [1 => 2, 2 => 0, 3 => - 2],
'B101' => [1 => -4, 2 => -2, 3 => 0, 4 => 3],
'B102' => [1 => -2, 2 => 0, 3 => 3, 4 => 5],
'B103' => [1 => -2, 2 => 0, 3 => 1],
'E001' => [1 => -2, 2 => -1, 3 => 0, 4 => 1],
'E002' => [1 => -3, 2=> -1, 3 => 2, 3 => 4],
'E003' => [1 => -2, 2 => 0, 3 => 1],
'E004' => [1 => 4, 2 => 2, 3 => 0],
'E005' => [1 => 0, 2 => 2],
'E006' => [1 => -2, 2 => -1, 3 => 0],
'E007' => [1 => 0, 2 => -1, 3 => -3],
'E008' => [1 => 0, 2 => -1, 3 => -3],
'E009' => [1 => 0, 2 => -1, 3 => -3],
'L001' => [1 => -8, 2 => -6, 3 => -4, 4 => 0, 5 => -4, 6 => -2],
'L002' => [1 => 4, 2 => 2, 3 => 0, 4 => -4, 5 => -2],
'S001' => [1 => -2, 2 => 0, 3 => 2],
'S002' => [1 => 3, 2 => 1, 3 => -1, 4 => -3],
'D001' => [1 => 0, 2 => -2, 3 => -4, 4 => -6, 5 => -8],
'D005' => [1 => 0, 2 => 0],
'D006' => [1 => 0, 2 => 1, 3 => -2],
'D003' => [1 => -1, 2 => 1],
'V001' => [1 => -6, 2 => -4, 3 => -2, 4 => 0, 5 => -3, 6 => -2],
'V002' => [1 => -6, 2 => 0, 3 => -2],
'V003' => [1 => -6, 2 => 0],
'V004' => [1 => -12, 2 => 0],
'GD01' => [1 => -4, 2 => -2, 3 => 0, 4 => 0],
'P001' => [1 => -4, 2 => -2, 3 => 0, 4 => 2, 5 => 4],
'P002' => [1 => -4, 2 => 4],
'P003' => [1 => -2, 2 => 0, 3 => 2],
'P004' => [1 => 4, 2 => 2, 3 => 0, 4 => -2, 5 => -4],
'P005' => [1 => -6, 2 => -4, 3 => 2],
'P006' => [1 => 0, 2 => -2, 3 => -4],
'P007' => [1 => 0, 2 => -1, 3 => -2, 4 => -3],
'RA01' => [1 => 4, 2 => 2, 3 => 0, 4 => -2, 5 => -4],
'RA02' => [1 => 4, 2 => 2, 3 => 0, 4 => -2, 5 => -4],
'RA03' => [1 => -4, 2 => 4, 3 => -4],
'RA04' => [1 => 6, 2 => 4, 3 => 0, 4 => -2],
'BP01' => [1 => -4, 2 => 0, 3 => 4],
'RF01' => [1 => -4, 2 => -2, 3 => 2, 4 => 4]];
$points = 0;
foreach ($fragen as $variable => $values) {
// Antwort des Teilnehmers abrufen
$answer = value($variable);
// Prüfen, ob für diese Antwort ein Wert vorliegt (sonst keinen Punkt vergeben)
if (isset($values[$answer])) {
// Zählen des Wertes
$points += $values[$answer];}}
html('<p>Sie haben '.$points.' Punkte erzielt.</p>');
Ich habe jedoch keine interne Variable angelegt. Wie kann ich nun die Funktion put () noch nachträglich ergänzen, um den Summenwert im Datensatz zu sehen?