LEFT JOIN {assign_submission} s
ON u.id = s.userid
AND s.assignment = :assignmentid1
- AND s.latest = 1
- LEFT JOIN {assign_grades} g
- ON u.id = g.userid
- AND g.assignment = :assignmentid2 ';
+ AND s.latest = 1 ';
- // For group submissions we don't immediately create an entry in the assign_submission table for each user,
- // instead the userid is set to 0. In this case we use a different query to retrieve the grade for the user.
- if ($this->assignment->get_instance()->teamsubmission) {
- $params['assignmentid4'] = (int) $this->assignment->get_instance()->id;
- $grademaxattempt = 'SELECT mxg.userid, MAX(mxg.attemptnumber) AS maxattempt
- FROM {assign_grades} mxg
- WHERE mxg.assignment = :assignmentid4
- GROUP BY mxg.userid';
- $from .= 'LEFT JOIN (' . $grademaxattempt . ') gmx
- ON u.id = gmx.userid
- AND g.attemptnumber = gmx.maxattempt ';
- } else {
- $from .= 'AND g.attemptnumber = s.attemptnumber ';
- }
+ // For group assignments, there can be a grade with no submission.
+ $from .= ' LEFT JOIN {assign_grades} g
+ ON g.assignment = :assignmentid2
+ AND u.id = g.userid
+ AND (g.attemptnumber = s.attemptnumber OR s.attemptnumber IS NULL) ';
$from .= 'LEFT JOIN {assign_user_flags} uf
ON u.id = uf.userid
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"
+ @javascript
+ Scenario: Confirm that group submissions can be reopened
+ Given the following "courses" exist:
+ | fullname | shortname | category | groupmode |
+ | Course 1 | C1 | 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 |
+ | student3 | Student | 3 | student3@example.com |
+ | student4 | Student | 4 | student4@example.com |
+ And the following "course enrolments" exist:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+ | student1 | C1 | student |
+ | student2 | C1 | student |
+ | student3 | C1 | student |
+ | student4 | C1 | student |
+ And the following "groups" exist:
+ | name | course | idnumber |
+ | Group 1 | C1 | G1 |
+ And the following "group members" exist:
+ | user | group |
+ | student1 | G1 |
+ | student2 | G1 |
+ And I log in as "teacher1"
+ And I am on "Course 1" course homepage with 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 |
+ | Attempts reopened | Manually |
+ | Group mode | No groups |
+ | Require group to make submission | No |
+ And I log out
+ And I log in as "student1"
+ And I am on "Course 1" course homepage
+ 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 first submission |
+ And I press "Save changes"
+ And I log out
+ And I log in as "teacher1"
+ And I am on "Course 1" course homepage
+ And I follow "Test assignment name"
+ And I navigate to "View all submissions" in current page administration
+ And I click on "Grade" "link" in the "Student 1" "table_row"
+ And I set the following fields to these values:
+ | Grade out of 100 | 50.0 |
+ | Apply grades and feedback to entire group | 1 |
+ And I press "Save changes"
+ And I press "Ok"
+ And I set the following fields to these values:
+ | Allow another attempt | 1 |
+ And I press "Save changes"
+ And I press "Ok"
+ When I am on "Course 1" course homepage
+ And I follow "Test assignment name"
+ And I navigate to "View all submissions" in current page administration
+ Then "Student 1" row "Status" column of "generaltable" table should contain "Reopened"
+ And "Student 2" row "Status" column of "generaltable" table should contain "Reopened"
+
Scenario: Confirm groups and submission counts are correct
Given the following "courses" exist:
| fullname | shortname | category | groupmode |