]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed comparison of assessments for error banded and criterion grading.
authorrkingdon <rkingdon>
Fri, 20 Aug 2004 09:08:33 +0000 (09:08 +0000)
committerrkingdon <rkingdon>
Fri, 20 Aug 2004 09:08:33 +0000 (09:08 +0000)
mod/exercise/assessments.php
mod/exercise/locallib.php
mod/exercise/view.php

index f93e40afa0f6dfbeabac91130756f36f00009f02..c42d4a11bc520637b9b68fb6214d057ac24db09f 100644 (file)
                                break;
                                
                        case 3: // criterion grading
-                               for ($j = 100; $j >= 0; $j--) {
+                               for ($j = $exercise->grade; $j >= 0; $j--) {
                                        $numbers[$j] = $j;
                                }
                                for ($i=0; $i<$exercise->nelements; $i++) {
index b7afc9e9b1de0b7e747c28210060865cf9954c90..2af7c6ad4241531d914073862e5971c75a51e5dd 100644 (file)
@@ -115,11 +115,30 @@ function exercise_compare_assessments($exercise, $assessment1, $assessment2) {
     }
     $sumdiffs = 0;
     $sumweights = 0;
-    for ($i=0; $i < $exercise->nelements; $i++) {
-        $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i] / $maxscore[$i];
-        $sumdiffs += $diff * $diff; // use squared distances
-        $sumweights += $weight[$i];
-    }
+    switch ($exercise->gradingstrategy) {
+        case 1 : // accumulative grading and...
+        case 4 : // ...rubic grading
+            for ($i=0; $i < $exercise->nelements; $i++) {
+                $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i] / $maxscore[$i];
+                $sumdiffs += $diff * $diff; // use squared distances
+                $sumweights += $weight[$i];
+                }
+            break;
+        case 2 :  // error banded grading
+            // ignore maxscores here, the grades are either 0 or 1,
+            for ($i=0; $i < $exercise->nelements; $i++) {
+                $diff = ($grades[0][$i] - $grades[1][$i]) * $weight[$i];
+                $sumdiffs += $diff * $diff; // use squared distances
+                $sumweights += $weight[$i];
+                }
+            break;
+        case 3 : // criterion grading
+            // here we only need to look at the difference between the "zero" grade elements
+            $diff = ($grades[0][0] - $grades[1][0]) / (count($elementsraw) - 1);
+            $sumdiffs = $diff * $diff;
+            $sumweights = 1;
+            break;
+    }            
     // convert to a sensible grade (always out of 100)
     $COMP = (object)$EXERCISE_ASSESSMENT_COMPS[$exercise->assessmentcomps];
     $factor = $COMP->value;
@@ -1852,7 +1871,7 @@ function exercise_print_assessment_form($exercise, $assessment = false, $allowch
                     .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font></TD></tr>\n";
                 echo "<TR valign=\"top\">\n";
 
-                echo "  <TD BGCOLOR=\"$THEME->cellheading2\" align=\"center\"><B>".get_string("select", "exercise")."</B></TD>\n";
+                echo "  <TD BGCOLOR=\"$THEME->cellheading2\" align=\"center\"><B>".get_string("select")."</B></TD>\n";
                 echo "  <TD BGCOLOR=\"$THEME->cellheading2\"><B>". get_string("criterion","exercise")."</B></TD></tr>\n";
 
                 if (isset($grades[$i])) {
@@ -2320,7 +2339,7 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss
        <?PHP
 
     // now print a normal assessment form based on the student's assessment for this submission 
-    // and allow the teacher to grade and add comments
+    // and allow the teacher to grade and add additional comments
     $studentassessment = $assessment;
     $allowchanges = true;
     
@@ -2329,8 +2348,8 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss
     
     // is there an existing assessment for the submission
     if (!$assessment = exercise_get_submission_assessment($submission, $USER)) {
-        // copy student's assessment without the comments for the student's submission
-        $assessment = exercise_copy_assessment($studentassessment, $submission);
+        // copy student's assessment with their comments for the teacher's assessment
+        $assessment = exercise_copy_assessment($studentassessment, $submission, true);
         }
 
     // only show the grade if grading strategy > 0 and the grade is positive
@@ -2591,7 +2610,7 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss
             echo "<TR valign=top>\n";
             echo "  <TD BGCOLOR=\"$THEME->cellheading2\">&nbsp;</TD>\n";
             echo "  <TD BGCOLOR=\"$THEME->cellheading2\"><B>". get_string("criterion","exercise")."</B></TD>\n";
-            echo "  <TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("select", "exercise")."</B></TD>\n";
+            echo "  <TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("select")."</B></TD>\n";
             echo "  <TD BGCOLOR=\"$THEME->cellheading2\"><B>".get_string("suggestedgrade", "exercise")."</B></TD>\n";
             // find which criteria has been selected (saved in the zero element), if any
             if (isset($grades[0]->grade)) {
@@ -2639,7 +2658,7 @@ function exercise_print_teacher_assessment_form($exercise, $assessment, $submiss
                      "<P align=\"right\"><font size=\"1\">Weight: "
                     .number_format($EXERCISE_EWEIGHTS[$elements[$i]->weight], 2)."</font></TD></tr>\n";
                 echo "<TR valign=\"top\">\n";
-                echo "  <TD BGCOLOR=\"$THEME->cellheading2\" align=\"center\"><B>".get_string("select", "exercise")."</B></TD>\n";
+                echo "  <TD BGCOLOR=\"$THEME->cellheading2\" align=\"center\"><B>".get_string("select")."</B></TD>\n";
                 echo "  <TD BGCOLOR=\"$THEME->cellheading2\"><B>". get_string("criterion","exercise")."</B></TD></tr>\n";
                 if (isset($grades[$i])) {
                     $selection = $grades[$i]->grade;
index 0efe73cae51b7d5823b6b39fd75593e5e4eca570..2413e49d6e75e56130a7583551c9bb26006f2b90 100644 (file)
                if (exercise_count_teacher_submissions($exercise) == 0) {
                        redirect("view.php?id=$cm->id", get_string("noexercisedescriptionssubmitted", "exercise"));
                        }
-               else {
+               elseif (($exercise->gradingstrategy == 3) and ($exercise->nelements ==1 )) {
+            // only one criterion specified
+            redirect("view.php?id=$cm->id", get_string("numberofcriterionelements", "exercise"));
+        } else {
                        set_field("exercise", "phase", 2, "id", "$exercise->id");
                        add_to_log($course->id, "exercise", "open", "view.php?id=$cm->id", "$exercise->id", $cm->id);
                        redirect("view.php?id=$cm->id", get_string("movingtophase", "exercise", 2));