Skip to content

Commit

Permalink
MDL-64161 gradereport_singleview: Single updates reported correctly.
Browse files Browse the repository at this point in the history
If there is an error with the update of individual entries this is
also correctly displayed as not being updated.
  • Loading branch information
abgreeve committed Nov 27, 2018
1 parent 3e2b8b2 commit 5c9bc96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions grade/report/singleview/classes/local/screen/screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ public function process($data) {
$progressbar->start_html();
$progressbar->start_progress(get_string('savegrades', 'gradereport_singleview'), count((array) $data) - 1);
$changecount = array();
// This array is used to determine if the override should be excluded from being counted as a change.
$ignorevalues = [];

foreach ($data as $varname => $throw) {
$progressbar->progress($progress);
Expand Down Expand Up @@ -351,15 +353,23 @@ public function process($data) {
}

$msg = $element->set($posted);
// Value to check against our list of matchelements to ignore.
$check = explode('_', $varname, 2);

// Optional type.
if (!empty($msg)) {
$warnings[] = $msg;
if ($element instanceof \gradereport_singleview\local\ui\finalgrade) {
// Add this value to this list so that the override object that is coming next will also be skipped.
$ignorevalues[$check[1]] = $check[1];
// This item wasn't changed so don't add to the changecount.
continue;
}
}
// Check to see if this value has already been skipped.
if (array_key_exists($check[1], $ignorevalues)) {
continue;
}
if (preg_match('/_(\d+)_(\d+)/', $varname, $matchelement)) {
$changecount[$matchelement[0]] = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion grade/report/singleview/tests/behat/singleview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Feature: We can use Single view
And I set the field "Insert value" to "1.0"
And I set the field "Perform bulk insert" to "1"
And I press "Save"
Then I should see "Grades were set for 8 items"
Then I should see "Grades were set for 6 items"

Scenario: Navigation works in the Single view.
Given I follow "Single view for Student 1"
Expand Down

0 comments on commit 5c9bc96

Please sign in to comment.