/** * Create the summary page * * @param quiz_attempt $attemptobj * @param mod_quiz_display_options $displayoptions */ public function summary_page($attemptobj, $displayoptions) { $output = ''; $output .= $this->header(); $output .= $this->heading(format_string($attemptobj->get_quiz_name())); $output .= $this->heading(get_string('summaryofattempt', 'quiz'), 3); $output .= $this->summary_table($attemptobj, $displayoptions); $output .= $this->summary_page_controls($attemptobj); $output .= $this->footer(); return $output; }
$accessmanager = $attemptobj->get_access_manager(time()); $messages = $accessmanager->prevent_access(); if (!$attemptobj->is_preview_user() && $messages) { print_error('attempterror', 'quiz', $attemptobj->view_url(), $accessmanager->print_messages($messages, true)); } $accessmanager->do_password_check($attemptobj->is_preview_user()); /// Log this page view. add_to_log($attemptobj->get_courseid(), 'quiz', 'view summary', 'summary.php?attempt=' . $attemptobj->get_attemptid(), $attemptobj->get_quizid(), $attemptobj->get_cmid()); /// Load the questions and states. $attemptobj->load_questions(); $attemptobj->load_question_states(); /// Print the page header require_js('mod/quiz/quiz.js'); $title = get_string('summaryofattempt', 'quiz'); if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . format_string($attemptobj->get_quiz_name()), ''); } else { print_header_simple(format_string($attemptobj->get_quiz_name()), '', $attemptobj->navigation($title), '', '', true, $attemptobj->update_module_button()); } /// Print tabs if they should be there. if ($attemptobj->is_preview_user()) { $currenttab = 'preview'; include 'tabs.php'; } /// Print heading. print_heading(format_string($attemptobj->get_quiz_name())); if ($attemptobj->is_preview_user()) { $attemptobj->print_restart_preview_button(); } print_heading($title); /// Prepare the summary table header
/// Print the page header $headtags = $attemptobj->get_question_html_head_contributions($questionid); print_header('', '', '', '', $headtags); echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib /// 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.
/** * Send the notification message when a quiz attempt becomes overdue. * * @param quiz_attempt $attemptobj all the data about the quiz attempt. */ function quiz_send_overdue_message($attemptobj) { global $CFG, $DB; $submitter = $DB->get_record('user', array('id' => $attemptobj->get_userid()), '*', MUST_EXIST); if (!$attemptobj->has_capability('mod/quiz:emailwarnoverdue', $submitter->id, false)) { return; // Message not required. } if (!$attemptobj->has_response_to_at_least_one_graded_question()) { return; // Message not required. } // Prepare lots of useful information that admins might want to include in // the email message. $quizname = format_string($attemptobj->get_quiz_name()); $deadlines = array(); if ($attemptobj->get_quiz()->timelimit) { $deadlines[] = $attemptobj->get_attempt()->timestart + $attemptobj->get_quiz()->timelimit; } if ($attemptobj->get_quiz()->timeclose) { $deadlines[] = $attemptobj->get_quiz()->timeclose; } $duedate = min($deadlines); $graceend = $duedate + $attemptobj->get_quiz()->graceperiod; $a = new stdClass(); // Course info. $a->coursename = format_string($attemptobj->get_course()->fullname); $a->courseshortname = format_string($attemptobj->get_course()->shortname); // Quiz info. $a->quizname = $quizname; $a->quizurl = $attemptobj->view_url(); $a->quizlink = '<a href="' . $a->quizurl . '">' . $quizname . '</a>'; // Attempt info. $a->attemptduedate = userdate($duedate); $a->attemptgraceend = userdate($graceend); $a->attemptsummaryurl = $attemptobj->summary_url()->out(false); $a->attemptsummarylink = '<a href="' . $a->attemptsummaryurl . '">' . $quizname . ' review</a>'; // Student's info. $a->studentidnumber = $submitter->idnumber; $a->studentname = fullname($submitter); $a->studentusername = $submitter->username; // Prepare the message. $eventdata = new stdClass(); $eventdata->component = 'mod_quiz'; $eventdata->name = 'attempt_overdue'; $eventdata->notification = 1; $eventdata->userfrom = core_user::get_noreply_user(); $eventdata->userto = $submitter; $eventdata->subject = get_string('emailoverduesubject', 'quiz', $a); $eventdata->fullmessage = get_string('emailoverduebody', 'quiz', $a); $eventdata->fullmessageformat = FORMAT_PLAIN; $eventdata->fullmessagehtml = ''; $eventdata->smallmessage = get_string('emailoverduesmall', 'quiz', $a); $eventdata->contexturl = $a->quizurl; $eventdata->contexturlname = $a->quizname; // Send the message. return message_send($eventdata); }
if ($userRole->roleid == 1 || $userRole->roleid == 2 || $userRole->roleid == 3) { $admin = true; } else { /// Check that this attempt belongs to this user. if ($attemptobj->get_userid() != $USER->id) { redirect("{$CFG->wwwroot}/index.php"); } } } require_js(array('yui_yahoo', 'yui_event')); require_js('mod/quiz/quiz.js'); //$title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number()); $userinfo = $DB->get_record('quiz_course_activation', array('attemptid' => $attemptid)); $course = $DB->get_record('course', array('id' => $attemptobj->get_courseid())); // Build Navigation $navlinks[] = array('name' => $attemptobj->get_quiz_name(), 'link' => null, 'type' => 'misc'); $navlinks[] = array('name' => $userinfo->username, 'link' => null, 'type' => 'misc'); //$navlinks[] = array('name' => $title, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($SITE->fullname, $SITE->fullname, $navigation); ?> <style type="text/css"> table.grades { width: 650px; border-collapse:collapse; border:1px solid #FFCA5E; } .grades caption {