mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-57296 gradebook: Fix issue with gradebook while collapsing grades
This commit is contained in:
parent
5130953c8a
commit
bba75cb186
@ -45,6 +45,13 @@ class grade_report_grader extends grade_report {
|
||||
*/
|
||||
private $allgrades;
|
||||
|
||||
/**
|
||||
* Contains all grade items expect GRADE_TYPE_NONE.
|
||||
*
|
||||
* @var array $allgradeitems
|
||||
*/
|
||||
private $allgradeitems;
|
||||
|
||||
/**
|
||||
* Array of errors for bulk grades updating.
|
||||
* @var array $gradeserror
|
||||
@ -519,6 +526,22 @@ class grade_report_grader extends grade_report {
|
||||
return $this->users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all grade items.
|
||||
*/
|
||||
protected function get_allgradeitems() {
|
||||
if (!empty($this->allgradeitems)) {
|
||||
return $this->allgradeitems;
|
||||
}
|
||||
$allgradeitems = grade_item::fetch_all(array('courseid' => $this->courseid));
|
||||
// But hang on - don't include ones which are set to not show the grade at all.
|
||||
$this->allgradeitems = array_filter($allgradeitems, function($item) {
|
||||
return $item->gradetype != GRADE_TYPE_NONE;
|
||||
});
|
||||
|
||||
return $this->allgradeitems;
|
||||
}
|
||||
|
||||
/**
|
||||
* we supply the userids in this query, and get all the grades
|
||||
* pulls out all the grades, this does not need to worry about paging
|
||||
@ -567,6 +590,19 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pre fill grades for any remaining items which might be collapsed.
|
||||
$allgradeitems = $this->get_allgradeitems();
|
||||
foreach ($userids as $userid) {
|
||||
foreach ($allgradeitems as $itemid => $gradeitem) {
|
||||
if (!isset($this->allgrades[$userid][$itemid])) {
|
||||
$this->allgrades[$userid][$itemid] = new grade_grade();
|
||||
$this->allgrades[$userid][$itemid]->itemid = $itemid;
|
||||
$this->allgrades[$userid][$itemid]->userid = $userid;
|
||||
$this->allgrades[$userid][$itemid]->grade_item = $gradeitem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -918,12 +954,7 @@ class grade_report_grader extends grade_report {
|
||||
// grade items (in case one has been hidden) as the course total shown needs to be adjusted for this particular
|
||||
// user.
|
||||
if (!$this->canviewhidden) {
|
||||
$allgradeitems = grade_item::fetch_all(array('courseid' => $this->courseid));
|
||||
|
||||
// But hang on - don't include ones which are set to not show the grade at all.
|
||||
$allgradeitems = array_filter($allgradeitems, function($item) {
|
||||
return $item->gradetype != GRADE_TYPE_NONE;
|
||||
});
|
||||
$allgradeitems = $this->get_allgradeitems();
|
||||
}
|
||||
|
||||
foreach ($this->users as $userid => $user) {
|
||||
|
@ -12,6 +12,7 @@ Feature: We can change what we are viewing on the grader report
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 1 | student2@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
@ -94,6 +95,9 @@ Feature: We can change what we are viewing on the grader report
|
||||
| capability | permission |
|
||||
| moodle/grade:viewhidden | Prevent |
|
||||
And I log out
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I navigate to "View > Grader report" in the course gradebook
|
||||
|
Loading…
x
Reference in New Issue
Block a user