From 41a446dbcebdabc364d65a3e4bce1c97aef22373 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 10 Mar 2008 10:41:22 +0000 Subject: [PATCH] MDL-13866 scale ratings do not work in forum; merged from MOODLE_19_STABLE --- mod/forum/lib.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 9f06e5c3b0..17cba23bbe 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -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; + } } } } -- 2.39.5