Merge branch 'MDL-74064-master' of https://github.com/HuongNV13/moodle

This commit is contained in:
Ilya Tregubov 2022-04-14 13:35:11 +06:00
commit 5c3563e3a2
5 changed files with 92 additions and 9 deletions

View File

@ -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';

View File

@ -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';

View File

@ -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(),
@ -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,

View File

@ -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."

View File

@ -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"