]> git.mjollnir.org Git - moodle.git/commitdiff
fix for MDL-7496, incorrect is read almost last, need to be said first
authortoyomoyo <toyomoyo>
Thu, 30 Nov 2006 08:27:58 +0000 (08:27 +0000)
committertoyomoyo <toyomoyo>
Thu, 30 Nov 2006 08:27:58 +0000 (08:27 +0000)
question/type/shortanswer/display.html
question/type/shortanswer/questiontype.php

index ab9f6a326643d83740ab87defb073275501c0523..d7f3f3829578b9f661755a7470cbbc35a9576c2f 100644 (file)
@@ -21,9 +21,3 @@
   <?php } ?>
   <?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?>
 </div>
-
-<?php if ($correctanswer) { ?>
-    <div class="correctness correct">
-    <?php print_string('correctansweris', 'quiz', s($correctanswer)); ?>
-  </div>
-<?php } ?>
index 1d03a548068c543d2fa64a2e86261c3eccd29b21..c18c22d60af510c0f18f62b677dd5ed54019f311 100644 (file)
@@ -123,7 +123,6 @@ class question_shortanswer_qtype extends default_questiontype {
     function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
         global $CFG;
     /// This implementation is also used by question type 'numerical'
-        $correctanswers = $this->get_correct_responses($question, $state);
         $readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
         $formatoptions = new stdClass;
         $formatoptions->noclean = true;
@@ -157,17 +156,8 @@ class question_shortanswer_qtype extends default_questiontype {
                 }
             }
         }
-
-        $correctanswer = '';
-        if ($options->readonly && $options->correct_responses) {
-            $delimiter = '';
-            if ($correctanswers) {
-                foreach ($correctanswers as $ca) {
-                    $correctanswer .= $delimiter.$ca;
-                    $delimiter = ', ';
-                }
-            }
-        }
+        
+        /// Removed correct answer, to be displayed later MDL-7496               
         include("$CFG->dirroot/question/type/shortanswer/display.html");
     }
 
@@ -314,6 +304,118 @@ class question_shortanswer_qtype extends default_questiontype {
 
         return $status;
     }
+    
+    
+        /**
+    * Prints the score obtained and maximum score available plus any penalty
+    * information
+    *
+    * This function prints a summary of the scoring in the most recently
+    * graded state (the question may not have been submitted for marking at
+    * the current state). The default implementation should be suitable for most
+    * question types.
+    * @param object $question The question for which the grading details are
+    *                         to be rendered. Question type specific information
+    *                         is included. The maximum possible grade is in
+    *                         ->maxgrade.
+    * @param object $state    The state. In particular the grading information
+    *                          is in ->grade, ->raw_grade and ->penalty.
+    * @param object $cmoptions
+    * @param object $options  An object describing the rendering options.
+    */
+    function print_question_grading_details(&$question, &$state, $cmoptions, $options) {
+        /* The default implementation prints the number of marks if no attempt
+        has been made. Otherwise it displays the grade obtained out of the
+        maximum grade available and a warning if a penalty was applied for the
+        attempt and displays the overall grade obtained counting all previous
+        responses (and penalties) */
+        
+        // MDL-7496 show correct answer after "Incorrect"
+        $correctanswer = '';
+        if ($correctanswers = $this->get_correct_responses($question, $state)) {
+            if ($options->readonly && $options->correct_responses) {
+                $delimiter = '';
+                if ($correctanswers) {
+                    foreach ($correctanswers as $ca) {
+                        $correctanswer .= $delimiter.$ca;
+                        $delimiter = ', ';
+                    }
+                }
+            }         
+        }
+      
+        if (QUESTION_EVENTDUPLICATE == $state->event) {
+            echo ' ';
+            print_string('duplicateresponse', 'quiz');
+        }
+        if (!empty($question->maxgrade) && $options->scores) {
+            if (question_state_is_graded($state->last_graded)) {
+                // Display the grading details from the last graded state
+                $grade = new stdClass;
+                $grade->cur = round($state->last_graded->grade, $cmoptions->decimalpoints);
+                $grade->max = $question->maxgrade;
+                $grade->raw = round($state->last_graded->raw_grade, $cmoptions->decimalpoints);
+
+                // let student know wether the answer was correct
+                echo '<div class="correctness ';
+                if ($state->last_graded->raw_grade >= $question->maxgrade/1.01) { // We divide by 1.01 so that rounding errors dont matter.
+                    echo ' correct">';
+                    print_string('correct', 'quiz');
+                } else if ($state->last_graded->raw_grade > 0) {
+                    echo ' partiallycorrect">';
+                    print_string('partiallycorrect', 'quiz');
+                    // MDL-7496
+                    if ($correctanswer) {
+                        echo ('<div class="correctness correct">');
+                        print_string('correctansweris', 'quiz', s($correctanswer));
+                        echo ('</div>');
+                    }
+                } else {
+                    echo ' incorrect">';
+                    // MDL-7496
+                    print_string('incorrect', 'quiz');                   
+                    if ($correctanswer) {
+                        echo ('<div class="correctness correct">');
+                        print_string('correctansweris', 'quiz', s($correctanswer));
+                        echo ('</div>');
+                    }
+                }
+                echo '</div>';
+
+                echo '<div class="gradingdetails">';
+                // print grade for this submission
+                print_string('gradingdetails', 'quiz', $grade);
+                if ($cmoptions->penaltyscheme) {
+                    // print details of grade adjustment due to penalties
+                    if ($state->last_graded->raw_grade > $state->last_graded->grade){
+                        echo ' ';
+                        print_string('gradingdetailsadjustment', 'quiz', $grade);
+                    }
+                    // print info about new penalty
+                    // penalty is relevant only if the answer is not correct and further attempts are possible
+                    if (($state->last_graded->raw_grade < $question->maxgrade) and (QUESTION_EVENTCLOSEANDGRADE !== $state->event)) {
+                        if ('' !== $state->last_graded->penalty && ((float)$state->last_graded->penalty) > 0.0) {
+                            // A penalty was applied so display it
+                            echo ' ';
+                            print_string('gradingdetailspenalty', 'quiz', $state->last_graded->penalty);
+                        } else {
+                            /* No penalty was applied even though the answer was
+                            not correct (eg. a syntax error) so tell the student
+                            that they were not penalised for the attempt */
+                            echo ' ';
+                            print_string('gradingdetailszeropenalty', 'quiz');
+                        }
+                    }
+                }
+                echo '</div>';
+            }
+        }
+    }
+    
+    
+    
+    
+    
 
 }
 //// END OF CLASS ////