Skip to content

Commit

Permalink
Merge branch 'MDL-74064-master' of https://github.com/HuongNV13/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Apr 14, 2022
2 parents 80709ba + 3956dd8 commit 5c3563e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mod/assign/classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ protected function get_time_remaining(\mod_assign\output\assign_submission_statu

// 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';
Expand Down
6 changes: 4 additions & 2 deletions mod/assign/lang/en/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,10 @@
$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';
Expand Down
17 changes: 12 additions & 5 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4447,14 +4447,14 @@ protected function view_single_grade_page($mform) {
* @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(),
Expand All @@ -4474,10 +4474,17 @@ protected function view_remove_submission_confirm() {
$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,
Expand Down
39 changes: 39 additions & 0 deletions mod/assign/tests/behat/remove_submission.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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."
37 changes: 36 additions & 1 deletion mod/assign/tests/behat/set_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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"

0 comments on commit 5c3563e

Please sign in to comment.