tool = $tool; } /** * Build the form. * * @param bool $globalMode */ public function build($globalMode = true) { $plugin = ImsLtiPlugin::create(); $course = $this->tool->getCourse(); $parent = $this->tool->getParent(); $this->addHeader($plugin->get_lang('ToolSettings')); if (null !== $course && $globalMode) { $this->addHtml( Display::return_message( sprintf($plugin->get_lang('ToolAddedOnCourseX'), $course->getTitle()), 'normal', false ) ); } $this->addText('name', get_lang('Name')); $this->addTextarea('description', get_lang('Description')); $this->addRadio( 'version', $plugin->get_lang('LtiVersion'), [ ImsLti::V_1P1 => 'LTI 1.0 / 1.1', ImsLti::V_1P3 => 'LTI 1.3.0', ] ); $this->freeze(['version']); if (null === $parent) { $this->addUrl('launch_url', $plugin->get_lang('LaunchUrl'), true); if ($this->tool->getVersion() === ImsLti::V_1P1) { $this->addText('consumer_key', $plugin->get_lang('ConsumerKey'), false); $this->addText('shared_secret', $plugin->get_lang('SharedSecret'), false); } elseif ($this->tool->getVersion() === ImsLti::V_1P3) { $this->addText('client_id', $plugin->get_lang('ClientId'), true); $this->freeze(['client_id']); if (!empty($this->tool->getJwksUrl())) { $this->addUrl('jwks_url', $plugin->get_lang('PublicKeyset')); } else { $this->addTextarea( 'public_key', $plugin->get_lang('PublicKey'), ['style' => 'font-family: monospace;', 'rows' => 5], true ); } $this->addUrl('login_url', $plugin->get_lang('LoginUrl')); $this->addUrl('redirect_url', $plugin->get_lang('RedirectUrl')); } } $this->addButtonAdvancedSettings('lti_adv'); $this->addHtml('
'); $this->addButtonAdvancedSettings('lti_privacy', get_lang('Privacy')); $this->addHtml(''); $this->addButtonUpdate($plugin->get_lang('EditExternalTool')); $this->addHidden('id', $this->tool->getId()); $this->addHidden('action', 'edit'); $this->applyFilter('__ALL__', 'trim'); } /** * @throws Exception */ public function setDefaultValues() { $advServices = $this->tool->getAdvantageServices(); $this->setDefaults( [ 'name' => $this->tool->getName(), 'description' => $this->tool->getDescription(), 'launch_url' => $this->tool->getLaunchUrl(), 'consumer_key' => $this->tool->getConsumerKey(), 'shared_secret' => $this->tool->getSharedSecret(), 'custom_params' => $this->tool->getCustomParams(), 'deep_linking' => $this->tool->isActiveDeepLinking(), 'share_name' => $this->tool->isSharingName(), 'share_email' => $this->tool->isSharingEmail(), 'share_picture' => $this->tool->isSharingPicture(), 'version' => $this->tool->getVersion(), 'client_id' => $this->tool->getClientId(), 'public_key' => $this->tool->publicKey, 'jwks_url' => $this->tool->getJwksUrl(), 'login_url' => $this->tool->getLoginUrl(), 'redirect_url' => $this->tool->getRedirectUrl(), '1p3_ags' => $advServices['ags'], '1p3_nrps' => $advServices['nrps'], 'document_target' => $this->tool->getDocumentTarget(), 'replacement_user_id' => $this->tool->getReplacementForUserId(), ] ); } }