Skip to content

Commit

Permalink
Merge branch 'MDL-78984-402' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_402_STABLE
  • Loading branch information
HuongNV13 committed Feb 27, 2024
2 parents c8d990d + d3cbf29 commit d53011e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion mod/assign/classes/output/user_submission_actionmenu.php
Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions mod/assign/override_form.php
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/overrideedit.php
Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion mod/assign/overrides.php
Expand Up @@ -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');
}
Expand Down

0 comments on commit d53011e

Please sign in to comment.