application_log("error", "Unable to create a quiz_progress entery when attempting complete a quiz. Database said: " . $db->ErrorMsg()); } } if (isset($qprogress_id) && $qprogress_id) { add_statistic("events", "quiz_view", "aquiz_id", $RECORD_ID); $quiz_timeout = (int) $quiz_record["quiz_timeout"] ? $quiz_record["quiz_timeout"] * 60 : 0; $quiz_end_time = $quiz_timeout ? $quiz_start_time + $quiz_timeout : 0; /** * Check to see if the release_until date is before the current end_time, * if it is, shorten the $quiz_end_time to the release_until date. */ if ($quiz_end_time && (int) $quiz_record["release_until"] && $quiz_end_time > $quiz_record["release_until"]) { $quiz_end_time = $quiz_record["release_until"]; } $quiz_time_remaining = $quiz_end_time - time(); $ajax_load_progress = quiz_load_progress($qprogress_id); if ($quiz_end_time) { ?> <div id="display-quiz-timeout" class="display-generic"> You have until <strong><?php echo date(DEFAULT_DATE_FORMAT, $quiz_end_time); ?> </strong> to complete this quiz. <div id="quiz-timer" style="margin-top: 15px; display: none"></div> </div> <script type="text/javascript"> function quizTimeout(timeout) { this.timeout = timeout; function countdown() {
if ($is_administrator) { $BREADCRUMB[] = array("url" => ENTRADA_URL . "/admin/" . $MODULE . "?section=results" . ($QUIZ_TYPE == "community_page" ? "&community=true" : "") . "&id=" . $quiz_record["aquiz_id"], "title" => "Quiz Results"); $BREADCRUMB[] = array("url" => "", "title" => $respondent_name); } /** * Providing there is no expiry date, or the expiry date is in the * future on both the quiz and the event, allow them to continue. */ if ($is_administrator || $quiz_record["quiztype_code"] == "immediate" || $quiz_record["quiztype_code"] == "delayed" && ((int) $quiz_record["release_until"] === 0 || $quiz_record["release_until"] <= time())) { $quiz_score = $quiz_record["quiz_score"]; $quiz_value = $quiz_record["quiz_value"]; $query = "\tSELECT a.*\n\t\t\t\t\t\t\t\tFROM `quiz_questions` AS a\n\t\t\t\t\t\t\t\tWHERE a.`quiz_id` = " . $db->qstr($quiz_record["quiz_id"]) . "\n\t\t\t\t\t\t\t\tAND a.`question_active` = '1'\n\t\t\t\t\t\t\t\tORDER BY a.`question_order` ASC"; $questions = $db->GetAll($query); $questions = Models_Quiz_Question::fetchAllRecords($quiz_record["quiz_id"]); if ($questions) { $PROCESSED = quiz_load_progress($RECORD_ID); /** * Calculates the percentage for display purposes. */ $quiz_percentage = round($quiz_score / $quiz_value, 2) * 100; if ($quiz_percentage >= 70) { $display_class = "success"; } elseif ($quiz_percentage > 50 && $quiz_percentage < 70) { $display_class = "notice"; } else { $display_class = "error"; } echo "<h1>" . html_encode($quiz_record["quiz_title"]) . "</h1>"; ?> <div class="display-<?php echo $display_class;
$query = "DELETE FROM `quiz_progress_responses` WHERE `qquestion_id` = " . $db->qstr($quiz_question["qquestion_id"]); if ($db->Execute($query)) { $query = "\tSELECT * FROM `quiz_progress`\n\t\t\t\t\t\t\tWHERE `quiz_id` = " . $db->qstr($quiz_question["quiz_id"]) . "\n\t\t\t\t\t\t\tORDER BY `updated_date` ASC"; $progress_records = $db->GetAll($query); if ($progress_records) { foreach ($progress_records as $progress_record) { /** * Get a list of all of the questions in this quiz so we * can run through a clean set of questions. */ $query = "\tSELECT a.*\n\t\t\t\t\t\t\t\t\t\tFROM `quiz_questions` AS a\n\t\t\t\t\t\t\t\t\t\tWHERE a.`quiz_id` = " . $db->qstr($progress_record["quiz_id"]) . "\n\t\t\t\t\t\t\t\t\t\tORDER BY a.`question_order` ASC"; $questions = $db->GetAll($query); $qprogress_id = $progress_record["qprogress_id"]; $quiz_score = 0; $quiz_value = 0; $PROCESSED = quiz_load_progress($qprogress_id); foreach ($questions as $question) { $question_correct = false; $question_points = 0; $query = "\tSELECT a.*\n\t\t\t\t\t\t\t\t\t\t\tFROM `quiz_question_responses` AS a\n\t\t\t\t\t\t\t\t\t\t\tWHERE a.`qquestion_id` = " . $db->qstr($question["qquestion_id"]) . "\n\t\t\t\t\t\t\t\t\t\t\tORDER BY " . ($question["randomize_responses"] == 1 ? "RAND()" : "a.`response_order` ASC"); $responses = $db->GetAll($query); if ($responses) { foreach ($responses as $response) { $response_selected = false; $response_correct = false; if ($PROCESSED[$question["qquestion_id"]] == $response["qqresponse_id"]) { $response_selected = true; if ($response["response_correct"] == 1) { $response_correct = true; $question_correct = true; $question_points = $question["question_points"];