More or less working now
This commit is contained in:
+51
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user