MDL-79440 mod_lti: fix missing array key warning on LTI 2 edit

These fields only exist for LTI 1.1 and LTI 1.3 edits, so can be
ignored in LTI 2.0 edits. This change fixes this for the tool
type edit (edit_form) and for the tool instance form (mod_form).
This commit is contained in:
Jake Dallimore 2023-09-21 12:32:39 +08:00
parent ecddfa6ccd
commit 72e867f9e6
No known key found for this signature in database
2 changed files with 4 additions and 2 deletions

View File

@ -437,7 +437,9 @@ class mod_lti_edit_types_form extends moodleform {
// change to the existing value. Add the option as a disabled to make this clear. Once changed, it cannot be set again.
// This isn't supported from 4.3 onward in the creation of new tool types.
foreach (['lti_sendname', 'lti_sendemailaddr'] as $elementname) {
if ($this->_form->_defaultValues[$elementname] == LTI_SETTING_DELEGATE) {
if (!empty($this->_form->_defaultValues[$elementname])
&& $this->_form->_defaultValues[$elementname] == LTI_SETTING_DELEGATE) {
$elementarr = array_filter($this->_form->_elements, function ($element) use($elementname) {
return !empty($element->_attributes['name']) && $element->_attributes['name'] == $elementname;
});

View File

@ -473,7 +473,7 @@ class mod_lti_mod_form extends moodleform_mod {
$mform->setType('secureicon', PARAM_URL);
// Add standard course module grading elements, and show them if the tool type + instance config permits it.
if (in_array($config['acceptgrades'], [LTI_SETTING_ALWAYS, LTI_SETTING_DELEGATE])) {
if (!empty($config['acceptgrades']) && in_array($config['acceptgrades'], [LTI_SETTING_ALWAYS, LTI_SETTING_DELEGATE])) {
$elementnamesbeforegrading = $this->_form->_elementIndex;
$this->standard_grading_coursemodule_elements();
$elementnamesaftergrading = $this->_form->_elementIndex;