MDL-55140 mod_choice: Allow independent open and close dates

This commit is contained in:
Stephen Bourget
2016-07-27 07:18:54 -04:00
parent 90a8bdbfc0
commit 2ff504c6b2
10 changed files with 142 additions and 77 deletions
+7 -20
View File
@@ -117,11 +117,6 @@ function choice_add_instance($choice) {
$choice->timemodified = time();
if (empty($choice->timerestrict)) {
$choice->timeopen = 0;
$choice->timeclose = 0;
}
//insert answers
$choice->id = $DB->insert_record("choice", $choice);
foreach ($choice->option as $key => $value) {
@@ -160,12 +155,6 @@ function choice_update_instance($choice) {
$choice->id = $choice->instance;
$choice->timemodified = time();
if (empty($choice->timerestrict)) {
$choice->timeopen = 0;
$choice->timeclose = 0;
}
//update, delete or insert answers
foreach ($choice->option as $key => $value) {
$value = trim($value);
@@ -1065,16 +1054,14 @@ function choice_get_availability_status($choice) {
$available = true;
$warnings = array();
if ($choice->timeclose != 0) {
$timenow = time();
$timenow = time();
if ($choice->timeopen > $timenow) {
$available = false;
$warnings['notopenyet'] = userdate($choice->timeopen);
} else if ($timenow > $choice->timeclose) {
$available = false;
$warnings['expired'] = userdate($choice->timeclose);
}
if (!empty($choice->timeopen) && ($choice->timeopen > $timenow)) {
$available = false;
$warnings['notopenyet'] = userdate($choice->timeopen);
} else if (!empty($choice->timeclose) && ($timenow > $choice->timeclose)) {
$available = false;
$warnings['expired'] = userdate($choice->timeclose);
}
if (!$choice->allowupdate && choice_get_my_response($choice)) {
$available = false;