MDL-3633 Don't show the attempt number column on the quiz view page if the quiz only...
authortjhunt <tjhunt>
Thu, 4 Sep 2008 09:22:37 +0000 (09:22 +0000)
committertjhunt <tjhunt>
Thu, 4 Sep 2008 09:22:37 +0000 (09:22 +0000)
lang/en_utf8/quiz.php
mod/quiz/accessrules.php
mod/quiz/comment.php
mod/quiz/view.php
theme/standard/styles_color.css

index 47c9afe40fdd8854202faff1afc83b44c78033db..14603d0e34492fac403bbf5dfde8a615d1235240 100644 (file)
@@ -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';
index 2941a00942e8cd4e546e061b0eb6bb77972d6fbc..dab4edd7ca7490542e4a5a2e3d1e654754155eb5 100644 (file)
@@ -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 '<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?
         if ($this->securewindow_required($canpreview)) {
             return $this->_securewindowrule->make_review_link($linktext, $attempt->id);
         } 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
      * 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);
     }
 
index b800d7b5fefb610cedc0cd7b6d0deee892504d7c..0376123d7f39850517682ceaf3d2ea6dc155cf7b 100644 (file)
@@ -1,7 +1,8 @@
 <?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
  * @package quiz
  */
     $attemptid =required_param('attempt', PARAM_INT); // attempt id
     $questionid =required_param('question', PARAM_INT); // question id
 
-    if (! $attempt = $DB->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)) {
index 44f74af5e9824afc9b95e0759c901778c862f1cc..78951f360724eafef870f164b0f56914457391bd 100644 (file)
         // 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;
 
         // 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';
             $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';
             $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
 
             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[] = '';
                 }
                         $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);
index 0e420390a678c7cca7f95c45080931abcdf1c2d4..a4d885a605fae067b25fae6445abf82e9fac076d 100644 (file)
@@ -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;