From 426bb5ae0fe1a8e87899359fbcc151f2aa25f6b1 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 8 Nov 2016 09:40:18 +0800 Subject: [PATCH 1/2] 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; From 763f7b05ae769b2023bd116732e67735f2f52756 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Thu, 10 Nov 2016 09:59:11 +0800 Subject: [PATCH 2/2] MDL-56753 mod_assign: behat tests for groups and grouping counting --- .../tests/behat/group_submission.feature | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/mod/assign/tests/behat/group_submission.feature b/mod/assign/tests/behat/group_submission.feature index 4826a18742a..dc6a8d6071a 100644 --- a/mod/assign/tests/behat/group_submission.feature +++ b/mod/assign/tests/behat/group_submission.feature @@ -135,3 +135,100 @@ Feature: Group assignment submissions And "Student 2" row "Status" column of "generaltable" table should contain "Submitted for grading" And "Student 3" row "Status" column of "generaltable" table should contain "Submitted for grading" And "Student 4" row "Status" column of "generaltable" table should contain "Submitted for grading" + + Scenario: Confirm groups and submission counts are correct + Given the following "courses" exist: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@example.com | + | student2 | Student | 2 | student2@example.com | + | student3 | Student | 3 | student3@example.com | + | student4 | Student | 4 | student4@example.com | + | student5 | Student | 5 | student5@example.com | + | student6 | Student | 6 | student6@example.com | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student2 | C1 | student | + | student3 | C1 | student | + | student4 | C1 | student | + | student5 | C1 | student | + | student6 | C1 | student | + And the following "groups" exist: + | name | course | idnumber | + | Group 1 | C1 | G1 | + | Group 2 | C1 | G2 | + | Group 3 | C1 | G3 | + And the following "group members" exist: + | user | group | + | student1 | G1 | + | student2 | G1 | + | student3 | G2 | + | student4 | G2 | + | student5 | G3 | + | student6 | G3 | + And the following "groupings" exist: + | name | course | idnumber | + | Grouping 1 | C1 | GG1 | + And the following "grouping groups" exist: + | grouping | group | + | GG1 | G1 | + | GG1 | G2 | + And I log in as "admin" + And I am on site homepage + And I follow "Course 1" + And I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test assignment name | + | Description | Test assignment description | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 0 | + | Students submit in groups | Yes | + | Grouping for student groups | Grouping 1 | + | Group mode | Separate groups | + | Require group to make submission | No | + And I log out + And I log in as "student1" + And I follow "Course 1" + And I follow "Test assignment name" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student's 1 submission | + And I press "Save changes" + And I log out + And I log in as "student3" + And I follow "Course 1" + And I follow "Test assignment name" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student's 3 submission | + And I press "Save changes" + And I log out + And I log in as "student5" + And I follow "Course 1" + And I follow "Test assignment name" + And I press "Add submission" + And I set the following fields to these values: + | Online text | I'm the student's 5 submission | + And I press "Save changes" + And I log out + And I log in as "admin" + And I am on site homepage + And I follow "Course 1" + And I follow "Test assignment name" + And I should see "3" in the "Groups" "table_row" + And I should see "3" in the "Submitted" "table_row" + When I set the field "Separate groups" to "Group 1" + And I press "Go" + Then I should see "1" in the "Groups" "table_row" + And I should see "1" in the "Submitted" "table_row" + And I set the field "Separate groups" to "Group 2" + And I press "Go" + And I should see "1" in the "Groups" "table_row" + And I should see "1" in the "Submitted" "table_row" + And I set the field "Separate groups" to "Group 3" + And I press "Go" + And I should see "1" in the "Groups" "table_row" + And I should see "1" in the "Submitted" "table_row"