Ejemplo n.º 1
0
    $_SESSION["1_.{$questionId}._answer"] = $value[count($value) - 1];
    $cell2 = create_select(["name" => '1_' . $questionId, "contents" => $options]);
    echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $cell2]))]);
    $questionId++;
}
$brTag = create_element("br", false, null);
$questionId = 0;
foreach ($categoryTwo as $key => $value) {
    $cell1 = $key;
    $options = array();
    for ($i = 0; $i < count($value) - 1; $i++) {
        array_push($options, create_input(["type" => "checkbox", "value" => $value[$i], "name" => '2_' . $questionId . '_checklist[]']) . $value[$i]);
    }
    $_SESSION["2_.{$questionId}._answer"] = $value[count($value) - 1];
    $content = implode($brTag, $options);
    echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $content]))]);
    $questionId++;
}
$questionId = 0;
foreach ($categoryThree as $key => $value) {
    $cell1 = $key;
    $content = create_input(["type" => "text", "name" => '3_' . $questionId]);
    $_SESSION["3_.{$questionId}._answer"] = $value;
    echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $content]))]);
    $questionId++;
}
echo create_table_row(["contents" => array(create_table_cell(["contents" => create_input(["type" => "submit", "name" => "submit", "value" => "Send", "id" => "submit"])]))]);
end_table();
end_form();
end_body();
end_html();
Ejemplo n.º 2
0
for ($i = 0; $i < $_SESSION['cat2counter']; $i++) {
    $cell1 = '';
    if (!empty($_POST['2_' . $i . '_checklist'])) {
        foreach ($_POST['2_' . $i . '_checklist'] as $check) {
            $cell1 .= $check . ',';
        }
        $cell1 = substr($cell1, 0, strlen($cell1) - 1);
    }
    $cell2 = substr($_SESSION["2_.{$i}._answer"], strpos($_SESSION["1_.{$i}._answer"], '=') + 1);
    if (strcmp($cell1, $cell2) == 0) {
        $correctAnswers++;
    }
    echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $cell2]))]);
}
for ($i = 0; $i < $_SESSION['cat3counter']; $i++) {
    $cell1 = '';
    if (!empty($_POST['3_' . $i])) {
        $cell1 = strtolower(htmlentities($_POST['3_' . $i]));
    }
    $cell2 = strtolower($_SESSION["3_.{$i}._answer"]);
    if (strcmp($cell1, $cell2) == 0) {
        $correctAnswers++;
    }
    echo create_table_row(["contents" => array(create_table_cell(["contents" => $cell1]), create_table_cell(["contents" => $cell2]))]);
}
$score = 100.0 * $correctAnswers / ($_SESSION['cat1counter'] + $_SESSION['cat2counter'] + $_SESSION['cat3counter']);
echo create_table_row(["contents" => array(create_table_cell(["contents" => "Ukupan postotak"]), create_table_cell(["contents" => $score . '%']))]);
end_table();
end_form();
end_body();
end_html();