Commit 0f989a4c authored by Juan Leyva's avatar Juan Leyva Committed by Eloy Lafuente (stronk7)
Browse files

MDL-52901 mod_assign: Check due dates in external save_submission

parent b74d0f84
......@@ -1636,9 +1636,12 @@ class mod_assign_external extends external_api {
$notices = array();
$submissiondata = (object)$params['plugindata'];
$assignment->save_submission($submissiondata, $notices);
if (!$assignment->submissions_open($USER->id)) {
$notices[] = get_string('duedatereached', 'assign');
} else {
$submissiondata = (object)$params['plugindata'];
$assignment->save_submission($submissiondata, $notices);
}
$warnings = array();
foreach ($notices as $notice) {
......
......@@ -928,6 +928,16 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(0, count($result));
// Set up a due and cutoff passed date.
$instance->duedate = time() - WEEKSECS;
$instance->cutoffdate = time() - WEEKSECS;
$DB->update_record('assign', $instance);
$result = mod_assign_external::save_submission($instance->id, $submissionpluginparams);
$result = external_api::clean_returnvalue(mod_assign_external::save_submission_returns(), $result);
$this->assertCount(1, $result);
$this->assertEquals(get_string('duedatereached', 'assign'), $result[0]['item']);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment