diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php
index 15d94cfb306..af587d322af 100644
--- a/grade/report/grader/lib.php
+++ b/grade/report/grader/lib.php
@@ -802,8 +802,6 @@ class grade_report_grader extends grade_report {
$rows = array();
$this->rowcount = 0;
$numrows = count($this->gtree->get_levels());
- $numusers = count($this->users);
- $gradetabindex = 1;
$columnstounset = array();
$strgrade = $this->get_lang_string('gradenoun');
$strfeedback = $this->get_lang_string("feedback");
@@ -945,7 +943,6 @@ class grade_report_grader extends grade_report {
// Preload scale objects for items with a scaleid and initialize tab indices
$scaleslist = array();
- $tabindices = array();
foreach ($this->gtree->get_items() as $itemid => $item) {
$scale = null;
@@ -955,9 +952,6 @@ class grade_report_grader extends grade_report {
} else {
$jsarguments['items'][$itemid] = array('id'=>$itemid, 'name'=>$item->get_name(true), 'type'=>'value', 'scale'=>false, 'decimals'=>$item->get_decimals());
}
- $tabindices[$item->id]['grade'] = $gradetabindex;
- $tabindices[$item->id]['feedback'] = $gradetabindex + $numusers;
- $gradetabindex += $numusers * 2;
}
$scalesarray = array();
@@ -1123,7 +1117,7 @@ class grade_report_grader extends grade_report {
} else {
$nogradestr = $this->get_lang_string('nooutcome', 'grades');
}
- $attributes = array('tabindex' => $tabindices[$item->id]['grade'], 'id'=>'grade_'.$userid.'_'.$item->id);
+ $attributes = ['id' => 'grade_' . $userid . '_' . $item->id];
$gradelabel = $fullname . ' ' . $item->get_name(true);
$itemcell->text .= html_writer::label(
get_string('useractivitygrade', 'gradereport_grader', $gradelabel), $attributes['id'], false,
@@ -1149,9 +1143,33 @@ class grade_report_grader extends grade_report {
$gradelabel = $fullname . ' ' . $item->get_name(true);
$itemcell->text .= '';
- $itemcell->text .= '';
+
+ // 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');
+ $isnumeric = $decsep === '.';
+ $inputtype = $isnumeric ? 'number' : 'text';
+ $inputparams = [
+ 'type' => $inputtype,
+ 'class' => 'text',
+ 'title' => $strgrade,
+ 'name' => "grade[{$userid}][{$item->id}]",
+ 'id' => "grade_{$userid}_{$item->id}",
+ 'value' => $value,
+ ];
+ // If we're rendering this as a number field, set step and min/max attributes (if applicable).
+ if ($isnumeric) {
+ $inputparams['step'] = 'any';
+ if (isset($item->grademin)) {
+ $inputparams['min'] = $item->grademin;
+ }
+ if (isset($item->grademax)) {
+ $inputparams['max'] = $item->grademax;
+ }
+ }
+
+ $itemcell->text .= html_writer::empty_tag('input', $inputparams);
} else {
$itemcell->text .= $gradepassicon . "" .
format_float($gradeval, $decimalpoints) . "";
@@ -1163,7 +1181,7 @@ class grade_report_grader extends grade_report {
$feedbacklabel = $fullname . ' ' . $item->get_name(true);
$itemcell->text .= '';
- $itemcell->text .= '';
}
diff --git a/grade/tests/behat/grade_UI_settings.feature b/grade/tests/behat/grade_UI_settings.feature
index a5a9f116a3e..ed4e48590d2 100644
--- a/grade/tests/behat/grade_UI_settings.feature
+++ b/grade/tests/behat/grade_UI_settings.feature
@@ -43,9 +43,9 @@ Feature: Site settings can be used to hide parts of the gradebook UI
@javascript
Scenario: Disable category overriding
- And "tr .course input[type='text']" "css_element" should exist
- Then I navigate to "Grades > Grade category settings" in site administration
+ Given "Student 1 Course total" "field" should exist
+ And I navigate to "Grades > Grade category settings" in site administration
And I set the field "Allow category grades to be manually overridden" to "0"
And I press "Save changes"
- And I am on the "Course 1" "grades > Grader report > View" page
- And "tr .course input[type='text']" "css_element" should not exist
+ When I am on the "Course 1" "grades > Grader report > View" page
+ Then "Student 1 Course total" "field" should not exist
diff --git a/grade/tests/behat/grade_mingrade.feature b/grade/tests/behat/grade_mingrade.feature
index b6007dc77d3..cd4b61f18c0 100644
--- a/grade/tests/behat/grade_mingrade.feature
+++ b/grade/tests/behat/grade_mingrade.feature
@@ -19,50 +19,23 @@ Feature: We can use a minimum grade different than zero
| student1 | C1 | student |
| student2 | C1 | student |
And the following "grade categories" exist:
- | fullname | course |
- | Sub category 1 | C1 |
- | Sub category 2 | C1 |
+ | fullname | course | aggregateonlygraded |
+ | Sub category 1 | C1 | 0 |
+ | Sub category 2 | C1 | 0 |
+ And the following "grade items" exist:
+ | itemname | grademin | course |
+ | Manual item 1 | -100 | C1 |
+ | Manual item 2 | 50 | C1 |
+ And the following "grade items" exist:
+ | itemname | grademin | grademax | course | gradecategory |
+ | Manual item 3 | -100 | 50 | C1 | Sub category 1 |
+ And the following "grade items" exist:
+ | itemname | grademin | course | gradecategory |
+ | Manual item 4 | -100 | C1 | Sub category 1 |
+ | Manual item 5 | 50 | C1 | Sub category 2 |
+ | Manual item 6 | 50 | C1 | Sub category 2 |
And I log in as "admin"
- And I set the following administration settings values:
- | grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
And I am on the "Course 1" "grades > gradebook setup" page
- And I press "Add grade item"
- And I set the following fields to these values:
- | Item name | Manual item 1 |
- | Minimum grade | -100 |
- | Grade category | Course 1 |
- And I press "Save changes"
- And I press "Add grade item"
- And I set the following fields to these values:
- | Item name | Manual item 2 |
- | Minimum grade | 50 |
- | Grade category | Course 1 |
- And I press "Save changes"
- And I press "Add grade item"
- And I set the following fields to these values:
- | Item name | Manual item 3 |
- | Maximum grade | 50 |
- | Minimum grade | -100 |
- | Grade category | Sub category 1 |
- And I press "Save changes"
- And I press "Add grade item"
- And I set the following fields to these values:
- | Item name | Manual item 4 |
- | Minimum grade | -100 |
- | Grade category | Sub category 1 |
- And I press "Save changes"
- And I press "Add grade item"
- And I set the following fields to these values:
- | Item name | Manual item 5 |
- | Minimum grade | 50 |
- | Grade category | Sub category 2 |
- And I press "Save changes"
- And I press "Add grade item"
- And I set the following fields to these values:
- | Item name | Manual item 6 |
- | Minimum grade | 50 |
- | Grade category | Sub category 2 |
- And I press "Save changes"
And I navigate to "Setup > Course grade settings" in the course gradebook
And I set the field "Show weightings" to "Show"
And I set the field "Show contribution to course total" to "Show"
@@ -70,13 +43,7 @@ Feature: We can use a minimum grade different than zero
@javascript
Scenario: Natural aggregation with negative and positive grade
- And I navigate to "Setup > Gradebook setup" in the course gradebook
- And I set the following settings for grade item "Sub category 1":
- | Aggregation | Natural |
- | Exclude empty grades | 0 |
- And I set the following settings for grade item "Sub category 2":
- | Aggregation | Natural |
- | Exclude empty grades | 0 |
+ Given I navigate to "Setup > Gradebook setup" in the course gradebook
And I set the following settings for grade item "Course 1":
| Aggregation | Natural |
| Exclude empty grades | 0 |
@@ -89,11 +56,11 @@ Feature: We can use a minimum grade different than zero
And I give the grade "50.00" to the user "Student 1" for the grade item "Manual item 5"
And I give the grade "75.00" to the user "Student 1" for the grade item "Manual item 6"
And I give the grade "0.00" to the user "Student 2" for the grade item "Manual item 1"
- And I give the grade "0.00" to the user "Student 2" for the grade item "Manual item 2"
+ And I give the grade "50.00" to the user "Student 2" for the grade item "Manual item 2"
And I give the grade "-10.00" to the user "Student 2" for the grade item "Manual item 3"
And I give the grade "50.00" to the user "Student 2" for the grade item "Manual item 4"
- And I give the grade "0.00" to the user "Student 2" for the grade item "Manual item 5"
- And I give the grade "0.00" to the user "Student 2" for the grade item "Manual item 6"
+ And I give the grade "50.00" to the user "Student 2" for the grade item "Manual item 5"
+ And I give the grade "50.00" to the user "Student 2" for the grade item "Manual item 6"
And I press "Save changes"
And I navigate to "View > User report" in the course gradebook
And I click on "Student 1" in the "user" search widget
diff --git a/lib/behat/behat_field_manager.php b/lib/behat/behat_field_manager.php
index 5d0366d411c..a53d0e1a430 100644
--- a/lib/behat/behat_field_manager.php
+++ b/lib/behat/behat_field_manager.php
@@ -159,13 +159,12 @@ class behat_field_manager {
case 'password':
case 'email':
case 'file':
+ case 'number':
return 'text';
case 'checkbox':
return 'checkbox';
- break;
case 'radio':
return 'radio';
- break;
default:
// Here we return false because all text-based
// fields should be included in the first switch case.