MDL-70034 gradingform_guide: use new API to retrieve grade item name
authorMark Nelson <mdjnelson@gmail.com>
Wed, 23 Dec 2020 07:48:52 +0000 (15:48 +0800)
committerMark Nelson <mdjnelson@gmail.com>
Sat, 9 Jan 2021 06:31:09 +0000 (14:31 +0800)
grade/grading/form/guide/lib.php

index f878c5e..371a5ff 100644 (file)
@@ -657,8 +657,9 @@ class gradingform_guide_controller extends gradingform_controller {
         }
         $returnvalue['maxscore'] = $maxscore;
         $returnvalue['minscore'] = 0;
-        if (!empty($this->moduleinstance->grade)) {
-            $graderange = make_grades_menu($this->moduleinstance->grade);
+        $fieldname = \core_grades\component_gradeitems::get_field_name_for_itemname($this->component, $this->area, 'grade');
+        if (!empty($this->moduleinstance->{$fieldname})) {
+            $graderange = make_grades_menu($this->moduleinstance->{$fieldname});
             $returnvalue['modulegrade'] = count($graderange) - 1;
         }
         return $returnvalue;