From 36658798dca1f028db39e9287bd4f81df754b8d8 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 6 Oct 2002 03:23:34 +0000 Subject: [PATCH] More or less working now --- mod/quiz/view.php | 53 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 5e941c4fc1..2fff1da035 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -22,7 +22,7 @@ } } else { - if (! $quiz = get_record("quiz", "id", $a)) { + if (! $quiz = get_record("quiz", "id", $q)) { error("Course module is incorrect"); } if (! $course = get_record("course", "id", $quiz->course)) { @@ -37,6 +37,15 @@ add_to_log($course->id, "quiz", "view", "view.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) { @@ -52,7 +61,47 @@ // Print the main part of the page - echo "YOUR CODE GOES HERE"; + print_heading($quiz->name); + + print_simple_box($quiz->intro, "CENTER"); + + if (isset($timestart) and isset($timefinish)) { + if ($available) { + echo "

The quiz is available: "; + } else { + echo "

The quiz is not available: "; + } + echo userdate($timestart)." - ".userdate($timefinish)."

"; + } + + if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) { + $numattempts = count($attempts); + } else { + $numattempts = 0; + } + + echo "

You have attempted this quiz $numattempts times, out of $quiz->attempts allowed attempts.

"; + if ($numattempts) { + $table->data = array("Attempt", "Time", "Grade"); + foreach ($attempts as $attempt) { + $table->data = array($attempt->attempt, userdate($attempt->timemodified), $attempt->grade); + } + print_table($table); + } + + $mygrade = quiz_get_grade($quiz->id, $USER->id); + + if ($numattempts < $quiz->attempts) { + $options["id"] = $quiz->id; + if ($numattempts) { + print_heading("Your best grade so far is $mygrade / $quiz->grade."); + } + echo "
"; + print_single_button("attempt.php", $options, $label="Attempt quiz now"); + echo "

"; + } else { + print_heading("You have no attempts left. Your final grade is $mygrade / $quiz->grade."); + } // Finish the page -- 2.39.5