MDL-3030 quiz overdue handling: show attempt state on the review page.
This commit is contained in:
@@ -492,6 +492,23 @@ class quiz_attempt {
|
||||
return self::create_helper(array('uniqueid' => $usageid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state one of the state constants like IN_PROGRESS.
|
||||
* @return string the human-readable state name.
|
||||
*/
|
||||
public static function state_name($state) {
|
||||
switch ($state) {
|
||||
case quiz_attempt::IN_PROGRESS:
|
||||
return get_string('stateinprogress', 'quiz');
|
||||
case quiz_attempt::OVERDUE:
|
||||
return get_string('stateoverdue', 'quiz');
|
||||
case quiz_attempt::FINISHED:
|
||||
return get_string('statefinished', 'quiz');
|
||||
case quiz_attempt::ABANDONED:
|
||||
return get_string('stateabandoned', 'quiz');
|
||||
}
|
||||
}
|
||||
|
||||
private function determine_layout() {
|
||||
$this->pagelayout = array();
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
* @param int $page the current page number
|
||||
* @return $summarydata containing filtered row data
|
||||
*/
|
||||
protected function filter_summary_table($summarydata, $page) {
|
||||
protected function filter_review_summary_table($summarydata, $page) {
|
||||
if ($page == 0) {
|
||||
return $summarydata;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
* @param int $page contains the current page number
|
||||
*/
|
||||
public function review_summary_table($summarydata, $page) {
|
||||
$summarydata = $this->filter_summary_table($summarydata, $page);
|
||||
$summarydata = $this->filter_review_summary_table($summarydata, $page);
|
||||
if (empty($summarydata)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
+8
-2
@@ -112,7 +112,7 @@ $attempt = $attemptobj->get_attempt();
|
||||
$quiz = $attemptobj->get_quiz();
|
||||
$overtime = 0;
|
||||
|
||||
if ($attempt->timefinish) {
|
||||
if ($attempt->state == quiz_attempt::FINISHED) {
|
||||
if ($timetaken = ($attempt->timefinish - $attempt->timestart)) {
|
||||
if ($quiz->timelimit && $timetaken > ($quiz->timelimit + 60)) {
|
||||
$overtime = $timetaken - $quiz->timelimit;
|
||||
@@ -140,6 +140,7 @@ if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() != $U
|
||||
fullname($student, true)),
|
||||
);
|
||||
}
|
||||
|
||||
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
|
||||
$attemptlist = $attemptobj->links_to_other_attempts($attemptobj->review_url(null, $page,
|
||||
$showall));
|
||||
@@ -157,7 +158,12 @@ $summarydata['startedon'] = array(
|
||||
'content' => userdate($attempt->timestart),
|
||||
);
|
||||
|
||||
if ($attempt->timefinish) {
|
||||
$summarydata['state'] = array(
|
||||
'title' => get_string('attemptstate', 'quiz'),
|
||||
'content' => quiz_attempt::state_name($attempt->state),
|
||||
);
|
||||
|
||||
if ($attempt->state == quiz_attempt::FINISHED) {
|
||||
$summarydata['completedon'] = array(
|
||||
'title' => get_string('completedon', 'quiz'),
|
||||
'content' => userdate($attempt->timefinish),
|
||||
|
||||
Reference in New Issue
Block a user