From 152d3c024295c271c3fea00cf2b84d6271b3aa83 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 4 Sep 2008 09:22:37 +0000 Subject: [PATCH] MDL-3633 Don't show the attempt number column on the quiz view page if the quiz only allows one attempt. --- lang/en_utf8/quiz.php | 3 +++ mod/quiz/accessrules.php | 36 +++++++++++++++++++++++++-------- mod/quiz/comment.php | 15 ++++---------- mod/quiz/view.php | 36 ++++++++++++++++++++++++--------- theme/standard/styles_color.css | 3 +++ 5 files changed, 64 insertions(+), 29 deletions(-) diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 47c9afe40f..14603d0e34 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -412,8 +412,10 @@ $string['noquestionsfound'] = 'No questions found'; $string['noquestionsinfile'] = 'There are no questions in the import file'; $string['noresponse'] = 'No Response'; $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['noreviewuntil'] = 'You are not allowed to review this quiz until $a'; +$string['noreviewuntilshort'] = 'Available $a'; $string['noscript'] = 'JavaScript must be enabled to continue!'; $string['notavailable'] = 'This quiz is not currently available'; $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['reviewoptionsheading'] = 'Review options'; $string['reviewresponse'] = 'Review response'; +$string['reviewthisattempt'] = 'Review your responses to this attempt'; $string['rqp'] = 'Remote Question'; $string['rqps'] = 'Remote Questions'; $string['save'] = 'Save'; diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index 2941a00942..dab4edd7ca 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -319,37 +319,57 @@ class quiz_access_manager { * @param object $attempt the attempt object * @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; /// If review of responses is not allowed, or the attempt is still open, don't link. - if (!$reviewoptions->responses || !$attempt->timefinish) { - return $linktext; + if (!$attempt->timefinish) { + return ''; + } + if (!$reviewoptions->responses) { + $message = $this->cannot_review_message($reviewoptions, true); + if ($message) { + return '' . $message . ''; + } else { + return ''; + } } + $linktext = get_string('review', 'quiz'); + /// It is OK to link, does it need to be in a secure window? if ($this->securewindow_required($canpreview)) { return $this->_securewindowrule->make_review_link($linktext, $attempt->id); } else { - return '' . $linktext . ''; + return '' . $linktext . ''; } } + /** * If $reviewoptions->responses is false, meaning that students can't review this * attempt at the moment, return an appropriate string explaining why. * * @param object $reviewoptions as obtained from quiz_get_reviewoptions. + * @param boolean $short if true, return a shorter string. * @return string an appropraite message. */ - public function cannot_review_message($reviewoptions) { + public function cannot_review_message($reviewoptions, $short = false) { $quiz = $this->_quizobj->get_quiz(); + if ($short) { + $langstrsuffix = 'short'; + $dateformat = get_string('strftimedatetimeshort', 'langconfig'); + } else { + $langstrsuffix = ''; + $dateformat = ''; + } if ($reviewoptions->quizstate == QUIZ_STATE_IMMEDIATELY) { return ''; } else if ($reviewoptions->quizstate == QUIZ_STATE_OPEN && $quiz->timeclose && ($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 { - 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. */ 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); } diff --git a/mod/quiz/comment.php b/mod/quiz/comment.php index b800d7b5fe..0376123d7f 100644 --- a/mod/quiz/comment.php +++ b/mod/quiz/comment.php @@ -1,7 +1,8 @@ get_record('quiz_attempts', array('uniqueid' => $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'); - } + $attemptobj = new quiz_attempt($attemptid); // Teachers are only allowed to comment and grade on closed attempts if (!($attempt->timefinish > 0)) { diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 44f74af5e9..78951f3607 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -175,6 +175,8 @@ // 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); + $attemptcolumn = $quiz->attempts != 1; + $gradecolumn = $someoptions->scores && $quiz->grade && $quiz->sumgrades; $markcolumn = $gradecolumn && ($quiz->grade != $quiz->sumgrades); $overallstats = $alloptions->scores; @@ -184,9 +186,17 @@ // Prepare table header $table->class = 'generaltable quizattemptsummary'; - $table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz')); - $table->align = array('center', 'left'); - $table->size = array('', ''); + $table->head = array(); + $table->align = 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) { $table->head[] = get_string('marks', 'quiz') . ' / ' . quiz_format_grade($quiz, $quiz->sumgrades); $table->align[] = 'center'; @@ -197,6 +207,9 @@ $table->align[] = 'center'; $table->size[] = ''; } + $table->head[] = get_string('review', 'quiz'); + $table->align[] = 'center'; + $table->size[] = ''; if ($feedbackcolumn) { $table->head[] = get_string('feedback', 'quiz'); $table->align[] = 'left'; @@ -214,10 +227,12 @@ $row = array(); // Add the attempt number, making it a link, if appropriate. - if ($attempt->preview) { - $row[] = $accessmanager->make_review_link(get_string('preview', 'quiz'), $attempt, $canpreview, $attemptoptions); - } else { - $row[] = $accessmanager->make_review_link($attempt->attempt, $attempt, $canpreview, $attemptoptions); + if ($attemptcolumn) { + if ($attempt->preview) { + $row[] = get_string('preview', 'quiz'); + } else { + $row[] = $attempt->attempt; + } } // prepare strings for time taken and date completed @@ -239,8 +254,7 @@ if ($markcolumn && $attempt->timefinish > 0) { if ($attemptoptions->scores) { - $row[] = $accessmanager->make_review_link(quiz_format_grade($quiz, $attempt->sumgrades), - $attempt, $canpreview, $attemptoptions); + $row[] = quiz_format_grade($quiz, $attempt->sumgrades); } else { $row[] = ''; } @@ -258,12 +272,14 @@ $table->rowclass[$attempt->attempt] = 'bestrow'; } - $row[] = $accessmanager->make_review_link($formattedgrade, $attempt, $canpreview, $attemptoptions); + $row[] = $formattedgrade; } else { $row[] = ''; } } + $row[] = $accessmanager->make_review_link($attempt, $canpreview, $attemptoptions); + if ($feedbackcolumn && $attempt->timefinish > 0) { if ($attemptoptions->overallfeedback) { $row[] = quiz_feedback_for_grade($attemptgrade, $quiz->id); diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index 0e420390a6..a4d885a605 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -1036,6 +1036,9 @@ table.message_search_results td { table.quizattemptsummary .bestrow td { background-color: #e8e8e8; } +table.quizattemptsummary .noreviewmessage { + color: gray; +} #mod-quiz-attempt #quiz-timer-outer { border-color: #dddddd; -- 2.39.5