/// Print infobox $rows = array(); /// User picture and name. if ($attemptobj->get_userid() != $USER->id) { // Print user picture and name $student = $DB->get_record('user', array('id' => $attemptobj->get_userid())); $picture = print_user_picture($student, $attemptobj->get_courseid(), $student->picture, false, true); $rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $student->id . '&course=' . $attemptobj->get_courseid() . '">' . fullname($student, true) . '</a></td></tr>'; } /// Quiz name. $rows[] = '<tr><th scope="row" class="cell">' . get_string('modulename', 'quiz') . '</th><td class="cell">' . format_string($attemptobj->get_quiz_name()) . '</td></tr>'; /// Question name. $rows[] = '<tr><th scope="row" class="cell">' . get_string('question', 'quiz') . '</th><td class="cell">' . format_string($attemptobj->get_question($questionid)->name) . '</td></tr>'; /// Other attempts at the quiz. if ($attemptobj->has_capability('mod/quiz:viewreports')) { $attemptlist = $attemptobj->links_to_other_attempts($baseurl); if ($attemptlist) { $rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') . '</th><td class="cell">' . $attemptlist . '</td></tr>'; } } /// Timestamp of this action. $timestamp = $attemptobj->get_question_state($questionid)->timestamp; if ($timestamp) { $rows[] = '<tr><th scope="row" class="cell">' . get_string('completedon', 'quiz') . '</th><td class="cell">' . userdate($timestamp) . '</td></tr>'; } /// Now output the summary table, if there are any rows to be shown. if (!empty($rows)) { echo '<table class="generaltable generalbox quizreviewsummary"><tbody>', "\n"; echo implode("\n", $rows); echo "\n</tbody></table>\n"; }
} } else { $timetaken = get_string('unfinished', 'quiz'); } /// Print summary table about the whole attempt. /// First we assemble all the rows that are appopriate to the current situation in /// an array, then later we only output the table if there are any rows to show. $rows = array(); if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() != $USER->id) { /// If showuserpicture is true, the picture is shown elsewhere, so don't repeat it. $student = $DB->get_record('user', array('id' => $attemptobj->get_userid())); $picture = $OUTPUT->user_picture(moodle_user_picture::make($student, $attemptobj->get_courseid())); $rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $student->id . '&course=' . $attemptobj->get_courseid() . '">' . fullname($student, true) . '</a></td></tr>'; } if ($attemptobj->has_capability('mod/quiz:viewreports')) { $attemptlist = $attemptobj->links_to_other_attempts($attemptobj->review_url(0, $page, $showall)); if ($attemptlist) { $rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') . '</th><td class="cell">' . $attemptlist . '</td></tr>'; } } /// Timing information. $rows[] = '<tr><th scope="row" class="cell">' . get_string('startedon', 'quiz') . '</th><td class="cell">' . userdate($attempt->timestart) . '</td></tr>'; if ($attempt->timefinish) { $rows[] = '<tr><th scope="row" class="cell">' . get_string('completedon', 'quiz') . '</th><td class="cell">' . userdate($attempt->timefinish) . '</td></tr>'; $rows[] = '<tr><th scope="row" class="cell">' . get_string('timetaken', 'quiz') . '</th><td class="cell">' . $timetaken . '</td></tr>'; } if (!empty($overtime)) { $rows[] = '<tr><th scope="row" class="cell">' . get_string('overdue', 'quiz') . '</th><td class="cell">' . $overtime . '</td></tr>'; } /// Show scores (if the user is allowed to see scores at the moment). $grade = quiz_rescale_grade($attempt->sumgrades, $quiz);