Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-38267 assign: No Submit button after cut-off date

  • Loading branch information...
commit 9054c04d45367d2fb9fa93ef8b83efc00fb8236e 1 parent aba4d00
@prateeksachan prateeksachan authored danpoltawski committed
Showing with 49 additions and 1 deletion.
  1. +7 −1 mod/assign/locallib.php
  2. +42 −0 mod/assign/tests/locallib_test.php
View
8 mod/assign/locallib.php
@@ -3552,7 +3552,7 @@ public function view_student_summary($user, $showlinks) {
}
}
- $showsubmit = ($submission || $teamsubmission) && $showlinks;
+ $showsubmit = ($submission || $teamsubmission) && $showlinks && $this->submissions_open($user->id);
if ($teamsubmission && ($teamsubmission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
$showsubmit = false;
}
@@ -4477,6 +4477,9 @@ protected function process_submit_for_grading($mform) {
require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php');
require_sesskey();
+ if (!$this->submissions_open()) {
+ return $this->view_student_error_message();
+ }
$instance = $this->get_instance();
$data = new stdClass();
$adminconfig = $this->get_admin_config();
@@ -5141,6 +5144,9 @@ protected function process_save_submission(&$mform, &$notices) {
// Need submit permission to submit an assignment.
require_capability('mod/assign:submit', $this->context);
require_sesskey();
+ if (!$this->submissions_open()) {
+ return $this->view_student_error_message();
+ }
$instance = $this->get_instance();
$data = new stdClass();
View
42 mod/assign/tests/locallib_test.php
@@ -1309,5 +1309,47 @@ public function test_submission_graded_event() {
$sink->close();
}
+ public function test_disable_submit_after_cutoff_date() {
+ global $PAGE;
+
+ $this->setUser($this->editingteachers[0]);
+ $now = time();
+ $tomorrow = $now + 24*60*60;
+ $lastweek = $now - 7*24*60*60;
+ $yesterday = $now - 24*60*60;
+
+ $assign = $this->create_instance(array('duedate'=>$yesterday,
+ 'cutoffdate'=>$tomorrow,
+ 'assignsubmission_onlinetext_enabled'=>1));
+ $PAGE->set_url(new moodle_url('/mod/assign/view.php', array('id' => $assign->get_course_module()->id)));
+
+ // Student should be able to see an add submission button.
+ $this->setUser($this->students[0]);
+ $output = $assign->view_student_summary($this->students[0], true);
+ $this->assertNotEquals(false, strpos($output, get_string('addsubmission', 'assign')));
+
+ // Add a submission but don't submit now.
+ $submission = $assign->get_user_submission($this->students[0]->id, true);
+ $data = new stdClass();
+ $data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
+ 'text'=>'Submission text',
+ 'format'=>FORMAT_MOODLE);
+ $plugin = $assign->get_submission_plugin_by_type('onlinetext');
+ $plugin->save($submission, $data);
+
+ // Create another instance with cut-off and due-date already passed.
+ $this->setUser($this->editingteachers[0]);
+ $now = time();
+ $assign = $this->create_instance(array('duedate'=>$lastweek,
+ 'cutoffdate'=>$yesterday,
+ 'assignsubmission_onlinetext_enabled'=>1));
+
+ $this->setUser($this->students[0]);
+ $output = $assign->view_student_summary($this->students[0], true);
+ $this->assertNotContains($output, get_string('editsubmission', 'assign'),
+ 'Should not be able to edit after cutoff date.');
+ $this->assertNotContains($output, get_string('submitassignment', 'assign'),
+ 'Should not be able to submit after cutoff date.');
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.