MDL-56753 mod_assign: fix groups and submitted counting on grading summary

This also fixes a coding error that was displayed when a group was not part of
assignment grouping.
This commit is contained in:
Simey Lameze 2016-11-08 09:40:18 +08:00
parent b8af6c1ef0
commit 426bb5ae0f

View File

@ -1903,6 +1903,10 @@ class assign {
$count += 1;
}
}
} else if ($activitygroup != 0 && empty($groups)) {
// Set count to 1 if $groups returns empty.
// It means the group is not part of $this->get_instance()->teamsubmissiongroupingid.
$count = 1;
}
} else {
// It is faster to loop around participants if no grouping was specified.
@ -2074,6 +2078,12 @@ class assign {
array_keys($participants),
$this->get_instance()->teamsubmissiongroupingid,
'DISTINCT g.id, g.name');
if (empty($groups)) {
// If $groups is empty it means it is not part of $this->get_instance()->teamsubmissiongroupingid.
// All submissions from students that do not belong to any of teamsubmissiongroupingid groups
// count towards groupid = 0. Setting to true as only '0' key matters.
$groups = [true];
}
list($groupssql, $groupsparams) = $DB->get_in_or_equal(array_keys($groups), SQL_PARAMS_NAMED);
$groupsstr = 's.groupid ' . $groupssql . ' AND';
$params = $params + $groupsparams;