version = self::VERSION_LTI_1P3; return $session; } /** * Override the default label construction * (non-PHPdoc) * @see common_session_DefaultSession::getUserLabel() * * @throws LtiVariableMissingException */ public function getUserLabel() { if ($this->getLaunchData()->hasVariable(LtiLaunchData::LIS_PERSON_NAME_FULL)) { return $this->getLaunchData()->getUserFullName(); } else { $parts = []; if ($this->getLaunchData()->hasVariable(LtiLaunchData::LIS_PERSON_NAME_GIVEN)) { $parts[] = $this->getLaunchData()->getUserGivenName(); } if ($this->getLaunchData()->hasVariable(LtiLaunchData::LIS_PERSON_NAME_FAMILY)) { $parts[] = $this->getLaunchData()->getUserFamilyName(); } return empty($parts) ? __('user') : implode(' ', $parts); } } /** * Returns the data that was transmitted during launch * * @return LtiLaunchData */ public function getLaunchData() { return $this->getUser()->getLaunchData(); } /** * Returns a resource representing the incoming link * * @throws LtiVariableMissingException * @throws common_exception_Error */ public function getLtiLinkResource(): core_kernel_classes_Resource { if ($this->linkId === null) { /** @var LinkService $service */ $service = $this->getServiceLocator()->get(LinkService::SERVICE_ID); $this->linkId = $service->getLinkId( $this->getLtiConsumer(), $this->getLaunchData()->getResourceLinkID() ); } return new core_kernel_classes_Resource($this->linkId); } /** * Returns the consumer based on the LTI version * * @throws LtiVariableMissingException */ private function getLtiConsumer(): string { if ($this->version === self::VERSION_LTI_1P1) { return $this->getLaunchData() ->getLtiConsumer() ->getUri(); } return (string)$this->getLaunchData() ->getVariable(LtiLaunchData::TOOL_CONSUMER_INSTANCE_ID); } }