Skip to content

Commit

Permalink
MDL-64811 mod_assign: warn about 'Default group' submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
davosmith committed Jun 17, 2019
1 parent 5dae8c0 commit 74ddcaa
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 3 deletions.
1 change: 1 addition & 0 deletions mod/assign/lang/en/assign.php
Expand Up @@ -576,6 +576,7 @@
$string['timeremainingcolon'] = 'Time remaining: {$a}';
$string['togglezoom'] = 'Zoom in/out of region';
$string['ungroupedusers'] = 'The setting \'Require group to make submission\' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions.';
$string['ungroupedusersoptional'] = 'The setting \'Students submit in groups\' is enabled and some users are either not a member of any group, or are a member of more than one group. Please be aware that these students will submit as members of the \'Default group\'.';
$string['unlocksubmissionforstudent'] = 'Allow submissions for student: (id={$a->id}, fullname={$a->fullname}).';
$string['unlocksubmissions'] = 'Unlock submissions';
$string['unlimitedattempts'] = 'Unlimited';
Expand Down
11 changes: 9 additions & 2 deletions mod/assign/locallib.php
Expand Up @@ -5532,8 +5532,15 @@ public function get_assign_grading_summary_renderable($activitygroup = null) {
}

if ($instance->teamsubmission) {
$warnofungroupedusers = assign_grading_summary::WARN_GROUPS_NO;
$defaultteammembers = $this->get_submission_group_members(0, true);
$warnofungroupedusers = (count($defaultteammembers) > 0 && $instance->preventsubmissionnotingroup);
if (count($defaultteammembers) > 0) {
if ($instance->preventsubmissionnotingroup) {
$warnofungroupedusers = assign_grading_summary::WARN_GROUPS_REQUIRED;
} else {
$warnofungroupedusers = assign_grading_summary::WARN_GROUPS_OPTIONAL;
}
}

$summary = new assign_grading_summary($this->count_teams($activitygroup),
$instance->submissiondrafts,
Expand Down Expand Up @@ -5561,7 +5568,7 @@ public function get_assign_grading_summary_renderable($activitygroup = null) {
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
false,
assign_grading_summary::WARN_GROUPS_NO,
$this->can_grade(),
$isvisible);
}
Expand Down
8 changes: 8 additions & 0 deletions mod/assign/renderable.php
Expand Up @@ -753,6 +753,13 @@ class assign_grading_summary implements renderable {
/** @var boolean isvisible - Is the assignment's context module visible to students? */
public $isvisible = true;

/** @var string no warning needed about group submissions */
const WARN_GROUPS_NO = 'nowarning';
/** @var string warn about group submissions, as groups are required */
const WARN_GROUPS_REQUIRED = 'warnrequired';
/** @var string warn about group submissions, as some will submit as 'Default group' */
const WARN_GROUPS_OPTIONAL = 'warnoptional';

/**
* constructor
*
Expand All @@ -766,6 +773,7 @@ class assign_grading_summary implements renderable {
* @param int $coursemoduleid
* @param int $submissionsneedgradingcount
* @param bool $teamsubmission
* @param string $warnofungroupedusers
* @param bool $cangrade
* @param bool $isvisible
*/
Expand Down
4 changes: 3 additions & 1 deletion mod/assign/renderer.php
Expand Up @@ -279,8 +279,10 @@ public function render_assign_grading_summary(assign_grading_summary $summary) {

// Status.
if ($summary->teamsubmission) {
if ($summary->warnofungroupedusers) {
if ($summary->warnofungroupedusers === assign_grading_summary::WARN_GROUPS_REQUIRED) {
$o .= $this->output->notification(get_string('ungroupedusers', 'assign'));
} else if ($summary->warnofungroupedusers === assign_grading_summary::WARN_GROUPS_OPTIONAL) {
$o .= $this->output->notification(get_string('ungroupedusersoptional', 'assign'));
}

$this->add_table_row_tuple($t, get_string('numberofteams', 'assign'),
Expand Down
93 changes: 93 additions & 0 deletions mod/assign/tests/behat/submit_without_group.feature
Expand Up @@ -129,3 +129,96 @@ Feature: Submit assignment without group
And I should see "The setting 'Require group to make submission' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions."
And I navigate to "View all submissions" in current page administration
And I should see "Member of more than one group, so unable to make submissions." in the "Student 3" "table_row"

Scenario: All users are in groups, so no warning messages needed.
Given the following "courses" exist:
| fullname | shortname | groupmode |
| Course 1 | C1 | 0 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | preventsubmissionnotingroup | teamsubmission |
| assign | C1 | assign1 | Allow default group | Test assignment description | 1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G2 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Allow default group"
Then I should not see "The setting 'Require group to make submission\' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions."
And I should not see "The setting 'Students submit in groups' is enabled and some users are either not a member of any group, or are a member of more than one group. Please be aware that these students will submit as members of the 'Default group'."

Scenario: One user is not in a group, so should see a warning about default group submission
Given the following "courses" exist:
| fullname | shortname | groupmode |
| Course 1 | C1 | 0 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | preventsubmissionnotingroup | teamsubmission |
| assign | C1 | assign1 | Allow default group | Test assignment description | 1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Allow default group"
Then I should not see "The setting 'Require group to make submission\' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions."
And I should see "The setting 'Students submit in groups' is enabled and some users are either not a member of any group, or are a member of more than one group. Please be aware that these students will submit as members of the 'Default group'."

Scenario: One user is a member of multiple groups, so should see a warning about default group submission
Given the following "courses" exist:
| fullname | shortname | groupmode |
| Course 1 | C1 | 0 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | preventsubmissionnotingroup | teamsubmission |
| assign | C1 | assign1 | Allow default group | Test assignment description | 1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "group members" exist:
| user | group |
| student1 | G1 |
| student2 | G1 |
| student2 | G2 |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Allow default group"
Then I should not see "The setting 'Require group to make submission\' is enabled and some users are either not a member of any group, or are a member of more than one group, so are unable to make submissions."
And I should see "The setting 'Students submit in groups' is enabled and some users are either not a member of any group, or are a member of more than one group. Please be aware that these students will submit as members of the 'Default group'."

0 comments on commit 74ddcaa

Please sign in to comment.