diff --git a/mod/assign/classes/output/user_submission_actionmenu.php b/mod/assign/classes/output/user_submission_actionmenu.php index 4c8b121102313..6cbfddc8617e9 100644 --- a/mod/assign/classes/output/user_submission_actionmenu.php +++ b/mod/assign/classes/output/user_submission_actionmenu.php @@ -131,7 +131,8 @@ public function export_for_template(\renderer_base $output): array { } if ($status === ASSIGN_SUBMISSION_STATUS_NEW) { - if ($this->timelimit && empty($this->submission->timestarted)) { + $timelimitenabled = get_config('assign', 'enabletimelimit'); + if ($timelimitenabled && $this->timelimit && empty($this->submission->timestarted)) { $confirmation = new \confirm_action( get_string('confirmstart', 'assign', format_time($this->timelimit)), null, diff --git a/mod/assign/override_form.php b/mod/assign/override_form.php index e30e4d4234b31..8f5f7cf49019b 100644 --- a/mod/assign/override_form.php +++ b/mod/assign/override_form.php @@ -263,9 +263,12 @@ protected function definition() { } // Time limit. - $mform->addElement('duration', 'timelimit', - get_string('timelimit', 'assign'), array('optional' => true)); - $mform->setDefault('timelimit', $assigninstance->timelimit); + $timelimitenabled = get_config('assign', 'enabletimelimit'); + if ($timelimitenabled) { + $mform->addElement('duration', 'timelimit', + get_string('timelimit', 'assign'), array('optional' => true)); + $mform->setDefault('timelimit', $assigninstance->timelimit); + } // Submit buttons. $mform->addElement('submit', 'resetbutton', @@ -344,7 +347,7 @@ public function validation($data, $files) { $changed = false; $keys = array('duedate', 'cutoffdate', 'allowsubmissionsfromdate', 'timelimit'); foreach ($keys as $key) { - if ($data[$key] != $assigninstance->{$key}) { + if (isset($data[$key]) && $data[$key] != $assigninstance->{$key}) { $changed = true; break; } diff --git a/mod/assign/overrideedit.php b/mod/assign/overrideedit.php index 76fb11b2f827a..88f38217baf8d 100644 --- a/mod/assign/overrideedit.php +++ b/mod/assign/overrideedit.php @@ -144,7 +144,7 @@ // Replace unchanged values with null. foreach ($keys as $key) { - if (($fromform->{$key} == $assigninstance->{$key})) { + if (!isset($fromform->{$key}) || $fromform->{$key} == $assigninstance->{$key}) { $fromform->{$key} = null; } } diff --git a/mod/assign/overrides.php b/mod/assign/overrides.php index dd65575ebae20..e41efdb992cfa 100644 --- a/mod/assign/overrides.php +++ b/mod/assign/overrides.php @@ -211,7 +211,8 @@ } // Format timelimit. - if (isset($override->timelimit)) { + $timelimitenabled = get_config('assign', 'enabletimelimit'); + if ($timelimitenabled && isset($override->timelimit)) { $fields[] = get_string('timelimit', 'assign'); $values[] = $override->timelimit > 0 ? format_time($override->timelimit) : get_string('none', 'assign'); }