Skip to content

Commit

Permalink
issue #5: fix issue with the form displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Nov 27, 2024
1 parent 13a25d6 commit 9df77df
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion classes/local/mod/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ public function coursemodule_definition_after_data(moodleform_mod $modform, Mood
} else {
$form->setDefault(self::NEW_DUEDATE_FORM_FIELD, 0);
}
} else {
// Otherwise if value is overridden (other is selected), then apply default overridden value.
$element = $form->getElement(self::NEW_DUEDATE_FORM_FIELD);
$submittedvalue = $form->getElementValue(self::NEW_DUEDATE_FORM_FIELD);
$exportedvalue = $element->exportValue($submittedvalue);
if (empty($exportedvalue['overridden'])) {
$form->setDefault(self::NEW_DUEDATE_FORM_FIELD, $form->getElementValue('duedate'));
}
}

// This is a very hacky way of making sure that duedate field is set to a new value based on data in the different field.
Expand Down Expand Up @@ -731,7 +739,7 @@ private function build_field_prefix(string $cmid): string {
* @return string
*/
private function build_new_element_name($cmid): string {
return self::NEW_DUEDATE_FORM_FIELD . '_' . $cmid . '_' . 'assign';;
return self::NEW_DUEDATE_FORM_FIELD . '_' . $cmid . '_' . 'assign';
}

/**
Expand Down

0 comments on commit 9df77df

Please sign in to comment.