/** * Configure course and account navigation placements * * @return Generator */ public function getGenerator() { parent::getGenerator(); $this->generator->setOptionProperty(Option::COURSE_NAVIGATION(), 'visibility', 'admins'); $this->generator->setOptionProperty(Option::ACCOUNT_NAVIGATION(), 'visibility', 'admins'); return $this->generator; }
/** * Generate the XML configuration file * * @return string */ public function saveXML() { $config = new DOMDocument('1.0', 'UTF-8'); $config->formatOutput = true; $cartridge = $config->createElementNS(self::LTICC, 'cartridge_basiclti_link'); $config->appendChild($cartridge); $cartridge->setAttributeNS(self::XMLNS, 'xmlns:blti', self::BLTI); $cartridge->setAttributeNS(self::XMLNS, 'xmlns:lticm', self::LTICM); $cartridge->setAttributeNS(self::XMLNS, 'xmlns:lticp', self::LTICP); $cartridge->setAttributeNS(self::XMLNS, 'xmlns:xsi', self::XSI); $cartridge->setAttributeNS(self::XSI, 'xsi:schemaLocation', self::LTICC . ' ' . self::LTICC . '.xsd ' . self::BLTI . ' ' . self::BLTI . '.xsd ' . self::LTICM . ' ' . self::LTICM . '.xsd ' . self::LTICP . ' ' . self::LTICP . '.xsd'); $cartridge->appendChild($config->createElementNS(self::BLTI, 'blti:title', $this->name)); /* * TODO CDATA wrapper? */ if ($this->description) { $cartridge->appendChild($config->createElementNS(self::BLTI, 'blti:description', $this->description)); } if ($this->iconURL) { $cartridge->appendChild($config->createElementNS(self::BLTI, 'blti:icon', $this->iconURL)); } $cartridge->appendChild($config->createElementNS(self::BLTI, 'blti:launch_url', $this->launchURL)); $extensions = $config->createElementNS(self::BLTI, 'blti:extensions'); $cartridge->appendChild($extensions); $extensions->setAttribute('platform', 'canvas.instructure.com'); $property = $config->createElementNS(self::LTICM, 'lticm:property', $this->id); $property->setAttribute('name', 'tool_id'); $extensions->appendChild($property); $property = $config->createElementNS(self::LTICM, 'lticm:property', $this->launchPrivacy); $property->setAttribute('name', 'privacy_level'); $extensions->appendChild($property); if (!empty($this->domain)) { $property = $config->createElementNS(self::LTICM, 'lticm:property', $this->domain); $property->setAttribute('name', 'domain'); $extensions->appendChild($property); } /* if no options are configured, create a default course navigation option */ if (empty($this->options)) { $extensions->appendChild($this->getOptionsElement($config, Option::COURSE_NAVIGATION(), [])); } else { foreach ($this->options as $option => $properties) { $extensions->appendChild($this->getOptionsElement($config, $option, $properties)); } } $bundle = $config->createElement('cartridge_bundle'); $cartridge->appendChild($bundle); $bundle->setAttribute('identiferref', 'BLT001_Bundle'); $icon = $config->createElement('cartridge_icon'); $cartridge->appendChild($icon); $icon->setAttribute('identifierref', 'BLT001_Icon'); return $config->saveXML(); }