Skip to content

Commit

Permalink
MDL-82344 mod_lti: relax content selection validation in instance form
Browse files Browse the repository at this point in the history
This was added in MDL-78916 in 4.3 but makes configuring a generic
launch to the default tool URL impossible, since a content item must be
selected. This fix makes this element optional again, which allows
teachers to choose whether a given instance launches into selected
content, or launches the default tool URL.
  • Loading branch information
snake committed Jul 29, 2024
1 parent 1a33da6 commit be889fe
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions mod/lti/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,12 @@ public function definition() {
. get_string('contentselected', 'mod_lti') : '';
$selectcontentindicator = html_writer::div($selectcontentindicatorinner, '',
['aria-role' => 'status', 'id' => 'id_selectcontentindicator']);
$selectcontentstatus = $iscontentitem ? 'true' : 'false';
$selectcontentgrp = [
$mform->createElement('button', 'selectcontent', get_string('selectcontent', 'mod_lti'), $contentbuttonattributes,
['customclassoverride' => 'btn-primary']),
['customclassoverride' => 'btn-secondary']),
$mform->createElement('html', $selectcontentindicator),
$mform->createElement('hidden', 'selectcontentstatus', $selectcontentstatus),
];
$mform->setType('selectcontentstatus', PARAM_TEXT);
$mform->addGroup($selectcontentgrp, 'selectcontentgroup', get_string('content'), ' ', false);
$mform->addRule('selectcontentgroup', get_string('selectcontentvalidationerror', 'mod_lti'), 'required');
}

// Adding the standard "name" field.
Expand Down Expand Up @@ -539,14 +535,4 @@ public function set_data($defaultvalues) {
}
parent::set_data($defaultvalues);
}

public function validation($data, $files) {
$errors = parent::validation($data, $files);

if (isset($data['selectcontentstatus']) && $data['selectcontentstatus'] === 'false') {
$errors['selectcontentgroup'] = get_string('selectcontentvalidationerror', 'mod_lti');
}

return $errors;
}
}

0 comments on commit be889fe

Please sign in to comment.