mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-50524' of https://github.com/andrewhancox/moodle
This commit is contained in:
commit
1a5f8df5c0
@ -278,6 +278,7 @@ When reviewing assignments, teachers can leave feedback comments and upload file
|
||||
$string['modulename_link'] = 'mod/assignment/view';
|
||||
$string['modulenameplural'] = 'Assignments';
|
||||
$string['moreusers'] = '{$a} more...';
|
||||
$string['multipleteams'] = 'You\'re a member of multiple groups, please contact your teacher.';
|
||||
$string['mysubmission'] = 'My submission: ';
|
||||
$string['newsubmissions'] = 'Assignments submitted';
|
||||
$string['noattempt'] = 'No attempt';
|
||||
@ -434,7 +435,7 @@ $string['teamsubmissiongroupingid_help'] = 'This is the grouping that the assign
|
||||
$string['textinstructions'] = 'Assignment instructions';
|
||||
$string['timemodified'] = 'Last modified';
|
||||
$string['timeremaining'] = 'Time remaining';
|
||||
$string['ungroupedusers'] = 'The setting \'Require group to make submission\' is turned on and some users are not allocated to groups, this will prevent them from submitting assignments.';
|
||||
$string['ungroupedusers'] = 'The setting \'Require group to make submission\' is turned on and some users are not allocated to groups or are allocated to multiple groups, this will prevent them from submitting assignments.';
|
||||
$string['unlocksubmissionforstudent'] = 'Allow submissions for student: (id={$a->id}, fullname={$a->fullname}).';
|
||||
$string['unlocksubmissions'] = 'Unlock submissions';
|
||||
$string['unlimitedattempts'] = 'Unlimited';
|
||||
|
@ -146,6 +146,9 @@ class assign {
|
||||
/** @var array cached list of user groups when team submissions are enabled. The cache key will be the user. */
|
||||
private $usersubmissiongroups = array();
|
||||
|
||||
/** @var array cached list of user groups. The cache key will be the user. */
|
||||
private $usergroups = array();
|
||||
|
||||
/**
|
||||
* Constructor for the base assign class.
|
||||
*
|
||||
@ -2301,8 +2304,7 @@ class assign {
|
||||
return $this->usersubmissiongroups[$userid];
|
||||
}
|
||||
|
||||
$grouping = $this->get_instance()->teamsubmissiongroupingid;
|
||||
$groups = groups_get_all_groups($this->get_course()->id, $userid, $grouping);
|
||||
$groups = $this->get_all_groups($userid);
|
||||
if (count($groups) != 1) {
|
||||
$return = false;
|
||||
} else {
|
||||
@ -2315,6 +2317,19 @@ class assign {
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function get_all_groups($userid) {
|
||||
if (isset($this->usergroups[$userid])) {
|
||||
return $this->usergroups[$userid];
|
||||
}
|
||||
|
||||
$grouping = $this->get_instance()->teamsubmissiongroupingid;
|
||||
$return = groups_get_all_groups($this->get_course()->id, $userid, $grouping);
|
||||
|
||||
$this->usergroups[$userid] = $return;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the submission that is used by a plugin.
|
||||
@ -3033,6 +3048,7 @@ class assign {
|
||||
}
|
||||
$showedit = $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled());
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context());
|
||||
$usergroups = $this->get_all_groups($user->id);
|
||||
|
||||
$submissionstatus = new assign_submission_status($instance->allowsubmissionsfromdate,
|
||||
$instance->alwaysshowdescription,
|
||||
@ -3062,7 +3078,8 @@ class assign {
|
||||
$instance->attemptreopenmethod,
|
||||
$instance->maxattempts,
|
||||
$this->get_grading_status($userid),
|
||||
$instance->preventsubmissionnotingroup);
|
||||
$instance->preventsubmissionnotingroup,
|
||||
$usergroups);
|
||||
$o .= $this->get_renderer()->render($submissionstatus);
|
||||
}
|
||||
|
||||
@ -3939,6 +3956,7 @@ class assign {
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context());
|
||||
|
||||
$gradingstatus = $this->get_grading_status($user->id);
|
||||
$usergroups = $this->get_all_groups($user->id);
|
||||
$submissionstatus = new assign_submission_status($instance->allowsubmissionsfromdate,
|
||||
$instance->alwaysshowdescription,
|
||||
$submission,
|
||||
@ -3967,7 +3985,8 @@ class assign {
|
||||
$instance->attemptreopenmethod,
|
||||
$instance->maxattempts,
|
||||
$gradingstatus,
|
||||
$instance->preventsubmissionnotingroup);
|
||||
$instance->preventsubmissionnotingroup,
|
||||
$usergroups);
|
||||
if (has_capability('mod/assign:submit', $this->get_context(), $user)) {
|
||||
$o .= $this->get_renderer()->render($submissionstatus);
|
||||
}
|
||||
|
@ -388,6 +388,8 @@ class assign_submission_status implements renderable {
|
||||
public $gradingstatus = '';
|
||||
/** @var bool preventsubmissionnotingroup */
|
||||
public $preventsubmissionnotingroup = 0;
|
||||
/** @var array usergroups */
|
||||
public $usergroups = array();
|
||||
|
||||
|
||||
/**
|
||||
@ -422,6 +424,7 @@ class assign_submission_status implements renderable {
|
||||
* @param int $maxattempts - How many attempts can a student make?
|
||||
* @param string $gradingstatus - The submission status (ie. Graded, Not Released etc).
|
||||
* @param bool $preventsubmissionnotingroup - Prevent submission if user is not in a group
|
||||
* @param array $usergroups - Array containing all groups the user is assigned to
|
||||
*/
|
||||
public function __construct($allowsubmissionsfromdate,
|
||||
$alwaysshowdescription,
|
||||
@ -451,7 +454,8 @@ class assign_submission_status implements renderable {
|
||||
$attemptreopenmethod,
|
||||
$maxattempts,
|
||||
$gradingstatus,
|
||||
$preventsubmissionnotingroup) {
|
||||
$preventsubmissionnotingroup,
|
||||
$usergroups) {
|
||||
$this->allowsubmissionsfromdate = $allowsubmissionsfromdate;
|
||||
$this->alwaysshowdescription = $alwaysshowdescription;
|
||||
$this->submission = $submission;
|
||||
@ -481,6 +485,7 @@ class assign_submission_status implements renderable {
|
||||
$this->maxattempts = $maxattempts;
|
||||
$this->gradingstatus = $gradingstatus;
|
||||
$this->preventsubmissionnotingroup = $preventsubmissionnotingroup;
|
||||
$this->usergroups = $usergroups;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,11 @@ class mod_assign_renderer extends plugin_renderer_base {
|
||||
if ($group) {
|
||||
$cell2 = new html_table_cell(format_string($group->name, false, $status->context));
|
||||
} else if ($status->preventsubmissionnotingroup) {
|
||||
$cell2 = new html_table_cell(get_string('noteam', 'assign'));
|
||||
if (count($status->usergroups) == 0) {
|
||||
$cell2 = new html_table_cell(get_string('noteam', 'assign'));
|
||||
} else if (count($status->usergroups) > 1) {
|
||||
$cell2 = new html_table_cell(get_string('multipleteams', 'assign'));
|
||||
}
|
||||
} else {
|
||||
$cell2 = new html_table_cell(get_string('defaultteam', 'assign'));
|
||||
}
|
||||
|
@ -9,19 +9,24 @@ Feature: Submit assignment without group
|
||||
| fullname | shortname | category | groupmode |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
| Course 2 | C2 | 0 | 1 |
|
||||
| Course 3 | C3 | 0 | 1 |
|
||||
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 |
|
||||
| assign | C1 | assign2 | Require group membership | Test assignment description | 1 | 1 | 1 |
|
||||
| assign | C2 | assign2 | Require group membership | Test assignment description | 1 | 1 | 1 |
|
||||
| assign | C3 | assign2 | Require group membership | Test assignment description | 1 | 1 | 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 |
|
||||
| student3 | Student | 3 | student3@example.com |
|
||||
And the following "groups" exist:
|
||||
| name | course | idnumber |
|
||||
| Group 1 | C2 | G1 |
|
||||
| Group 1 | C3 | G1 |
|
||||
| Group 2 | C3 | G2 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
@ -30,12 +35,20 @@ Feature: Submit assignment without group
|
||||
| teacher1 | C2 | editingteacher |
|
||||
| student1 | C2 | student |
|
||||
| student2 | C2 | student |
|
||||
| teacher1 | C3 | editingteacher |
|
||||
| student3 | C3 | student |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 2"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
And I add "Student 1 (student1@example.com)" user to "Group 1" group members
|
||||
And I add "Student 2 (student2@example.com)" user to "Group 1" group members
|
||||
And I am on homepage
|
||||
And I follow "Course 3"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
And I add "Student 3 (student3@example.com)" user to "Group 1" group members
|
||||
And I add "Student 3 (student3@example.com)" user to "Group 2" group members
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
@ -80,7 +93,7 @@ Feature: Submit assignment without group
|
||||
And I follow "Course 1"
|
||||
And I follow "Allow default group"
|
||||
And I should see "1" in the "Groups" "table_row"
|
||||
And I should not see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups, this will prevent them from submitting assignments."
|
||||
And I should not see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups or are allocated to multiple groups, this will prevent them from submitting assignments."
|
||||
And I follow "View/grade all submissions"
|
||||
And I should see "Default group" in the "Student 1" "table_row"
|
||||
And I should see "Default group" in the "Student 2" "table_row"
|
||||
@ -90,7 +103,7 @@ Feature: Submit assignment without group
|
||||
And I follow "Course 1"
|
||||
And I follow "Require group membership"
|
||||
And I should see "0" in the "Groups" "table_row"
|
||||
And I should see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups, this will prevent them from submitting assignments."
|
||||
And I should see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups or are allocated to multiple groups, this will prevent them from submitting assignments."
|
||||
And I follow "View/grade all submissions"
|
||||
And I should see "Default group" in the "Student 1" "table_row"
|
||||
And I should see "Default group" in the "Student 2" "table_row"
|
||||
@ -100,9 +113,21 @@ Feature: Submit assignment without group
|
||||
And I follow "Course 2"
|
||||
And I follow "Require group membership"
|
||||
And I should see "1" in the "Groups" "table_row"
|
||||
And I should not see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups, this will prevent them from submitting assignments."
|
||||
And I should not see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups or are allocated to multiple groups, this will prevent them from submitting assignments."
|
||||
And I follow "View/grade all submissions"
|
||||
And I should see "Group 1" in the "Student 1" "table_row"
|
||||
And I should see "Group 1" in the "Student 2" "table_row"
|
||||
And I should see "Submitted for grading" in the "Student 1" "table_row"
|
||||
And I should see "Submitted for grading" in the "Student 2" "table_row"
|
||||
And I log out
|
||||
When I log in as "student3"
|
||||
And I follow "Course 3"
|
||||
And I follow "Require group membership"
|
||||
Then I should see "You're a member of multiple groups, please contact your teacher."
|
||||
And I should see "Nothing has been submitted for this assignment"
|
||||
And I should not see "Add submission"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Require group membership"
|
||||
And I should see "The setting 'Require group to make submission' is turned on and some users are not allocated to groups or are allocated to multiple groups, this will prevent them from submitting assignments."
|
Loading…
x
Reference in New Issue
Block a user