From 55c0c75c0337d86fac598aa655830f31ea44db52 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 6 Oct 2002 03:24:56 +0000 Subject: [PATCH] A start on the page that actually prints the questions and stores the answers --- mod/quiz/attempt.php | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 mod/quiz/attempt.php diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php new file mode 100644 index 0000000000..cb3ab1b4ff --- /dev/null +++ b/mod/quiz/attempt.php @@ -0,0 +1,109 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $quiz = get_record("quiz", "id", $cm->instance)) { + error("Course module is incorrect"); + } + + } else { + if (! $quiz = get_record("quiz", "id", $q)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $quiz->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) { + error("Course Module ID was incorrect"); + } + } + + require_login($course->id); + + add_to_log($course->id, "quiz", "attempt", "attempt.php?id=$cm->id", "$quiz->id"); + + if ($course->format == "weeks" and $quiz->days) { + $timenow = time(); + $timestart = $course->startdate + (($cw->section - 1) * 608400); + $timefinish = $timestart + (3600 * 24 * $quiz->days); + $available = ($timestart < $timenow and $timenow < $timefinish); + } else { + $available = true; + } + +// Print the page header + + if ($course->category) { + $navigation = "id\">$course->shortname ->"; + } + + $strquizzes = get_string("modulenameplural", "quiz"); + $strquiz = get_string("modulename", "quiz"); + + print_header("$course->shortname: $quiz->name", "$course->fullname", + "$navigation id>$strquizzes -> $quiz->name", + "", "", true, update_module_icon($cm->id, $course->id)); + +/// Print the headings and so on + + print_heading($quiz->name); + + if (!$available) { + error("Sorry, this quiz is not available", "view.php?id=$cm->id"); + } + + if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) { + $numattempts = count($attempts) + 1; + } else { + $numattempts = 1; + } + + if ($numattempts > $quiz->attempts) { + error("Sorry, you've had $quiz->attempts attempts already.", "view.php?id=$cm->id"); + } + + print_heading("Attempt $numattempts out of $quiz->attempts"); + + print_simple_box($quiz->intro, "CENTER"); + + +/// Print all the questions + + echo "
"; + print_simple_box_start("CENTER"); + + if (!$quiz->questions) { + error("No questions have bee defined!", "view.php?id=$cm->id"); + } + + $questions = explode(",", $quiz->questions); + + echo "
"; + echo "id\">"; + foreach ($questions as $key => $questionid) { + quiz_print_question($key+1, $questionid); + } + echo "
"; + echo "
"; + + print_simple_box_end(); + +// Finish the page + print_footer($course); + +?> -- 2.39.5