From 426bb5ae0fe1a8e87899359fbcc151f2aa25f6b1 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 8 Nov 2016 09:40:18 +0800 Subject: [PATCH] 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. --- mod/assign/locallib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 8c4aacebcac..4dae25332af 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -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; -- 2.11.4.GIT