Skip to content

Commit

Permalink
Merge branch 'MDL-79062-403-2' of https://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
… into MOODLE_403_STABLE
  • Loading branch information
HuongNV13 committed Nov 6, 2023
2 parents be7a698 + 60a1c97 commit d3bc17f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 66 deletions.
19 changes: 12 additions & 7 deletions grade/report/grader/lib.php
Expand Up @@ -771,8 +771,6 @@ public function get_right_rows(bool $displayaverages) : array {

$rows = [];
$this->rowcount = 0;
$numusers = count($this->users);
$gradetabindex = 1;
$strgrade = get_string('gradenoun');
$this->get_sort_arrows();

Expand All @@ -789,14 +787,11 @@ public function get_right_rows(bool $displayaverages) : array {

// Preload scale objects for items with a scaleid and initialize tab indices.
$scaleslist = [];
$tabindices = [];

foreach ($this->gtree->get_items() as $itemid => $item) {
if (!empty($item->scaleid)) {
$scaleslist[] = $item->scaleid;
}
$tabindices[$item->id]['grade'] = $gradetabindex;
$gradetabindex += $numusers * 2;
}

$cache = \cache::make_from_params(\cache_store::MODE_REQUEST, 'gradereport_grader', 'scales');
Expand Down Expand Up @@ -1061,7 +1056,6 @@ public function get_right_rows(bool $displayaverages) : array {
$nogradestr = get_string('nooutcome', 'grades');
}
$attributes = [
'tabindex' => $tabindices[$item->id]['grade'],
'id' => 'grade_' . $userid . '_' . $item->id
];
$gradelabel = $fullname . ' ' . $item->get_name(true);
Expand Down Expand Up @@ -1093,6 +1087,18 @@ public function get_right_rows(bool $displayaverages) : array {
// 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);

Expand All @@ -1101,7 +1107,6 @@ public function get_right_rows(bool $displayaverages) : array {
$context->value = $value;
$context->label = get_string('useractivitygrade', 'gradereport_grader', $gradelabel);
$context->title = $strgrade;
$context->tabindex = $tabindices[$item->id]['grade'];
$context->extraclasses = 'form-control';
if ($context->statusicons) {
$context->extraclasses .= ' statusicons';
Expand Down
8 changes: 6 additions & 2 deletions grade/templates/cellmenu.mustache
Expand Up @@ -65,12 +65,16 @@
<div class="dropdown-divider" role="separator"></div>
{{/divider1}}
{{#ascendingfirstnameurl}}
<h6 class="dropdown-header">{{#str}} firstname, moodle {{/str}}</h6>
<div role="group" aria-label="{{#str}} sortbyfirstname, core_grades {{/str}}">
<div class="h6 dropdown-header">{{#str}} firstname, moodle {{/str}}</div>
{{{ascendingfirstnameurl}}}
{{{descendingfirstnameurl}}}
<h6 class="dropdown-header">{{#str}} lastname, moodle {{/str}}</h6>
</div>
<div role="group" aria-label="{{#str}} sortbylastname, core_grades {{/str}}">
<div class="h6 dropdown-header">{{#str}} lastname, moodle {{/str}}</div>
{{{ascendinglastnameurl}}}
{{{descendinglastnameurl}}}
</div>
{{/ascendingfirstnameurl}}
{{#ascendingurl}}
{{{ascendingurl}}}
Expand Down
3 changes: 2 additions & 1 deletion grade/templates/grades/grader/input.mustache
Expand Up @@ -31,4 +31,5 @@
}
}}
<label for="{{id}}" class="accesshide">{{{label}}}</label>
<input id="{{id}}" name="{{name}}" type="text" value="{{value}}" title="{{title}}" class="{{extraclasses}}" tabindex="{{tabindex}}">
<input id="{{id}}" name="{{name}}" type="{{#isnumeric}}number{{/isnumeric}}{{^isnumeric}}text{{/isnumeric}}" value="{{value}}" title="{{title}}" class="{{extraclasses}}" {{!
}} {{#minvalue}}min="{{.}}" {{/minvalue}} {{#maxvalue}}max="{{.}}" {{/maxvalue}} {{#isnumeric}}step="any"{{/isnumeric}}>
8 changes: 4 additions & 4 deletions grade/tests/behat/grade_UI_settings.feature
Expand Up @@ -36,9 +36,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
71 changes: 19 additions & 52 deletions grade/tests/behat/grade_mingrade.feature
Expand Up @@ -19,64 +19,31 @@ 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 choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 1 |
| Minimum grade | -100 |
| Grade category | Course 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 2 |
| Minimum grade | 50 |
| Grade category | Course 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I choose the "Add grade item" item in the "Add" action menu
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 click on "Save" "button" in the "New grade item" "dialogue"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 4 |
| Minimum grade | -100 |
| Grade category | Sub category 1 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 5 |
| Minimum grade | 50 |
| Grade category | Sub category 2 |
And I click on "Save" "button" in the "New grade item" "dialogue"
And I choose the "Add grade item" item in the "Add" action menu
And I set the following fields to these values:
| Item name | Manual item 6 |
| Minimum grade | 50 |
| Grade category | Sub category 2 |
And I click on "Save" "button" in the "New grade item" "dialogue"
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"
And I press "Save changes"

@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" of type "category" on "setup" page:
| Aggregation | Natural |
| Exclude empty grades | 0 |
And I set the following settings for grade item "Sub category 2" of type "category" on "setup" page:
| 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" of type "course" on "setup" page:
| Aggregation | Natural |
| Exclude empty grades | 0 |
Expand All @@ -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
Expand Down

0 comments on commit d3bc17f

Please sign in to comment.