Due date and start date are now optional, as requested in bug 867 and bug 3635

This commit is contained in:
gustav_delius 2005-07-07 17:16:56 +00:00
parent a61a956c65
commit bb52d44c6a
9 changed files with 175 additions and 91 deletions

View file

@ -365,7 +365,7 @@
/// Check access to quiz page /// Check access to quiz page
// check the quiz times // check the quiz times
if (($timestamp < $quiz->timeopen || $timestamp > $quiz->timeclose)) { if ($timestamp < $quiz->timeopen || ($quiz->timeclose and $timestamp > $quiz->timeclose)) {
if ($isteacher) { if ($isteacher) {
notify(get_string('notavailabletostudents', 'quiz')); notify(get_string('notavailabletostudents', 'quiz'));
} else { } else {
@ -473,7 +473,7 @@
echo "</form>\n"; echo "</form>\n";
$secondsleft = $quiz->timeclose - time(); $secondsleft = ($quiz->timeclose ? $quiz->timeclose : 999999999999) - time();
// If time limit is set include floating timer. // If time limit is set include floating timer.
if ($quiz->timelimit > 0) { if ($quiz->timelimit > 0) {

View file

@ -101,7 +101,7 @@
$currentsection = $quiz->section; $currentsection = $quiz->section;
} }
$closequiz = userdate($quiz->timeclose); $closequiz = $quiz->timeclose ? userdate($quiz->timeclose) : '';
if (isteacher($course->id)) { if (isteacher($course->id)) {
if ($usercount = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)')) { if ($usercount = count_records_select('quiz_attempts', "quiz = '$quiz->id' AND preview = '0'", 'COUNT(DISTINCT userid)')) {

View file

@ -26,10 +26,22 @@ function quiz_add_instance($quiz) {
$quiz->created = time(); $quiz->created = time();
$quiz->timemodified = time(); $quiz->timemodified = time();
$quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, // The following is adapted from the assignment module
$quiz->openhour, $quiz->openminute, 0); if (empty($quiz->dueenable)) {
$quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, $quiz->timeclose = 0;
$quiz->closehour, $quiz->closeminute, 0); } else {
$quiz->timeclose = make_timestamp($quiz->dueyear, $quiz->duemonth,
$quiz->dueday, $quiz->duehour,
$quiz->dueminute);
}
if (empty($quiz->availableenable)) {
$quiz->timeopen = 0;
$quiz->preventlate = 0;
} else {
$quiz->timeopen = make_timestamp($quiz->availableyear, $quiz->availablemonth,
$quiz->availableday, $quiz->availablehour,
$quiz->availableminute);
}
if (empty($quiz->name)) { if (empty($quiz->name)) {
if (empty($quiz->intro)) { if (empty($quiz->intro)) {
@ -50,35 +62,48 @@ function quiz_add_instance($quiz) {
delete_records('event', 'modulename', 'quiz', 'instance', $quiz->id); // Just in case delete_records('event', 'modulename', 'quiz', 'instance', $quiz->id); // Just in case
$event = NULL; unset($event);
$event->name = $quiz->name;
$event->description = $quiz->intro; $event->description = $quiz->intro;
$event->courseid = $quiz->course; $event->courseid = $quiz->course;
$event->groupid = 0; $event->groupid = 0;
$event->userid = 0; $event->userid = 0;
$event->modulename = 'quiz'; $event->modulename = 'quiz';
$event->instance = $quiz->id; $event->instance = $quiz->id;
$event->eventtype = 'open';
$event->timestart = $quiz->timeopen; $event->timestart = $quiz->timeopen;
$event->visible = instance_is_visible('quiz', $quiz); $event->visible = instance_is_visible('quiz', $quiz);
$event->timeduration = ($quiz->timeclose - $quiz->timeopen);
if ($event->timeduration > QUIZ_MAX_EVENT_LENGTH) { /// Long durations create two events if ($quiz->timeclose and $quiz->timeopen) {
$event2 = $event; // we have both a start and an end date
$event->eventtype = 'open';
$event->timeduration = ($quiz->timeclose - $quiz->timeopen);
$event->name .= ' ('.get_string('quizopens', 'quiz').')'; if ($event->timeduration > QUIZ_MAX_EVENT_LENGTH) { /// Long durations create two events
$event->timeduration = 0;
$event2->timestart = $quiz->timeclose; $event->name = $quiz->name.' ('.get_string('quizopens', 'quiz').')';
$event2->eventtype = 'close'; $event->timeduration = 0;
$event2->timeduration = 0; add_event($event);
$event2->name .= ' ('.get_string('quizcloses', 'quiz').')';
add_event($event2); $event->timestart = $quiz->timeclose;
$event->eventtype = 'close';
$event->name = $quiz->name.' ('.get_string('quizcloses', 'quiz').')';
unset($event->id);
add_event($event);
} else { // single event with duration
$event->name = $quiz->name;
add_event($event);
}
} elseif ($quiz->timeopen) { // only an open date
$event->name = $quiz->name.' ('.get_string('quizopens', 'quiz').')';
$event->eventtype = 'open';
$event->timeduration = 0;
add_event($event);
} elseif ($quiz->timeclose) { // only a closing date
$event->name = $quiz->name.' ('.get_string('quizcloses', 'quiz').')';
$event->timestart = $quiz->timeclose;
$event->eventtype = 'close';
$event->timeduration = 0;
} }
add_event($event);
return $quiz->id; return $quiz->id;
} }
@ -91,12 +116,23 @@ function quiz_update_instance($quiz) {
quiz_process_options($quiz); quiz_process_options($quiz);
$quiz->timemodified = time(); $quiz->timemodified = time();
if (isset($quiz->openyear)) { // this would not be set if we come from edit.php // The following is adapted from the assignment module
$quiz->timeopen = make_timestamp($quiz->openyear, $quiz->openmonth, $quiz->openday, if (empty($quiz->dueenable)) {
$quiz->openhour, $quiz->openminute, 0); $quiz->timeclose = 0;
$quiz->timeclose = make_timestamp($quiz->closeyear, $quiz->closemonth, $quiz->closeday, } else {
$quiz->closehour, $quiz->closeminute, 0); $quiz->timeclose = make_timestamp($quiz->dueyear, $quiz->duemonth,
$quiz->dueday, $quiz->duehour,
$quiz->dueminute);
} }
if (empty($quiz->availableenable)) {
$quiz->timeopen = 0;
$quiz->preventlate = 0;
} else {
$quiz->timeopen = make_timestamp($quiz->availableyear, $quiz->availablemonth,
$quiz->availableday, $quiz->availablehour,
$quiz->availableminute);
}
$quiz->id = $quiz->instance; $quiz->id = $quiz->instance;
if (!update_record("quiz", $quiz)) { if (!update_record("quiz", $quiz)) {
@ -125,25 +161,38 @@ function quiz_update_instance($quiz) {
$event->userid = 0; $event->userid = 0;
$event->modulename = 'quiz'; $event->modulename = 'quiz';
$event->instance = $quiz->id; $event->instance = $quiz->id;
$event->eventtype = 'open';
$event->timestart = $quiz->timeopen; $event->timestart = $quiz->timeopen;
$event->visible = instance_is_visible('quiz', $quiz); $event->visible = instance_is_visible('quiz', $quiz);
$event->timeduration = ($quiz->timeclose - $quiz->timeopen); if ($quiz->timeclose and $quiz->timeopen) {
// we have both a start and an end date
$event->eventtype = 'open';
$event->timeduration = ($quiz->timeclose - $quiz->timeopen);
if ($event->timeduration > QUIZ_MAX_EVENT_LENGTH) { /// Long durations create two events if ($event->timeduration > QUIZ_MAX_EVENT_LENGTH) { /// Long durations create two events
$event->name = $quiz->name.' ('.get_string('quizopens', 'quiz').')';
$event->timeduration = 0;
add_event($event);
$event->timestart = $quiz->timeclose;
$event->eventtype = 'close';
$event->name = $quiz->name.' ('.get_string('quizcloses', 'quiz').')';
unset($event->id);
add_event($event);
} else { // single event with duration
$event->name = $quiz->name;
add_event($event);
}
} elseif ($quiz->timeopen) { // only an open date
$event->name = $quiz->name.' ('.get_string('quizopens', 'quiz').')'; $event->name = $quiz->name.' ('.get_string('quizopens', 'quiz').')';
$event->timeduration = 0; $event->eventtype = 'open';
$event->timeduration = 0;
add_event($event); add_event($event);
} elseif ($quiz->timeclose) { // only a closing date
$event->name = $quiz->name.' ('.get_string('quizcloses', 'quiz').')';
$event->timestart = $quiz->timeclose; $event->timestart = $quiz->timeclose;
$event->eventtype = 'close'; $event->eventtype = 'close';
$event->name = $quiz->name.' ('.get_string('quizcloses', 'quiz').')'; $event->timeduration = 0;
unset($event->id);
add_event($event);
} else { // single event with duration
$event->name = $quiz->name;
add_event($event);
} }
return true; return true;

View file

@ -394,6 +394,30 @@ function quiz_calculate_best_attempt($quiz, $attempts) {
/// OTHER QUIZ FUNCTIONS //////////////////////////////////////////////////// /// OTHER QUIZ FUNCTIONS ////////////////////////////////////////////////////
/**
* Print a box with quiz start and due dates
*
* @param object $quiz
*/
function quiz_view_dates($quiz) {
if (!$quiz->timeopen && !$quiz->timeclose) {
return;
}
print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
echo '<table>';
if ($quiz->timeopen) {
echo '<tr><td class="c0">'.get_string('availabledate','assignment').':</td>';
echo ' <td class="c1">'.userdate($quiz->timeopen).'</td></tr>';
}
if ($quiz->timeclose) {
echo '<tr><td class="c0">'.get_string('duedate','assignment').':</td>';
echo ' <td class="c1">'.userdate($quiz->timeclose).'</td></tr>';
}
echo '</table>';
print_simple_box_end();
}
/** /**
* Array of names of quizzes a question appears in * Array of names of quizzes a question appears in
* *

View file

@ -64,6 +64,9 @@
if (!isset($form->penaltyscheme)) { if (!isset($form->penaltyscheme)) {
$form->penaltyscheme = $CFG->quiz_penaltyscheme; $form->penaltyscheme = $CFG->quiz_penaltyscheme;
} }
if (empty($form->timedue)) {
$form->timedue = "";
}
$fix = 0; // This will later be set to 1 if some of the variables have been fixed by the admin. $fix = 0; // This will later be set to 1 if some of the variables have been fixed by the admin.
@ -81,7 +84,10 @@
} }
?> ?>
<script type="text/javascript" language="javascript">
var dueitems = ['dueday','duemonth','dueyear','duehour', 'dueminute'];
var availableitems = ['availableday','availablemonth','availableyear','availablehour', 'availableminute'];
</script>
<form name="form" method="post" action="mod.php"> <form name="form" method="post" action="mod.php">
@ -117,31 +123,38 @@
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign=top>
<td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td> <td align="right"><b><?php print_string("availabledate","assignment") ?>:</b></td>
<td align="left"> <td align="left">
<input name="availableenable" type="checkbox" value="1" alt="<?php print_string('availabledate', 'assignment') ?>" onclick="return lockoptions('form', 'availableenable', availableitems)" <?php if ($form->timeopen) echo 'checked="checked"' ?> />
<?php <?php
if (!$form->timeopen and $course->format == "weeks") { print_date_selector("availableday", "availablemonth", "availableyear", $form->timeopen);
$form->timeopen = $course->startdate + (($form->section - 1) * 608400); echo "&nbsp;-&nbsp;";
} print_time_selector("availablehour", "availableminute", $form->timeopen);
print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
print_time_selector("openhour", "openminute", $form->timeopen);
helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
?> ?>
<input type="hidden" name="havailableday" value="0" />
<input type="hidden" name="havailablemonth" value="0" />
<input type="hidden" name="havailableyear" value="0" />
<input type="hidden" name="havailablehour" value="0" />
<input type="hidden" name="havailableminute" value="0" />
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign=top>
<td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td> <td align="right"><b><?php print_string("duedate", "assignment") ?>:</b></td>
<td align="left"> <td align="left">
<input name="dueenable" type="checkbox" value="1" alt="<?php print_string('duedate', 'assignment') ?>" onclick="return lockoptions('form', 'dueenable', dueitems)" <?php if ($form->timeclose) echo 'checked="checked"' ?> />
<?php <?php
if (!$form->timeclose and $course->format == "weeks") { print_date_selector("dueday", "duemonth", "dueyear", $form->timeclose);
$form->timeclose = $course->startdate + (($form->section) * 608400); echo "&nbsp;-&nbsp;";
} print_time_selector("duehour", "dueminute", $form->timeclose);
print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose); helpbutton("timeopen", get_string("timeclose","quiz"), "quiz");
print_time_selector("closehour", "closeminute", $form->timeclose);
helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
?> ?>
<input type="hidden" name="hdueday" value="0" />
<input type="hidden" name="hduemonth" value="0" />
<input type="hidden" name="hdueyear" value="0" />
<input type="hidden" name="hduehour" value="0" />
<input type="hidden" name="hdueminute" value="0" />
</td> </td>
</tr> </tr>
@ -575,4 +588,9 @@
</center> </center>
</form> </form>
<script type="text/javascript">
<?php
if (!$form->timeclose) echo "lockoptions('form','dueenable', dueitems);";
if (!$form->timeopen) echo "lockoptions('form','availableenable', availableitems);";
?>
</script

View file

@ -197,7 +197,7 @@ function quiz_get_states(&$questions, $cmoptions, $attempt) {
" AND n.questionid IN ($questionlist)"; " AND n.questionid IN ($questionlist)";
$gradedstates = get_records_sql($sql); $gradedstates = get_records_sql($sql);
// loop through all questions, restore the states, and set the last_graded states // loop through all questions and set the last_graded states
foreach ($ids as $i) { foreach ($ids as $i) {
if (isset($states[$i])) { if (isset($states[$i])) {
quiz_restore_state($questions[$i], $states[$i]); quiz_restore_state($questions[$i], $states[$i]);
@ -205,14 +205,15 @@ function quiz_get_states(&$questions, $cmoptions, $attempt) {
quiz_restore_state($questions[$i], $gradedstates[$i]); quiz_restore_state($questions[$i], $gradedstates[$i]);
$states[$i]->last_graded = $gradedstates[$i]; $states[$i]->last_graded = $gradedstates[$i];
} else { } else {
error('No graded state could be found!'); $states[$i]->last_graded = clone($states[$i]);
$states[$i]->last_graded->responses = array('' => '');
} }
} else { } else {
// Create a new state object // Create a new state object
if ($cmoptions->attemptonlast and $attempt->attempt > 1) { if ($quiz->attemptonlast and $attempt->attempt > 1 and !$attempt->preview) {
// build on states from last attempt // build on states from last attempt
if (empty($lastattemptid)) { if (!$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1)) {
$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1); error('Could not find previous attempt to build on');
} }
// Load the last graded state for the question // Load the last graded state for the question
$sql = "SELECT $statefields". $sql = "SELECT $statefields".
@ -221,7 +222,9 @@ function quiz_get_states(&$questions, $cmoptions, $attempt) {
" WHERE s.id = n.newgraded". " WHERE s.id = n.newgraded".
" AND n.attemptid = '$lastattemptid'". " AND n.attemptid = '$lastattemptid'".
" AND n.questionid = '$i'"; " AND n.questionid = '$i'";
$states[$i] = get_record_sql($sql); if (!$states[$i] = get_record_sql($sql)) {
error('Could not find state for previous attempt to build on');
}
quiz_restore_state($questions[$i], $states[$i]); quiz_restore_state($questions[$i], $states[$i]);
$states[$i]->attempt = $attempt->uniqueid; $states[$i]->attempt = $attempt->uniqueid;
$states[$i]->question = (int) $i; $states[$i]->question = (int) $i;
@ -232,16 +235,8 @@ function quiz_get_states(&$questions, $cmoptions, $attempt) {
$states[$i]->raw_grade = ''; $states[$i]->raw_grade = '';
$states[$i]->penalty = ''; $states[$i]->penalty = '';
$states[$i]->sumpenalty = '0.0'; $states[$i]->sumpenalty = '0.0';
$states[$i]->last_graded = new object; $states[$i]->changed = true;
$states[$i]->last_graded->attempt = $attempt->uniqueid; $states[$i]->last_graded = clone($states[$i]);
$states[$i]->last_graded->question = (int) $i;
$states[$i]->last_graded->seq_number = 0;
$states[$i]->last_graded->timestamp = $attempt->timestart;
$states[$i]->last_graded->event = ($attempt->timefinish) ? QUIZ_EVENTCLOSE : QUIZ_EVENTOPEN;
$states[$i]->last_graded->grade = '';
$states[$i]->last_graded->raw_grade = '';
$states[$i]->last_graded->penalty = '';
$states[$i]->last_graded->sumpenalty = '0.0';
$states[$i]->last_graded->responses = array('' => ''); $states[$i]->last_graded->responses = array('' => '');
} else { } else {
@ -278,8 +273,7 @@ function quiz_get_states(&$questions, $cmoptions, $attempt) {
* Creates the run-time fields for the states * Creates the run-time fields for the states
* *
* Extends the state objects for a question by calling * Extends the state objects for a question by calling
* {@link restore_session_and_responses()} or it creates a new one by * {@link restore_session_and_responses()}
* calling {@link create_session_and_responses()}
* @return boolean Represents success or failure * @return boolean Represents success or failure
* @param object $question The question for which the state is needed * @param object $question The question for which the state is needed
* @param object $state The state as loaded from the database * @param object $state The state as loaded from the database
@ -343,7 +337,6 @@ function quiz_save_question_session(&$question, &$state) {
$new->attemptid = $state->attempt; $new->attemptid = $state->attempt;
$new->questionid = $question->id; $new->questionid = $question->id;
$new->newest = $state->id; $new->newest = $state->id;
$new->newgraded = $state->id;
$new->sumpenalty = $state->sumpenalty; $new->sumpenalty = $state->sumpenalty;
if (!insert_record('quiz_newest_states', $new)) { if (!insert_record('quiz_newest_states', $new)) {
error('Could not insert entry in quiz_newest_states'); error('Could not insert entry in quiz_newest_states');
@ -745,7 +738,7 @@ function quiz_apply_penalty_and_timelimit(&$question, &$state, $attempt, $cmopti
} }
// deal with closing time // deal with closing time
if ($state->timestamp > ($cmoptions->timeclose + 60)) { // allowing 1 minute lateness if ($cmoptions->timeclose and $state->timestamp > ($cmoptions->timeclose + 60)) { // allowing 1 minute lateness
$state->grade = 0; $state->grade = 0;
} }
@ -902,7 +895,7 @@ function quiz_get_reviewoptions($cmoptions, $attempt, $isteacher=false) {
$options->feedback = ($cmoptions->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK) ? 1 : 0; $options->feedback = ($cmoptions->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_FEEDBACK) ? 1 : 0;
$options->correct_responses = ($cmoptions->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS) ? 1 : 0; $options->correct_responses = ($cmoptions->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_ANSWERS) ? 1 : 0;
$options->solutions = ($cmoptions->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_SOLUTIONS) ? 1 : 0; $options->solutions = ($cmoptions->review & QUIZ_REVIEW_IMMEDIATELY & QUIZ_REVIEW_SOLUTIONS) ? 1 : 0;
} else if (time() < $cmoptions->timeclose) { } else if (!$cmoptions->timeclose or time() < $cmoptions->timeclose) {
$options->responses = ($cmoptions->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_RESPONSES) ? 1 : 0; $options->responses = ($cmoptions->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_RESPONSES) ? 1 : 0;
$options->scores = ($cmoptions->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_SCORES) ? 1 : 0; $options->scores = ($cmoptions->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_SCORES) ? 1 : 0;
$options->feedback = ($cmoptions->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_FEEDBACK) ? 1 : 0; $options->feedback = ($cmoptions->review & QUIZ_REVIEW_OPEN & QUIZ_REVIEW_FEEDBACK) ? 1 : 0;

View file

@ -50,10 +50,10 @@
redirect('view.php?q='.$quiz->id); redirect('view.php?q='.$quiz->id);
} }
if ((time() - $attempt->timefinish) > 120) { // always allow review right after attempt if ((time() - $attempt->timefinish) > 120) { // always allow review right after attempt
if (time() < $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_OPEN)) { if ((!$quiz->timeclose or time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN)) {
redirect('view.php?q='.$quiz->id, get_string("noreviewuntil", "quiz", userdate($quiz->timeclose))); redirect('view.php?q='.$quiz->id, get_string("noreviewuntil", "quiz", userdate($quiz->timeclose)));
} }
if (time() >= $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_CLOSED)) { if ($quiz->timeclose and time() >= $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_CLOSED)) {
redirect('view.php?q='.$quiz->id, get_string("noreview", "quiz")); redirect('view.php?q='.$quiz->id, get_string("noreview", "quiz"));
} }
} }

View file

@ -70,10 +70,10 @@
error(get_string("noreview", "quiz")); error(get_string("noreview", "quiz"));
} }
if ((time() - $attempt->timefinish) > 120) { // always allow review right after attempt if ((time() - $attempt->timefinish) > 120) { // always allow review right after attempt
if (time() < $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_OPEN)) { if (!$quiz->timeclose or time() < $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_OPEN)) {
error(get_string("noreviewuntil", "quiz", userdate($quiz->timeclose))); error(get_string("noreviewuntil", "quiz", userdate($quiz->timeclose)));
} }
if (time() >= $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_CLOSED)) { if ($quiz->timeclose and time() >= $quiz->timeclose and !($quiz->review & QUIZ_REVIEW_CLOSED)) {
error(get_string("noreview", "quiz")); error(get_string("noreview", "quiz"));
} }
} }

View file

@ -77,7 +77,7 @@
echo '<td id="middle-column">'; echo '<td id="middle-column">';
$available = ($quiz->timeopen < $timenow and $timenow < $quiz->timeclose) || $isteacher; $available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose)) || $isteacher;
// Print the main part of the page // Print the main part of the page
@ -102,7 +102,7 @@
if ($quiz->timelimit) { if ($quiz->timelimit) {
echo "<p align=\"center\">".get_string("quiztimelimit","quiz", format_time($quiz->timelimit * 60))."</p>"; echo "<p align=\"center\">".get_string("quiztimelimit","quiz", format_time($quiz->timelimit * 60))."</p>";
} }
echo "<p align=\"center\">".get_string("quizavailable", "quiz", userdate($quiz->timeclose)); quiz_view_dates($quiz);
} else if ($timenow < $quiz->timeopen) { } else if ($timenow < $quiz->timeopen) {
echo "<p align=\"center\">".get_string("quiznotavailable", "quiz", userdate($quiz->timeopen)); echo "<p align=\"center\">".get_string("quiznotavailable", "quiz", userdate($quiz->timeopen));
} else { } else {
@ -222,7 +222,7 @@
$datecompleted .= '</noscript>'; $datecompleted .= '</noscript>';
} else { // attempt was not completed but is also not available any more. } else { // attempt was not completed but is also not available any more.
$timetaken = format_time($quiz->timeclose - $attempt->timestart); $timetaken = format_time($quiz->timeclose - $attempt->timestart);
$datecompleted = userdate($quiz->timeclose); $datecompleted = $quiz->timeclose ? userdate($quiz->timeclose) : '';
} }
/// prepare strings for attempt number, mark and grade /// prepare strings for attempt number, mark and grade
@ -313,10 +313,10 @@
if (!($quiz->review & QUIZ_REVIEW_RESPONSES)) { if (!($quiz->review & QUIZ_REVIEW_RESPONSES)) {
return false; return false;
} }
if ((time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN)) { if ((!$quiz->timeclose or time() < $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_OPEN)) {
return false; return false;
} }
if ((time() > $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_CLOSED)) { if (($quiz->timeclose and time() > $quiz->timeclose) and !($quiz->review & QUIZ_REVIEW_CLOSED)) {
return false; return false;
} }
return true; return true;