Permalink
Browse files

More or less working now

  • Loading branch information...
1 parent 3a506ca commit 36658798dca1f028db39e9287bd4f81df754b8d8 moodler committed Oct 6, 2002
Showing with 51 additions and 2 deletions.
  1. +51 −2 mod/quiz/view.php
View
@@ -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 "<P ALIGN=CENTER>The quiz is available: ";
+ } else {
+ echo "<P ALIGN=CENTER>The quiz is not available: ";
+ }
+ echo userdate($timestart)." - ".userdate($timefinish)." </P>";
+ }
+
+ if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) {
+ $numattempts = count($attempts);
+ } else {
+ $numattempts = 0;
+ }
+
+ echo "<P ALIGN=CENTER>You have attempted this quiz $numattempts times, out of $quiz->attempts allowed attempts.</P>";
+ 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 "<DIV align=CENTER>";
+ print_single_button("attempt.php", $options, $label="Attempt quiz now");
+ echo "</P>";
+ } else {
+ print_heading("You have no attempts left. Your final grade is $mygrade / $quiz->grade.");
+ }
// Finish the page

0 comments on commit 3665879

Please sign in to comment.