2004-09-12 17:34:35 +00:00
|
|
|
<?php // $Id$
|
2002-10-04 02:59:05 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// This page prints a particular instance of quiz
|
2002-10-04 02:59:05 +00:00
|
|
|
|
2008-07-08 17:46:59 +00:00
|
|
|
require_once(dirname(__FILE__) . '/../../config.php');
|
2005-02-10 01:59:11 +00:00
|
|
|
require_once($CFG->libdir.'/blocklib.php');
|
2007-10-11 11:42:49 +00:00
|
|
|
require_once($CFG->libdir.'/gradelib.php');
|
|
|
|
require_once($CFG->dirroot.'/mod/quiz/locallib.php');
|
|
|
|
require_once($CFG->dirroot.'/mod/quiz/pagelib.php');
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
|
|
|
|
$q = optional_param('q', 0, PARAM_INT); // quiz ID
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2002-10-04 02:59:05 +00:00
|
|
|
if ($id) {
|
2006-08-08 22:09:55 +00:00
|
|
|
if (! $cm = get_coursemodule_from_id('quiz', $id)) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2002-10-04 02:59:05 +00:00
|
|
|
}
|
2008-06-09 10:00:35 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('coursemisconf');
|
2002-10-04 02:59:05 +00:00
|
|
|
}
|
2008-06-09 10:00:35 +00:00
|
|
|
if (! $quiz = $DB->get_record('quiz', array('id' => $cm->instance))) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2002-10-04 02:59:05 +00:00
|
|
|
}
|
|
|
|
} else {
|
2008-06-09 10:00:35 +00:00
|
|
|
if (! $quiz = $DB->get_record('quiz', array('id' => $q))) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('invalidquizid', 'quiz');
|
2002-10-04 02:59:05 +00:00
|
|
|
}
|
2008-06-09 10:00:35 +00:00
|
|
|
if (! $course = $DB->get_record('course', array('id' => $quiz->course))) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('invalidcourseid');
|
2002-10-04 02:59:05 +00:00
|
|
|
}
|
|
|
|
if (! $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id)) {
|
2008-06-10 06:27:38 +00:00
|
|
|
print_error('invalidcoursemodule');
|
2002-10-04 02:59:05 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-22 13:53:39 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Check login and get context.
|
2005-02-16 10:40:48 +00:00
|
|
|
require_login($course->id, false, $cm);
|
2006-08-25 16:03:54 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2008-03-07 12:33:07 +00:00
|
|
|
require_capability('mod/quiz:view', $context);
|
|
|
|
|
|
|
|
/// Cache some other capabilites we use several times.
|
|
|
|
$canattempt = has_capability('mod/quiz:attempt', $context);
|
|
|
|
$canpreview = has_capability('mod/quiz:preview', $context);
|
2005-05-06 06:24:04 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Create an object to manage all the other (non-roles) access rules.
|
|
|
|
$timenow = time();
|
2008-07-08 16:33:47 +00:00
|
|
|
$accessmanager = new quiz_access_manager(new quiz($quiz, $cm, $course), $timenow,
|
2008-03-07 12:33:07 +00:00
|
|
|
has_capability('mod/quiz:ignoretimelimits', $context, NULL, false));
|
|
|
|
|
|
|
|
/// If no questions have been set up yet redirect to edit.php
|
|
|
|
if (!$quiz->questions && has_capability('mod/quiz:manage', $context)) {
|
2008-04-22 15:19:50 +00:00
|
|
|
redirect($CFG->wwwroot . '/mod/quiz/edit.php?cmid=' . $cm->id);
|
2005-01-02 07:15:19 +00:00
|
|
|
}
|
2002-10-04 02:59:05 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Log this request.
|
2004-01-31 15:22:04 +00:00
|
|
|
add_to_log($course->id, "quiz", "view", "view.php?id=$cm->id", $quiz->id, $cm->id);
|
2002-10-04 02:59:05 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Initialize $PAGE, compute blocks
|
2005-03-02 05:19:47 +00:00
|
|
|
$PAGE = page_create_instance($quiz->id);
|
|
|
|
$pageblocks = blocks_setup($PAGE);
|
2005-02-02 02:46:06 +00:00
|
|
|
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
|
2002-10-06 03:23:34 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
$edit = optional_param('edit', -1, PARAM_BOOL);
|
|
|
|
if ($edit != -1 && $PAGE->user_allowed_editing()) {
|
2006-04-23 20:58:06 +00:00
|
|
|
$USER->editing = $edit;
|
2005-02-01 07:16:19 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Print the page header
|
|
|
|
$bodytags = '';
|
|
|
|
if ($accessmanager->securewindow_required($canpreview)) {
|
|
|
|
$bodytags = 'onload="popupchecker(\'' . get_string('popupblockerwarning', 'quiz') . '\');"';
|
|
|
|
}
|
|
|
|
require_js('yui_yahoo');
|
|
|
|
require_js('yui_event');
|
2005-11-09 02:16:13 +00:00
|
|
|
$PAGE->print_header($course->shortname.': %fullname%','',$bodytags);
|
2002-10-13 13:51:56 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Print any blocks on the left of the page.
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<table id="layout-table"><tr>';
|
2005-03-16 03:26:21 +00:00
|
|
|
if(!empty($CFG->showblocksonmodpages) && (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2005-03-02 05:47:39 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_end();
|
2008-03-07 12:33:07 +00:00
|
|
|
echo "</td>\n";
|
2005-02-01 07:16:19 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Start the main part of the page
|
2005-02-12 11:37:09 +00:00
|
|
|
echo '<td id="middle-column">';
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2005-02-01 07:16:19 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Print heading and tabs (if there is more than one).
|
2006-08-25 16:03:54 +00:00
|
|
|
$currenttab = 'info';
|
|
|
|
include('tabs.php');
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Print quiz name and description
|
2005-04-03 00:19:11 +00:00
|
|
|
print_heading(format_string($quiz->name));
|
2008-03-07 12:33:07 +00:00
|
|
|
if (trim(strip_tags($quiz->intro))) {
|
|
|
|
$formatoptions->noclean = true;
|
|
|
|
print_box(format_text($quiz->intro, FORMAT_MOODLE, $formatoptions), 'generalbox', 'intro');
|
|
|
|
}
|
2002-10-06 03:23:34 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Display information about this quiz.
|
|
|
|
$messages = $accessmanager->describe_rules();
|
|
|
|
if ($quiz->attempts != 1) {
|
|
|
|
$messages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod));
|
2004-08-23 12:35:13 +00:00
|
|
|
}
|
2008-03-07 12:33:07 +00:00
|
|
|
print_box_start('quizinfo');
|
|
|
|
$accessmanager->print_messages($messages);
|
|
|
|
print_box_end();
|
2002-10-06 03:23:34 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Show number of attempts summary to those who can view reports.
|
2006-08-25 16:03:54 +00:00
|
|
|
if (has_capability('mod/quiz:viewreports', $context)) {
|
2007-12-12 17:23:55 +00:00
|
|
|
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm)) {
|
|
|
|
echo '<div class="quizattemptcounts"><a href="report.php?mode=overview&id=' .
|
2008-03-07 12:33:07 +00:00
|
|
|
$cm->id . '">' . $strattemptnum . "</a></div>\n";
|
2005-06-05 20:51:15 +00:00
|
|
|
}
|
2005-05-06 06:24:04 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Guests can't do a quiz, so offer them a choice of logging in or going back.
|
2007-02-28 11:34:50 +00:00
|
|
|
if (isguestuser()) {
|
2006-08-22 17:31:26 +00:00
|
|
|
$loginurl = $CFG->wwwroot.'/login/index.php';
|
2006-08-22 13:53:39 +00:00
|
|
|
if (!empty($CFG->loginhttps)) {
|
2006-08-22 17:31:26 +00:00
|
|
|
$loginurl = str_replace('http:','https:', $loginurl);
|
2006-08-22 13:53:39 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
notice_yesno('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" .
|
|
|
|
get_string('liketologin') . "</p>\n", $loginurl, get_referer(false));
|
2007-09-20 15:14:24 +00:00
|
|
|
finish_page($course);
|
2006-08-22 13:53:39 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// If they are not using guest access, and they can't do the quiz, tell them that.
|
|
|
|
if (!($canattempt || $canpreview)) {
|
|
|
|
print_box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" .
|
2007-09-20 15:14:24 +00:00
|
|
|
print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id, true) .
|
2008-03-07 12:33:07 +00:00
|
|
|
"</p>\n", 'generalbox', 'notice');
|
2007-09-20 15:14:24 +00:00
|
|
|
finish_page($course);
|
|
|
|
}
|
2002-10-15 12:54:11 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Get this user's attempts.
|
2007-09-20 15:14:24 +00:00
|
|
|
$attempts = quiz_get_user_attempts($quiz->id, $USER->id);
|
2008-03-07 12:33:07 +00:00
|
|
|
$lastfinishedattempt = end($attempts);
|
2007-09-20 15:14:24 +00:00
|
|
|
$unfinished = false;
|
|
|
|
if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) {
|
|
|
|
$attempts[] = $unfinishedattempt;
|
|
|
|
$unfinished = true;
|
|
|
|
}
|
|
|
|
$numattempts = count($attempts);
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Work out the final grade, checking whether it was overridden in the gradebook.
|
2007-09-20 15:14:24 +00:00
|
|
|
$mygrade = quiz_get_best_grade($quiz, $USER->id);
|
2007-10-11 11:42:49 +00:00
|
|
|
$mygradeoverridden = false;
|
|
|
|
$gradebookfeedback = '';
|
|
|
|
|
|
|
|
$grading_info = grade_get_grades($course->id, 'mod', 'quiz', $quiz->id, $USER->id);
|
2007-10-23 07:48:03 +00:00
|
|
|
if (!empty($grading_info->items)) {
|
|
|
|
$item = $grading_info->items[0];
|
|
|
|
if (isset($item->grades[$USER->id])) {
|
|
|
|
$grade = $item->grades[$USER->id];
|
2008-01-13 08:30:39 +00:00
|
|
|
|
2007-10-23 07:48:03 +00:00
|
|
|
if ($grade->overridden) {
|
|
|
|
$mygrade = $grade->grade + 0; // Convert to number.
|
|
|
|
$mygradeoverridden = true;
|
|
|
|
}
|
|
|
|
if (!empty($grade->str_feedback)) {
|
|
|
|
$gradebookfeedback = $grade->str_feedback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Print table with existing attempts
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($attempts) {
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-10-11 11:42:49 +00:00
|
|
|
print_heading(get_string('summaryofattempts', 'quiz'));
|
2005-05-08 11:24:03 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
// Work out which columns we need, taking account what data is available in each attempt.
|
|
|
|
list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
|
|
|
|
|
|
|
|
$gradecolumn = $someoptions->scores && $quiz->grade && $quiz->sumgrades;
|
|
|
|
$markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades);
|
|
|
|
$overallstats = $alloptions->scores;
|
|
|
|
|
|
|
|
$feedbackcolumn = quiz_has_feedback($quiz->id);
|
|
|
|
$overallfeedback = $feedbackcolumn && $alloptions->overallfeedback;
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
// Prepare table header
|
2007-09-20 15:14:24 +00:00
|
|
|
$table->class = 'generaltable quizattemptsummary';
|
2008-05-15 15:32:43 +00:00
|
|
|
$table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz'));
|
|
|
|
$table->align = array('center', 'left');
|
|
|
|
$table->size = array('', '');
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($markcolumn) {
|
2008-05-15 15:32:43 +00:00
|
|
|
$table->head[] = get_string('marks', 'quiz') . " / $quiz->sumgrades";
|
2007-09-20 15:14:24 +00:00
|
|
|
$table->align[] = 'center';
|
|
|
|
$table->size[] = '';
|
|
|
|
}
|
|
|
|
if ($gradecolumn) {
|
2008-05-15 15:32:43 +00:00
|
|
|
$table->head[] = get_string('grade') . " / $quiz->grade";
|
2007-09-20 15:14:24 +00:00
|
|
|
$table->align[] = 'center';
|
|
|
|
$table->size[] = '';
|
|
|
|
}
|
|
|
|
if ($feedbackcolumn) {
|
2008-05-15 15:32:43 +00:00
|
|
|
$table->head[] = get_string('feedback', 'quiz');
|
2007-09-20 15:14:24 +00:00
|
|
|
$table->align[] = 'left';
|
|
|
|
$table->size[] = '';
|
|
|
|
}
|
|
|
|
if (isset($quiz->showtimetaken)) {
|
2008-05-15 15:32:43 +00:00
|
|
|
$table->head[] = get_string('timetaken', 'quiz');
|
2007-09-20 15:14:24 +00:00
|
|
|
$table->align[] = 'left';
|
|
|
|
$table->size[] = '';
|
|
|
|
}
|
2006-12-22 12:52:13 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
// One row for each attempt
|
|
|
|
foreach ($attempts as $attempt) {
|
|
|
|
$attemptoptions = quiz_get_reviewoptions($quiz, $attempt, $context);
|
|
|
|
$row = array();
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
// Add the attempt number, making it a link, if appropriate.
|
|
|
|
if ($attempt->preview) {
|
2008-03-07 12:33:07 +00:00
|
|
|
$row[] = $accessmanager->make_review_link(get_string('preview', 'quiz'), $attempt, $canpreview, $attemptoptions);
|
2007-09-20 15:14:24 +00:00
|
|
|
} else {
|
2008-03-07 12:33:07 +00:00
|
|
|
$row[] = $accessmanager->make_review_link($attempt->attempt, $attempt, $canpreview, $attemptoptions);
|
2006-08-22 17:31:26 +00:00
|
|
|
}
|
2005-05-08 11:24:03 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
// prepare strings for time taken and date completed
|
|
|
|
$timetaken = '';
|
|
|
|
$datecompleted = '';
|
|
|
|
if ($attempt->timefinish > 0) {
|
|
|
|
// attempt has finished
|
|
|
|
$timetaken = format_time($attempt->timefinish - $attempt->timestart);
|
|
|
|
$datecompleted = userdate($attempt->timefinish);
|
2008-03-07 12:33:07 +00:00
|
|
|
} else if (!$quiz->timeclose || $timenow < $quiz->timeclose) {
|
2007-09-20 15:14:24 +00:00
|
|
|
// The attempt is still in progress.
|
2008-03-07 12:33:07 +00:00
|
|
|
$timetaken = format_time($timenow - $attempt->timestart);
|
2007-09-20 15:14:24 +00:00
|
|
|
$datecompleted = '';
|
2008-03-07 12:33:07 +00:00
|
|
|
} else {
|
2007-09-20 15:14:24 +00:00
|
|
|
$timetaken = format_time($quiz->timeclose - $attempt->timestart);
|
|
|
|
$datecompleted = userdate($quiz->timeclose);
|
|
|
|
}
|
|
|
|
$row[] = $datecompleted;
|
2006-08-22 17:31:26 +00:00
|
|
|
|
2007-11-27 19:18:36 +00:00
|
|
|
if ($markcolumn && $attempt->timefinish > 0) {
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($attemptoptions->scores) {
|
2008-08-15 06:42:38 +00:00
|
|
|
$row[] = $accessmanager->make_review_link(quiz_format_grade($quiz, $attempt->sumgrades),
|
2008-03-07 12:33:07 +00:00
|
|
|
$attempt, $canpreview, $attemptoptions);
|
2007-09-20 15:14:24 +00:00
|
|
|
} else {
|
|
|
|
$row[] = '';
|
2006-04-18 22:54:10 +00:00
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
}
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
// Ouside the if because we may be showing feedback but not grades.
|
|
|
|
$attemptgrade = quiz_rescale_grade($attempt->sumgrades, $quiz);
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($gradecolumn) {
|
2007-11-27 19:18:36 +00:00
|
|
|
if ($attemptoptions->scores && $attempt->timefinish > 0) {
|
2007-09-20 15:14:24 +00:00
|
|
|
$formattedgrade = $attemptgrade;
|
|
|
|
// highlight the highest grade if appropriate
|
2008-03-07 12:33:07 +00:00
|
|
|
if ($overallstats && !$attempt->preview && $numattempts > 1 && !is_null($mygrade) &&
|
|
|
|
$attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
|
2007-09-20 15:14:24 +00:00
|
|
|
$table->rowclass[$attempt->attempt] = 'bestrow';
|
2006-08-25 16:03:54 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
$row[] = $accessmanager->make_review_link($formattedgrade, $attempt, $canpreview, $attemptoptions);
|
2007-09-20 15:14:24 +00:00
|
|
|
} else {
|
|
|
|
$row[] = '';
|
2006-08-25 16:03:54 +00:00
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
}
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-11-27 19:18:36 +00:00
|
|
|
if ($feedbackcolumn && $attempt->timefinish > 0) {
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($attemptoptions->overallfeedback) {
|
|
|
|
$row[] = quiz_feedback_for_grade($attemptgrade, $quiz->id);
|
|
|
|
} else {
|
|
|
|
$row[] = '';
|
2006-08-25 16:03:54 +00:00
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
}
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
if (isset($quiz->showtimetaken)) {
|
|
|
|
$row[] = $timetaken;
|
|
|
|
}
|
2002-10-06 03:23:34 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
if ($attempt->preview) {
|
|
|
|
$table->data['preview'] = $row;
|
|
|
|
} else {
|
|
|
|
$table->data[$attempt->attempt] = $row;
|
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
} // End of loop over attempts.
|
|
|
|
print_table($table);
|
|
|
|
}
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Print information about the student's best score for this quiz if possible.
|
|
|
|
$moreattempts = $unfinished || !$accessmanager->is_finished($numattempts, $lastfinishedattempt);
|
2007-09-20 15:14:24 +00:00
|
|
|
if (!$moreattempts) {
|
|
|
|
print_heading(get_string("nomoreattempts", "quiz"));
|
|
|
|
}
|
2006-08-25 16:03:54 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($numattempts && $quiz->sumgrades && !is_null($mygrade)) {
|
2007-10-11 11:42:49 +00:00
|
|
|
$resultinfo = '';
|
2008-01-13 08:30:39 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($overallstats) {
|
2008-03-07 12:33:07 +00:00
|
|
|
if ($moreattempts) {
|
2007-09-20 15:14:24 +00:00
|
|
|
$a = new stdClass;
|
|
|
|
$a->method = quiz_get_grading_option_name($quiz->grademethod);
|
|
|
|
$a->mygrade = $mygrade;
|
|
|
|
$a->quizgrade = $quiz->grade;
|
2007-10-11 11:42:49 +00:00
|
|
|
$resultinfo .= print_heading(get_string('gradesofar', 'quiz', $a), '', 2, 'main', true);
|
2007-09-20 15:14:24 +00:00
|
|
|
} else {
|
2007-10-11 11:42:49 +00:00
|
|
|
$resultinfo .= print_heading(get_string('yourfinalgradeis', 'quiz', "$mygrade / $quiz->grade"), '', 2, 'main', true);
|
|
|
|
if ($mygradeoverridden) {
|
2008-03-07 12:33:07 +00:00
|
|
|
$resultinfo .= '<p class="overriddennotice">'.get_string('overriddennotice', 'grades')."</p>\n";
|
2007-10-11 11:42:49 +00:00
|
|
|
}
|
2006-08-22 17:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-11 11:42:49 +00:00
|
|
|
if ($gradebookfeedback) {
|
|
|
|
$resultinfo .= print_heading(get_string('comment', 'quiz'), '', 3, 'main', true);
|
2008-03-07 12:33:07 +00:00
|
|
|
$resultinfo .= '<p class="quizteacherfeedback">'.$gradebookfeedback."</p>\n";
|
2007-10-11 11:42:49 +00:00
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($overallfeedback) {
|
2007-10-11 11:42:49 +00:00
|
|
|
$resultinfo .= print_heading(get_string('overallfeedback', 'quiz'), '', 3, 'main', true);
|
2008-03-07 12:33:07 +00:00
|
|
|
$resultinfo .= '<p class="quizgradefeedback">'.quiz_feedback_for_grade($mygrade, $quiz->id)."</p>\n";
|
2007-10-11 11:42:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($resultinfo) {
|
|
|
|
print_box($resultinfo, 'generalbox', 'feedback');
|
2007-09-20 15:14:24 +00:00
|
|
|
}
|
|
|
|
}
|
2006-12-22 12:52:13 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Determine if we should be showing a start/continue attempt button,
|
|
|
|
/// or a button to go back to the course page.
|
|
|
|
print_box_start('quizattempt');
|
|
|
|
$buttontext = ''; // This will be set something if as start/continue attempt button should appear.
|
2007-09-20 15:14:24 +00:00
|
|
|
if (!$quiz->questions) {
|
|
|
|
print_heading(get_string("noquestions", "quiz"));
|
2008-03-07 12:33:07 +00:00
|
|
|
} else {
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($unfinished) {
|
2008-03-07 12:33:07 +00:00
|
|
|
if ($canpreview) {
|
2007-09-20 15:14:24 +00:00
|
|
|
$buttontext = get_string('continuepreview', 'quiz');
|
2006-08-22 17:31:26 +00:00
|
|
|
} else {
|
2007-09-20 15:14:24 +00:00
|
|
|
$buttontext = get_string('continueattemptquiz', 'quiz');
|
|
|
|
}
|
|
|
|
} else {
|
2008-03-07 12:33:07 +00:00
|
|
|
$messages = $accessmanager->prevent_new_attempt($numattempts, $lastfinishedattempt);
|
|
|
|
if (!$canpreview && $messages) {
|
|
|
|
$accessmanager->print_messages($messages);
|
2007-09-20 15:14:24 +00:00
|
|
|
} else {
|
2008-03-07 12:33:07 +00:00
|
|
|
if ($canpreview) {
|
|
|
|
$buttontext = get_string('previewquiznow', 'quiz');
|
|
|
|
} else if ($numattempts == 0) {
|
|
|
|
$buttontext = get_string('attemptquiznow', 'quiz');
|
|
|
|
} else {
|
|
|
|
$buttontext = get_string('reattemptquiz', 'quiz');
|
2006-08-25 16:03:54 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
}
|
2006-08-22 17:31:26 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
// If, so far, we think a button should be printed, so check if they will be allowed to access it.
|
2007-09-20 15:14:24 +00:00
|
|
|
if ($buttontext) {
|
2008-03-07 12:33:07 +00:00
|
|
|
if (!$moreattempts) {
|
|
|
|
$buttontext = '';
|
|
|
|
} else if (!$canpreview && $messages = $accessmanager->prevent_access()) {
|
|
|
|
$accessmanager->print_messages($messages);
|
|
|
|
$buttontext = '';
|
2007-09-20 15:14:24 +00:00
|
|
|
}
|
2006-08-22 17:31:26 +00:00
|
|
|
}
|
2008-03-07 12:33:07 +00:00
|
|
|
}
|
2007-09-20 15:14:24 +00:00
|
|
|
|
2008-03-07 12:33:07 +00:00
|
|
|
/// Now actually print the appropriate button.
|
|
|
|
if ($buttontext) {
|
|
|
|
$accessmanager->print_start_attempt_button($canpreview, $buttontext, $unfinished);
|
2007-09-20 15:14:24 +00:00
|
|
|
} else {
|
|
|
|
print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id);
|
2006-06-28 10:13:40 +00:00
|
|
|
}
|
2008-03-07 12:33:07 +00:00
|
|
|
print_box_end();
|
2002-10-04 02:59:05 +00:00
|
|
|
|
2006-08-25 16:03:54 +00:00
|
|
|
// Should we not be seeing if we need to print right-hand-side blocks?
|
2006-08-22 17:31:26 +00:00
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
finish_page($course);
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
// Mark module as viewed (note, we do this here and not in finish_page,
|
|
|
|
// otherwise the 'not enrolled' error conditions would result in marking
|
|
|
|
// 'viewed', I think it's better if they don't.)
|
|
|
|
$completion=new completion_info($course);
|
|
|
|
$completion->set_module_viewed(cm);
|
2006-08-25 16:03:54 +00:00
|
|
|
|
|
|
|
// Utility functions =================================================================
|
|
|
|
|
2007-09-20 15:14:24 +00:00
|
|
|
function finish_page($course) {
|
2007-10-16 20:29:20 +00:00
|
|
|
global $THEME;
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_end();
|
2007-09-20 15:14:24 +00:00
|
|
|
echo '</td></tr></table>';
|
|
|
|
print_footer($course);
|
|
|
|
exit;
|
2006-08-25 16:03:54 +00:00
|
|
|
}
|
2002-10-04 02:59:05 +00:00
|
|
|
?>
|