From 99af155ddd5d57d79f222dd97d8e777dd7b4c96c Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 30 Aug 2021 01:38:17 +1000 Subject: [PATCH] MDL-66203 mod_assign: Reset submission status when removing a submission --- mod/assign/locallib.php | 12 ++++++++++-- mod/assign/tests/behat/remove_submission.feature | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 0340384af32..9a827cf64f8 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -5947,7 +5947,7 @@ class assign { $allsubmitted = true; $anysubmitted = false; $result = true; - if ($submission->status != ASSIGN_SUBMISSION_STATUS_REOPENED) { + if (!in_array($submission->status, [ASSIGN_SUBMISSION_STATUS_NEW, ASSIGN_SUBMISSION_STATUS_REOPENED])) { foreach ($team as $member) { $membersubmission = $this->get_user_submission($member->id, false, $submission->attemptnumber); @@ -5981,7 +5981,7 @@ class assign { // Set the group submission to reopened. foreach ($team as $member) { $membersubmission = $this->get_user_submission($member->id, true, $submission->attemptnumber); - $membersubmission->status = ASSIGN_SUBMISSION_STATUS_REOPENED; + $membersubmission->status = $submission->status; $result = $DB->update_record('assign_submission', $membersubmission) && $result; } $result = $DB->update_record('assign_submission', $submission) && $result; @@ -8083,6 +8083,8 @@ class assign { if (!$submission) { return false; } + $submission->status = $submission->attemptnumber ? ASSIGN_SUBMISSION_STATUS_REOPENED : ASSIGN_SUBMISSION_STATUS_NEW; + $this->update_submission($submission, $userid, false, $this->get_instance()->teamsubmission); // Tell each submission plugin we were saved with no data. $plugins = $this->get_submission_plugins(); @@ -8092,6 +8094,12 @@ class assign { } } + $completion = new completion_info($this->get_course()); + if ($completion->is_enabled($this->get_course_module()) && + $this->get_instance()->completionsubmit) { + $completion->update_state($this->get_course_module(), COMPLETION_INCOMPLETE, $userid); + } + if ($submission->userid != 0) { \mod_assign\event\submission_status_updated::create_from_submission($this, $submission)->trigger(); } diff --git a/mod/assign/tests/behat/remove_submission.feature b/mod/assign/tests/behat/remove_submission.feature index cf5149bea39..1a98e2a1993 100644 --- a/mod/assign/tests/behat/remove_submission.feature +++ b/mod/assign/tests/behat/remove_submission.feature @@ -51,10 +51,12 @@ Feature: Remove a submission When I follow "Remove submission" And I click on "Continue" "button" Then I should not see "I'm the student submission" + And "Student 1" row "Status" column of "generaltable" table should contain "No submission" And I log out And I am on the "Test assignment name" Activity page logged in as student1 And I should not see "I'm the student submission" + And I should see "No attempt" in the "Submission status" "table_row" @javascript @skip_chrome_zerosize Scenario: Remove a group submission should remove the data from all group members @@ -77,10 +79,12 @@ Feature: Remove a submission When I follow "Remove submission" And I click on "Continue" "button" Then I should not see "I'm the student submission" + And "Student 1" row "Status" column of "generaltable" table should contain "No submission" And I log out And I am on the "Test assignment name" Activity page logged in as student2 And I should not see "I'm the student submission" + And I should see "Nothing has been submitted for this assignment" in the "Submission status" "table_row" @javascript @skip_chrome_zerosize Scenario: A student can remove their own submission @@ -104,7 +108,9 @@ Feature: Remove a submission When I am on the "Test assignment name" Activity page logged in as teacher1 And I navigate to "View all submissions" in current page administration Then I should not see "I'm the student submission" + And "Student 1" row "Status" column of "generaltable" table should contain "No submission" And I log out And I am on the "Test assignment name" Activity page logged in as student1 And I should not see "I'm the student submission" + And I should see "No attempt" in the "Submission status" "table_row"