MDL-3633 Don't show the attempt number column on the quiz view page if the quiz only allows one attempt.

This commit is contained in:
tjhunt 2008-09-04 09:22:37 +00:00
parent 237806f4f0
commit 152d3c0242
5 changed files with 64 additions and 29 deletions

View file

@ -412,8 +412,10 @@ $string['noquestionsfound'] = 'No questions found';
$string['noquestionsinfile'] = 'There are no questions in the import file'; $string['noquestionsinfile'] = 'There are no questions in the import file';
$string['noresponse'] = 'No Response'; $string['noresponse'] = 'No Response';
$string['noreview'] = 'You are not allowed to review this quiz'; $string['noreview'] = 'You are not allowed to review this quiz';
$string['noreviewshort'] = 'Not permitted';
$string['noview'] = 'Logged-in user is not allowed to view this quiz'; $string['noview'] = 'Logged-in user is not allowed to view this quiz';
$string['noreviewuntil'] = 'You are not allowed to review this quiz until $a'; $string['noreviewuntil'] = 'You are not allowed to review this quiz until $a';
$string['noreviewuntilshort'] = 'Available $a';
$string['noscript'] = 'JavaScript must be enabled to continue!'; $string['noscript'] = 'JavaScript must be enabled to continue!';
$string['notavailable'] = 'This quiz is not currently available'; $string['notavailable'] = 'This quiz is not currently available';
$string['notavailabletostudents'] = 'Note: This quiz is not currently available to your students'; $string['notavailabletostudents'] = 'Note: This quiz is not currently available to your students';
@ -557,6 +559,7 @@ $string['reviewopen'] = 'Later, while the quiz is still open';
$string['reviewoptions'] = 'Students may review'; $string['reviewoptions'] = 'Students may review';
$string['reviewoptionsheading'] = 'Review options'; $string['reviewoptionsheading'] = 'Review options';
$string['reviewresponse'] = 'Review response'; $string['reviewresponse'] = 'Review response';
$string['reviewthisattempt'] = 'Review your responses to this attempt';
$string['rqp'] = 'Remote Question'; $string['rqp'] = 'Remote Question';
$string['rqps'] = 'Remote Questions'; $string['rqps'] = 'Remote Questions';
$string['save'] = 'Save'; $string['save'] = 'Save';

View file

@ -319,37 +319,57 @@ class quiz_access_manager {
* @param object $attempt the attempt object * @param object $attempt the attempt object
* @return string some HTML, the $linktext either unmodified or wrapped in a link to the review page. * @return string some HTML, the $linktext either unmodified or wrapped in a link to the review page.
*/ */
public function make_review_link($linktext, $attempt, $canpreview, $reviewoptions) { public function make_review_link($attempt, $canpreview, $reviewoptions) {
global $CFG; global $CFG;
/// If review of responses is not allowed, or the attempt is still open, don't link. /// If review of responses is not allowed, or the attempt is still open, don't link.
if (!$reviewoptions->responses || !$attempt->timefinish) { if (!$attempt->timefinish) {
return $linktext; return '';
} }
if (!$reviewoptions->responses) {
$message = $this->cannot_review_message($reviewoptions, true);
if ($message) {
return '<span class="noreviewmessage">' . $message . '</span>';
} else {
return '';
}
}
$linktext = get_string('review', 'quiz');
/// It is OK to link, does it need to be in a secure window? /// It is OK to link, does it need to be in a secure window?
if ($this->securewindow_required($canpreview)) { if ($this->securewindow_required($canpreview)) {
return $this->_securewindowrule->make_review_link($linktext, $attempt->id); return $this->_securewindowrule->make_review_link($linktext, $attempt->id);
} else { } else {
return '<a href="' . $this->_quizobj->review_url($attempt->id) . '">' . $linktext . '</a>'; return '<a href="' . $this->_quizobj->review_url($attempt->id) . '" title="' .
get_string('reviewthisattempt', 'quiz') . '">' . $linktext . '</a>';
} }
} }
/** /**
* If $reviewoptions->responses is false, meaning that students can't review this * If $reviewoptions->responses is false, meaning that students can't review this
* attempt at the moment, return an appropriate string explaining why. * attempt at the moment, return an appropriate string explaining why.
* *
* @param object $reviewoptions as obtained from quiz_get_reviewoptions. * @param object $reviewoptions as obtained from quiz_get_reviewoptions.
* @param boolean $short if true, return a shorter string.
* @return string an appropraite message. * @return string an appropraite message.
*/ */
public function cannot_review_message($reviewoptions) { public function cannot_review_message($reviewoptions, $short = false) {
$quiz = $this->_quizobj->get_quiz(); $quiz = $this->_quizobj->get_quiz();
if ($short) {
$langstrsuffix = 'short';
$dateformat = get_string('strftimedatetimeshort', 'langconfig');
} else {
$langstrsuffix = '';
$dateformat = '';
}
if ($reviewoptions->quizstate == QUIZ_STATE_IMMEDIATELY) { if ($reviewoptions->quizstate == QUIZ_STATE_IMMEDIATELY) {
return ''; return '';
} else if ($reviewoptions->quizstate == QUIZ_STATE_OPEN && $quiz->timeclose && } else if ($reviewoptions->quizstate == QUIZ_STATE_OPEN && $quiz->timeclose &&
($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_RESPONSES)) { ($quiz->review & QUIZ_REVIEW_CLOSED & QUIZ_REVIEW_RESPONSES)) {
return get_string('noreviewuntil', 'quiz', userdate($quiz->timeclose)); return get_string('noreviewuntil' . $langstrsuffix, 'quiz', userdate($quiz->timeclose, $dateformat));
} else { } else {
return get_string('noreview', 'quiz'); return get_string('noreview' . $langstrsuffix, 'quiz');
} }
} }
} }
@ -711,7 +731,7 @@ class securewindow_access_rule extends quiz_access_rule_base {
* @return string HTML for the link. * @return string HTML for the link.
*/ */
public function make_review_link($linktext, $attemptid) { public function make_review_link($linktext, $attemptid) {
return link_to_popup_window($this->_quizobj->review_url($attemptid), return button_to_popup_window($this->_quizobj->review_url($attemptid),
'quizpopup', $linktext, '', '', '', $this->windowoptions, true); 'quizpopup', $linktext, '', '', '', $this->windowoptions, true);
} }

View file

@ -1,7 +1,8 @@
<?php // $Id$ <?php // $Id$
/** /**
* This page prints a review of a particular question attempt * This page allows the teacher to enter a manual grade for a particular question.
* * This page is expected to only be used in a popup window.
* *
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz * @package quiz
*/ */
@ -12,15 +13,7 @@
$attemptid =required_param('attempt', PARAM_INT); // attempt id $attemptid =required_param('attempt', PARAM_INT); // attempt id
$questionid =required_param('question', PARAM_INT); // question id $questionid =required_param('question', PARAM_INT); // question id
if (! $attempt = $DB->get_record('quiz_attempts', array('uniqueid' => $attemptid))) { $attemptobj = new quiz_attempt($attemptid);
print_error('invalidattemptid', 'quiz');
}
if (! $quiz = $DB->get_record('quiz', array('id' => $attempt->quiz))) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record('course', array('id' => $quiz->course))) {
print_error('coursemisconf');
}
// Teachers are only allowed to comment and grade on closed attempts // Teachers are only allowed to comment and grade on closed attempts
if (!($attempt->timefinish > 0)) { if (!($attempt->timefinish > 0)) {

View file

@ -175,6 +175,8 @@
// Work out which columns we need, taking account what data is available in each attempt. // 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); list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
$attemptcolumn = $quiz->attempts != 1;
$gradecolumn = $someoptions->scores && $quiz->grade && $quiz->sumgrades; $gradecolumn = $someoptions->scores && $quiz->grade && $quiz->sumgrades;
$markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades); $markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades);
$overallstats = $alloptions->scores; $overallstats = $alloptions->scores;
@ -184,9 +186,17 @@
// Prepare table header // Prepare table header
$table->class = 'generaltable quizattemptsummary'; $table->class = 'generaltable quizattemptsummary';
$table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz')); $table->head = array();
$table->align = array('center', 'left'); $table->align = array();
$table->size = array('', ''); $table->size = array();
if ($attemptcolumn) {
$table->head[] = get_string('attempt', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
}
$table->head[] = get_string('timecompleted', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades);
$table->align[] = 'left';
$table->size[] = '';
if ($markcolumn) { if ($markcolumn) {
$table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades); $table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades);
$table->align[] = 'center'; $table->align[] = 'center';
@ -197,6 +207,9 @@
$table->align[] = 'center'; $table->align[] = 'center';
$table->size[] = ''; $table->size[] = '';
} }
$table->head[] = get_string('review', 'quiz');
$table->align[] = 'center';
$table->size[] = '';
if ($feedbackcolumn) { if ($feedbackcolumn) {
$table->head[] = get_string('feedback', 'quiz'); $table->head[] = get_string('feedback', 'quiz');
$table->align[] = 'left'; $table->align[] = 'left';
@ -214,10 +227,12 @@
$row = array(); $row = array();
// Add the attempt number, making it a link, if appropriate. // Add the attempt number, making it a link, if appropriate.
if ($attempt->preview) { if ($attemptcolumn) {
$row[] = $accessmanager->make_review_link(get_string('preview', 'quiz'), $attempt, $canpreview, $attemptoptions); if ($attempt->preview) {
} else { $row[] = get_string('preview', 'quiz');
$row[] = $accessmanager->make_review_link($attempt->attempt, $attempt, $canpreview, $attemptoptions); } else {
$row[] = $attempt->attempt;
}
} }
// prepare strings for time taken and date completed // prepare strings for time taken and date completed
@ -239,8 +254,7 @@
if ($markcolumn && $attempt->timefinish > 0) { if ($markcolumn && $attempt->timefinish > 0) {
if ($attemptoptions->scores) { if ($attemptoptions->scores) {
$row[] = $accessmanager->make_review_link(quiz_format_grade($quiz, $attempt->sumgrades), $row[] = quiz_format_grade($quiz, $attempt->sumgrades);
$attempt, $canpreview, $attemptoptions);
} else { } else {
$row[] = ''; $row[] = '';
} }
@ -258,12 +272,14 @@
$table->rowclass[$attempt->attempt] = 'bestrow'; $table->rowclass[$attempt->attempt] = 'bestrow';
} }
$row[] = $accessmanager->make_review_link($formattedgrade, $attempt, $canpreview, $attemptoptions); $row[] = $formattedgrade;
} else { } else {
$row[] = ''; $row[] = '';
} }
} }
$row[] = $accessmanager->make_review_link($attempt, $canpreview, $attemptoptions);
if ($feedbackcolumn && $attempt->timefinish > 0) { if ($feedbackcolumn && $attempt->timefinish > 0) {
if ($attemptoptions->overallfeedback) { if ($attemptoptions->overallfeedback) {
$row[] = quiz_feedback_for_grade($attemptgrade, $quiz->id); $row[] = quiz_feedback_for_grade($attemptgrade, $quiz->id);

View file

@ -1036,6 +1036,9 @@ table.message_search_results td {
table.quizattemptsummary .bestrow td { table.quizattemptsummary .bestrow td {
background-color: #e8e8e8; background-color: #e8e8e8;
} }
table.quizattemptsummary .noreviewmessage {
color: gray;
}
#mod-quiz-attempt #quiz-timer-outer { #mod-quiz-attempt #quiz-timer-outer {
border-color: #dddddd; border-color: #dddddd;