MDL-38267 assign: No Submit button after cut-off date
This commit is contained in:
committed by
Dan Poltawski
parent
aba4d0090d
commit
9054c04d45
@@ -3552,7 +3552,7 @@ class assign {
|
||||
}
|
||||
}
|
||||
|
||||
$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 @@ class assign {
|
||||
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 @@ class assign {
|
||||
// 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();
|
||||
|
||||
@@ -1309,5 +1309,47 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user