From 76c0d3d6bcd04956d07e2277557883caa58de726 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Tue, 22 Mar 2022 16:44:01 +1100 Subject: [PATCH 1/4] MDL-74064 mod_assign: Late submission recognition depends on timestarted --- mod/assign/classes/output/renderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/assign/classes/output/renderer.php b/mod/assign/classes/output/renderer.php index b696d341dcd..45e60caf347 100644 --- a/mod/assign/classes/output/renderer.php +++ b/mod/assign/classes/output/renderer.php @@ -1305,7 +1305,7 @@ class renderer extends \plugin_renderer_base { // There is a submission, display the relevant early/late message. if ($submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) { - $latecalculation = $submission->timemodified - ($timelimitenabledbeforeduedate ? $submission->timecreated : 0); + $latecalculation = $submission->timemodified - ($timelimitenabledbeforeduedate ? $submission->timestarted : 0); $latethreshold = $timelimitenabledbeforeduedate ? $status->timelimit : $status->duedate; $earlystring = $timelimitenabledbeforeduedate ? 'submittedundertime' : 'submittedearly'; $latestring = $timelimitenabledbeforeduedate ? 'submittedovertime' : 'submittedlate'; From 6ac1477e9852c589b3ae7d73b635479a1c8b7d47 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 28 Mar 2022 19:36:35 +1100 Subject: [PATCH 2/4] MDL-74064 mod_assign: Use core_user::get_user instead of querying DB --- mod/assign/locallib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 1cbce58e830..05c53f2a5f0 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -4447,14 +4447,14 @@ class assign { * @return string */ protected function view_remove_submission_confirm() { - global $USER, $DB; + global $USER; $userid = optional_param('userid', $USER->id, PARAM_INT); if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } - $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); + $user = core_user::get_user($userid, '*', MUST_EXIST); $o = ''; $header = new assign_header($this->get_instance(), From 7252fef24bb207ce955e0d972901f0cefba8042d Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 28 Mar 2022 19:37:03 +1100 Subject: [PATCH 3/4] MDL-74064 mod_assign: Notify submission removal does not reset timelimit --- mod/assign/lang/en/assign.php | 6 ++++-- mod/assign/locallib.php | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mod/assign/lang/en/assign.php b/mod/assign/lang/en/assign.php index 465d99ce3c0..814a1aee60c 100644 --- a/mod/assign/lang/en/assign.php +++ b/mod/assign/lang/en/assign.php @@ -476,8 +476,10 @@ $string['requireallteammemberssubmit_help'] = 'If enabled, all members of the st $string['recordid'] = 'Identifier'; $string['removesubmission'] = 'Remove submission'; $string['removesubmissionforstudent'] = 'Remove submission for student: (id={$a->id}, fullname={$a->fullname}).'; -$string['removesubmissionconfirm'] = 'Are you sure you want to remove the submission data?'; -$string['removesubmissionconfirmforstudent'] = 'Are you sure you want to remove the submission data for student {$a}?'; +$string['removesubmissionconfirm'] = 'Are you sure you want to remove your submission?'; +$string['removesubmissionconfirmforstudent'] = 'Are you sure you want to remove the submission for {$a}?'; +$string['removesubmissionconfirmforstudentwithtimelimit'] = 'Are you sure you want to remove the submission for {$a}? Please note that this will not reset the student\'s time limit. You can give more time by adding a time limit user override.'; +$string['removesubmissionconfirmwithtimelimit'] = 'Are you sure you want to remove your submission? Please note that this will not reset your time limit.'; $string['revealidentities'] = 'Reveal student identities'; $string['revealidentitiesconfirm'] = 'Are you sure you want to reveal student identities for this assignment? This operation cannot be undone. Once the student identities have been revealed, the marks will be released to the gradebook.'; $string['reverttodefaults'] = 'Revert to assignment defaults'; diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 05c53f2a5f0..5c0d9a85c18 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -4474,10 +4474,17 @@ class assign { $cancelurl = new moodle_url('/mod/assign/view.php', $urlparams); if ($userid == $USER->id) { - $confirmstr = get_string('removesubmissionconfirm', 'assign'); + if ($this->is_time_limit_enabled($userid)) { + $confirmstr = get_string('removesubmissionconfirmwithtimelimit', 'assign'); + } else { + $confirmstr = get_string('removesubmissionconfirm', 'assign'); + } } else { - $name = $this->fullname($user); - $confirmstr = get_string('removesubmissionconfirmforstudent', 'assign', $name); + if ($this->is_time_limit_enabled($userid)) { + $confirmstr = get_string('removesubmissionconfirmforstudentwithtimelimit', 'assign', $this->fullname($user)); + } else { + $confirmstr = get_string('removesubmissionconfirmforstudent', 'assign', $this->fullname($user)); + } } $o .= $this->get_renderer()->confirm($confirmstr, $confirmurl, From 3956dd856b6ae6c023c673de5b948f79e3b0f24f Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Thu, 14 Apr 2022 11:08:43 +0700 Subject: [PATCH 4/4] MDL-74064 mod_assign: Behat test for Assignment with time limit --- .../tests/behat/remove_submission.feature | 39 +++++++++++++++++++ .../tests/behat/set_availability.feature | 37 +++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/mod/assign/tests/behat/remove_submission.feature b/mod/assign/tests/behat/remove_submission.feature index 67c13091b8d..aade1877a97 100644 --- a/mod/assign/tests/behat/remove_submission.feature +++ b/mod/assign/tests/behat/remove_submission.feature @@ -9,6 +9,8 @@ Feature: Remove a submission And I set the following system permissions of "Teacher" role: | capability | permission | | mod/assign:editothersubmission | Allow | + And I set the following administration settings values: + | Enable timed assignments | 1 | And I log out And the following "courses" exist: | fullname | shortname | category | groupmode | @@ -114,3 +116,40 @@ Feature: Remove a submission 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 submissions have been made yet" in the "Submission status" "table_row" + + @javascript @skip_chrome_zerosize @_file_upload + Scenario: Submission removal with time limit setting + Given the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test assignment with time limit | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 1 | + | assignsubmission_file_maxfiles | 1 | + | assignsubmission_file_maxsizebytes | 1000000 | + | submissiondrafts | 0 | + | allowsubmissionsfromdate_enabled | 0 | + | duedate_enabled | 0 | + | cutoffdate_enabled | 0 | + | gradingduedate_enabled | 0 | + And I am on the "Test assignment with time limit" Activity page logged in as admin + And I navigate to "Settings" in current page administration + And I follow "Expand all" + # Set 'Time limit' to 5 seconds. + And I set the field "timelimit[enabled]" to "1" + And I set the field "timelimit[number]" to "5" + And I set the field "timelimit[timeunit]" to "seconds" + And I press "Save and return to course" + When I am on the "Test assignment with time limit" Activity page logged in as student1 + And I click on "Begin assignment" "link" + And I click on "Begin assignment" "button" + And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager + And I press "Save changes" + And I click on "Remove submission" "button" + Then I should see "Are you sure you want to remove your submission? Please note that this will not reset your time limit." + And I press "Cancel" + And I am on the "Test assignment with time limit" Activity page logged in as admin + And I click on "View all submissions" "link" + And I open the action menu in "Student 1" "table_row" + And I follow "Remove submission" + And I should see "Are you sure you want to remove the submission for Student 1? Please note that this will not reset the student's time limit. You can give more time by adding a time limit user override." diff --git a/mod/assign/tests/behat/set_availability.feature b/mod/assign/tests/behat/set_availability.feature index 6106980a36c..f16b409a1ca 100644 --- a/mod/assign/tests/behat/set_availability.feature +++ b/mod/assign/tests/behat/set_availability.feature @@ -5,7 +5,10 @@ Feature: Set availability dates for an assignment I need be able to set availability dates for an assignment Background: - Given the following "courses" exist: + Given I log in as "admin" + And I set the following administration settings values: + | Enable timed assignments | 1 | + And the following "courses" exist: | fullname | shortname | | Course 1 | C1 | And the following "users" exist: @@ -27,6 +30,19 @@ Feature: Set availability dates for an assignment | assignsubmission_file_maxfiles | 1 | | assignsubmission_file_maxsizebytes | 0 | | submissiondrafts | 0 | + Given the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test late assignment with time limit | + | assignsubmission_onlinetext_enabled | 1 | + | assignsubmission_file_enabled | 1 | + | assignsubmission_file_maxfiles | 1 | + | assignsubmission_file_maxsizebytes | 1000000 | + | submissiondrafts | 0 | + | allowsubmissionsfromdate_enabled | 0 | + | duedate_enabled | 0 | + | cutoffdate_enabled | 0 | + | gradingduedate_enabled | 0 | Scenario: Student cannot submit an assignment prior to the 'allow submissions from' date Given I am on the "Assignment name" Activity page logged in as teacher1 @@ -201,3 +217,22 @@ Feature: Set availability dates for an assignment And I follow "View all submissions" And I should see "No submission" in the "Student 1" "table_row" And I should see "Assignment is overdue by: 2 days 5 hours" in the "Student 1" "table_row" + + @_file_upload + Scenario: Late submission will be calculated only when the student starts the assignment + Given I am on the "Test late assignment with time limit" Activity page logged in as admin + And I navigate to "Settings" in current page administration + And I follow "Expand all" + # Set 'Time limit' to 5 seconds. + And I set the field "timelimit[enabled]" to "1" + And I set the field "timelimit[number]" to "5" + And I set the field "timelimit[timeunit]" to "seconds" + And I press "Save and return to course" + When I am on the "Test late assignment with time limit" Activity page logged in as student1 + And I wait "6" seconds + And I click on "Begin assignment" "link" + And I click on "Begin assignment" "button" + And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager + And I press "Save changes" + Then I should see "Submitted for grading" in the "Submission status" "table_row" + And I should see "under the time limit" in the "Time remaining" "table_row"