MDL-64811 mod_assign: warn about 'Default group' submissions

This commit is contained in:
Davo Smith 2019-06-17 15:30:47 +01:00
parent 5dae8c0515
commit 74ddcaaa6f
5 changed files with 114 additions and 3 deletions

View File

@ -576,6 +576,7 @@ $string['timeremaining'] = 'Time remaining';
$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';

View File

@ -5532,8 +5532,15 @@ class assign {
}
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,
@ -5561,7 +5568,7 @@ class assign {
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
false,
assign_grading_summary::WARN_GROUPS_NO,
$this->can_grade(),
$isvisible);
}

View File

@ -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
*
@ -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
*/

View File

@ -279,8 +279,10 @@ class mod_assign_renderer extends plugin_renderer_base {
// 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'),

View File

@ -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'."