if ($master) { echo "<th>UserName</th>"; } ?> <th>Name</th><th>Score/Grade</th><th>Date</th></tr> <?php global $sql_stmts; $quizzes = []; $quizzes_data = []; if ($master) { sql_getmany(sql_stmt("all quizzes"), $quizzes, []); } else { sql_getmany(sql_stmt("user_id->quiz_id reversed"), $quizzes, ["i", $suid]); } foreach ($quizzes as &$q) { $q = QUIZ($q); $quizzes_data[$q->id()] = $q->completed(); ?> <tr> <td><input name="quizzes" type="radio" value="<?php echo $q->id(); ?> "></td> <?php if ($master) { echo "<td>" . $q->username() . "</td>"; } ?> <td><?php echo $q->name(); ?>
function CURRENTQUIZ() { global $suid; if (safe_get("quiz_id", $_POST)) { $q = QUIZ($_POST["quiz_id"]); if ($q->is_authorized()) { return $q; } } elseif (safe_get("quiz_id", $_GET)) { $q = QUIZ($_GET["quiz_id"]); if ($q->is_authorized()) { return $q; } } elseif ($suid and quiz_getvalue("current_quiz_id")) { $q = QUIZ(quiz_getvalue("current_quiz_id")); if ($q->is_authorized()) { return $q; } else { quiz_delvalue("current_quiz_id"); } } elseif (quiz_getvalue("type")) { return QUIZ(TRUE); } }
<?php require_once '/var/www/config.php'; sro('/Includes/mysql.php'); sro('/Includes/session.php'); sro('/Includes/functions.php'); sro('/PHP5/lib/PHPLang/make_example.php'); sro('/PHP5/lib/PHPLang/display.php'); include_once 'quiz_types.php'; global $quiz_types; $id = array_key_exists("id", $_GET) ? $_GET["id"] : NULL; if ($id !== NULL and QUIZ($id)->is_authorized()) { echo json_encode(QUIZ($id)->data()); } else { if (array_key_exists($type, $quiz_types) and is_array($quiz_types[$type]) and array_key_exists("name", $quiz_types[$type])) { $type = $quiz_types[$type]["name"]; } print "Cannot find the type of quiz: \"{$type}\", or it was not valid, or you are not the correct user"; }
<?php require_once '/var/www/config.php'; sro('/Includes/mysql.php'); sro('/Includes/session.php'); sro('/Includes/functions.php'); sro('/PHP5/lib/PHPLang/display.php'); sro('/PHP5/quiz/common.php'); $id = array_key_exists("id", $_GET) ? $_GET["id"] : NULL; if ($id !== NULL and QUIZ($id)->is_authorized()) { $q = QUIZ($id); if ($q->delete()) { print "success"; } } else { print "Cannot find the quiz, or it was not valid, or you are not the correct user"; }
sro('/Includes/functions.php'); sro('/PHP5/quiz/common.php'); global $sql_stmts, $suid; ?> <header> <h1 data-i18n>Quiz</h1> </header> <article id="quiz"> <?php if (requireLoggedIn(FALSE)) { ?> <span data-i18n="quiz.loggedin">Review and resume previous quizzes</span> <a href="quizzes.php" data-i18n="ui.here">here</a>. <?php $quizzes = []; sql_getmany(sql_stmt("user_id->quiz_id reversed"), $quizzes, ["i", $suid]); foreach ($quizzes as $i => $q) { if (QUIZ($q)->completed()) { unset($quizzes[$i]); } } if (count($quizzes) == 1) { $pl = ""; } else { $pl = "zes"; } if (count($quizzes)) { echo "You have " . count($quizzes) . " quiz{$pl} to complete."; } } else { ?> <span data-i18n="quiz.loggedout">You are not logged in. Your scores cannot be saved.</span> <?php }