From f259405d020f1dd08bc9a8507f6a8db47f4d7faa Mon Sep 17 00:00:00 2001 From: Claude Vervoort Date: Wed, 15 Apr 2020 10:34:22 -0400 Subject: [PATCH] MDL-68328 mod_lti: use hidden form when deeplink options disabled --- mod/lti/mod_form.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mod/lti/mod_form.php b/mod/lti/mod_form.php index 8eb9fac73f9..49e925b72d6 100644 --- a/mod/lti/mod_form.php +++ b/mod/lti/mod_form.php @@ -63,10 +63,10 @@ class mod_lti_mod_form extends moodleform_mod { // Type ID parameter being passed when adding an preconfigured tool from activity chooser. $typeid = optional_param('typeid', false, PARAM_INT); + $showoptions = has_capability('mod/lti:addmanualinstance', $this->context); // Show configuration details only if not preset (when new) or user has the capabilities to do so (when editing). if ($this->_instance) { $showtypes = has_capability('mod/lti:addpreconfiguredinstance', $this->context); - $showoptions = has_capability('mod/lti:addmanualinstance', $this->context); if (!$showoptions && $this->current->typeid == 0) { // If you cannot add a manual instance and this is already a manual instance, then // remove the 'types' selector. @@ -74,7 +74,6 @@ class mod_lti_mod_form extends moodleform_mod { } } else { $showtypes = !$typeid; - $showoptions = !$typeid && has_capability('mod/lti:addmanualinstance', $this->context); } $this->typeid = 0; @@ -202,9 +201,15 @@ class mod_lti_mod_form extends moodleform_mod { $mform->setAdvanced('securetoolurl'); $mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti'); $mform->hideIf('securetoolurl', 'typeid', 'in', $noncontentitemtypes); + } else { + // We still need those on page to support deep linking return, but hidden to avoid instructor modification. + $mform->addElement('hidden', 'toolurl', '', array('id' => 'id_toolurl')); + $mform->setType('toolurl', PARAM_URL); + $mform->addElement('hidden', 'securetoolurl', '', array('id' => 'id_securetoolurl')); + $mform->setType('securetoolurl', PARAM_URL); } - $mform->addElement('hidden', 'urlmatchedtypeid', '', array( 'id' => 'id_urlmatchedtypeid' )); + $mform->addElement('hidden', 'urlmatchedtypeid', '', array('id' => 'id_urlmatchedtypeid')); $mform->setType('urlmatchedtypeid', PARAM_INT); $launchoptions = array(); @@ -250,6 +255,14 @@ class mod_lti_mod_form extends moodleform_mod { $mform->setAdvanced('secureicon'); $mform->addHelpButton('secureicon', 'secure_icon_url', 'lti'); $mform->hideIf('secureicon', 'typeid', 'in', $noncontentitemtypes); + } else { + // Keep those in the form to allow deep linking, key and secret are removed altogether. + $mform->addElement('hidden', 'instructorcustomparameters', '', array('id' => 'id_instructorcustomparameters')); + $mform->setType('instructorcustomparameters', PARAM_TEXT); + $mform->addElement('hidden', 'icon', '', array('id' => 'id_icon')); + $mform->setType('icon', PARAM_URL); + $mform->addElement('hidden', 'secureicon', '', array('id' => 'id_secureicon')); + $mform->setType('secureicon', PARAM_URL); } // Add privacy preferences fieldset where users choose whether to send their data. -- 2.43.0