From 25c1db727586aa0ff7dce30ffd62fb5e06109ef8 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 10 Oct 2023 16:14:48 +0800 Subject: [PATCH] MDL-79062 gradereport_grader: Set numeric type for grade value inputs * Set grade inputs for grade items with type set to GRADE_VALUE to number and add min and max input attributes, where necessary. --- grade/report/grader/lib.php | 12 ++++++++++++ grade/templates/grades/grader/input.mustache | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index b2bccd95450..9be062ec4a0 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -1082,6 +1082,18 @@ class grade_report_grader extends grade_report { // Value type. if ($quickgrading and $grade->is_editable()) { $context->iseditable = true; + + // Set this input field with type="number" if the decimal separator for current language is set to + // a period. Other decimal separators may not be recognised by browsers yet which may cause issues + // when entering grades. + $decsep = get_string('decsep', 'core_langconfig'); + $context->isnumeric = $decsep === '.'; + // 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; + } + $value = format_float($gradeval, $decimalpoints); $gradelabel = $fullname . ' ' . $item->get_name(true); diff --git a/grade/templates/grades/grader/input.mustache b/grade/templates/grades/grader/input.mustache index 91bc228e2d7..86919297e3d 100644 --- a/grade/templates/grades/grader/input.mustache +++ b/grade/templates/grades/grader/input.mustache @@ -31,4 +31,5 @@ } }} - +