From 693d89cbdb55e420e3e35a4f5c74da070b65bd3d Mon Sep 17 00:00:00 2001 From: Jayce Birrell Date: Tue, 10 Jun 2025 10:24:13 +0930 Subject: [PATCH] MDL-73003 core_grades: Don't use 'scale' to determine grading method. When a forum activity used a rubrics with a scale for grading, it was not treated as an advanced grading method, causing the code to mishandle the grading object and not return any grades. --- grade/classes/component_gradeitem.php | 10 +--- .../tests/behat/grade_calculation.feature | 46 +++++++++++++++++-- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/grade/classes/component_gradeitem.php b/grade/classes/component_gradeitem.php index 4e67600bb42..9d010ff45eb 100644 --- a/grade/classes/component_gradeitem.php +++ b/grade/classes/component_gradeitem.php @@ -204,15 +204,7 @@ abstract class component_gradeitem { * @return bool */ public function is_using_advanced_grading(): bool { - if ($this->is_using_scale()) { - return false; - } - - if ($this->get_advanced_grading_controller()) { - return true; - } - - return false; + return (bool) $this->get_advanced_grading_controller(); } /** diff --git a/grade/grading/form/rubric/tests/behat/grade_calculation.feature b/grade/grading/form/rubric/tests/behat/grade_calculation.feature index fa62ae43670..67844f37fee 100644 --- a/grade/grading/form/rubric/tests/behat/grade_calculation.feature +++ b/grade/grading/form/rubric/tests/behat/grade_calculation.feature @@ -4,7 +4,7 @@ Feature: Converting rubric score to grades As a teacher I need to be able to use different grade settings - Scenario Outline: Convert rubric scores to grades. + Background: Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | @@ -19,9 +19,11 @@ Feature: Converting rubric score to grades And the following "scales" exist: | name | scale | | Test scale 1 | Disappointing, Good, Very good, Excellent | - And the following "activities" exist: - | activity | name | intro | course | idnumber | grade | advancedgradingmethod_submissions | - | assign | Test assignment 1 | Test | C1 | assign1 | | rubric | + + Scenario Outline: Convert assignment rubric scores to grades. + Given the following "activities" exist: + | activity | name | intro | course | idnumber | grade | advancedgradingmethod_submissions | + | assign | Test assignment 1 | Test | C1 | assign1 | | rubric | When I log in as "teacher1" And I change window size to "large" And I am on "Course 1" course homepage with editing mode on @@ -55,3 +57,39 @@ Feature: Converting rubric score to grades | 100 | | 10.00 | | 70 | | 7.00 | | Test scale 1 | | Disappointing | + + Scenario Outline: Convert forum rubric scores with a scale to grades. + Given the following "activities" exist: + | activity | name | intro | course | idnumber | grade | advancedgradingmethod_submissions | + | forum | Test forum 1 | Test | C1 | forum1 | 100 | rubric | + And I change window size to "large" + And I am on the "Test forum 1" "forum activity editing" page logged in as teacher1 + And I expand all fieldsets + And I set the following fields to these values: + | Whole forum grading > Type | Scale | + | Whole forum grading > Scale | Default competence scale | + | Grading method | Rubric | + And I press "Save and display" + And I go to "Test forum 1" advanced grading definition page + # Defining a rubric. + And I set the following fields to these values: + | Name | Forum 1 rubric | + | Description | Rubric test description | + And I define the following rubric: + | Criterion 1 | Level 11 | 1 | Level 12 | 20 | Level 13 | 40 | Level 14 | 50 | + | Criterion 2 | Level 21 | 10 | Level 22 | 20 | Level 23 | 30 | | | + | Criterion 3 | Level 31 | 5 | Level 32 | 20 | | | | | + And I press "Save rubric and make it ready" + When I am on the "Test forum 1" "forum activity" page logged in as teacher1 + And I press "Grade users" + And I click on " points" "radio" + And I click on " points" "radio" + And I click on " points" "radio" + And I press "Save" + And I am on the "Course 1" "grades > Grader report > View" page + Then I should see "" in the "student1@example.com" "table_row" + + Examples: + | studentgrade | criterion1 | criterion2 | criterion3 | + | Competent | Level 14 50 | Level 23 30 | Level 32 20 | + | Not yet competent | Level 11 1 | Level 21 10 | Level 31 5 |