From d8bec7a0906d69549b1247a12c1512848fa755f6 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 30 Jan 2024 21:09:57 +0000 Subject: [PATCH] MDL-80766 gradereport_grader: omit max constraint for unlimited grades. --- grade/report/grader/lib.php | 4 +++- grade/report/singleview/classes/local/ui/finalgrade.php | 4 +++- grade/templates/grades/grader/input.mustache | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 9be062ec4a0..043fe5cf279 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -1091,7 +1091,9 @@ class grade_report_grader extends grade_report { // If we're rendering this as a number field, set min/max attributes, if applicable. if ($context->isnumeric) { $context->minvalue = $item->grademin ?? null; - $context->maxvalue = $item->grademax ?? null; + if (empty($CFG->unlimitedgrades)) { + $context->maxvalue = $item->grademax ?? null; + } } $value = format_float($gradeval, $decimalpoints); diff --git a/grade/report/singleview/classes/local/ui/finalgrade.php b/grade/report/singleview/classes/local/ui/finalgrade.php index 075f56b4c8d..a7a143ef508 100644 --- a/grade/report/singleview/classes/local/ui/finalgrade.php +++ b/grade/report/singleview/classes/local/ui/finalgrade.php @@ -113,6 +113,8 @@ class finalgrade extends grade_attribute_format implements unique_value, be_disa * @return element */ public function determine_format(): element { + global $CFG; + if ($this->grade->grade_item->load_scale()) { $scale = $this->grade->grade_item->load_scale(); @@ -153,7 +155,7 @@ class finalgrade extends grade_attribute_format implements unique_value, be_disa // Max attribute. $maxvalue = null; - if (isset($gradeitem->grademax)) { + if (isset($gradeitem->grademax) && empty($CFG->unlimitedgrades)) { $maxvalue = format_float($gradeitem->grademax, $decimals); } $textattribute->set_max($maxvalue); diff --git a/grade/templates/grades/grader/input.mustache b/grade/templates/grades/grader/input.mustache index 86919297e3d..70c2d184175 100644 --- a/grade/templates/grades/grader/input.mustache +++ b/grade/templates/grades/grader/input.mustache @@ -27,6 +27,9 @@ "extraclasses": "statusicons", "value": "Text information", "tabindex": "1", + "isnumeric": "1", + "minvalue": "0", + "maxvalue": "10", "name": "grade[313][624]" } }}