]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13866 scale ratings do not work in forum; merged from MOODLE_19_STABLE
authorskodak <skodak>
Mon, 10 Mar 2008 10:41:22 +0000 (10:41 +0000)
committerskodak <skodak>
Mon, 10 Mar 2008 10:41:22 +0000 (10:41 +0000)
mod/forum/lib.php

index 9f06e5c3b0d0847616c4b3697e0f2c8f153e9d71..17cba23bbe24dab0d82b11e84ae0902bebbf56be 100644 (file)
@@ -1209,9 +1209,18 @@ function forum_get_user_grades($forum, $userid=0) {
     if ($results = get_records_sql($sql)) {
         // it could throw off the grading if count and sum returned a rawgrade higher than scale
         // so to prevent it we review the results and ensure that rawgrade does not exceed the scale, if it does we set rawgrade = scale (i.e. full credit)
-        foreach ($results as $result) {
-            if ($result->rawgrade > $forum->scale) {
-                $result->rawgrade = $forum->scale;
+        foreach ($results as $rid=>$result) {
+            if ($forum->scale >= 0) {
+                //numberic
+                if ($result->rawgrade > $forum->scale) {
+                    $results[$rid]->rawgrade = $forum->scale;
+                }
+            } else {
+                //scales
+                $max = count_records('scale', 'id', - $forum->scale);
+                if ($result->rawgrade > $max) {
+                    $results[$rid]->rawgrade = $max;
+                }
             }
         }
     }