hasRequestParameter('ltiConsumerUri')) { throw new common_exception_MissingParameter('ltiConsumerUri', get_class($this)); } if (!$this->hasRequestParameter('ltiLaunchUrl')) { throw new common_exception_MissingParameter('ltiLaunchUrl', get_class($this)); } $ltiConsumer = new tao_models_classes_oauth_Credentials($this->getRequestParameter('ltiConsumerUri')); $launchUrl = $this->getRequestParameter('ltiLaunchUrl'); $serviceCallId = $this->getServiceCallId() . '_c'; $session = common_session_SessionManager::getSession(); $roles = []; foreach ($session->getUserRoles() as $role) { foreach (LtiUtils::mapTaoRole2LTIRoles($role) as $ltiRole) { $roles[] = $ltiRole; } } $ltiData = [ 'lti_message_type' => 'basic-lti-launch-request', 'lti_version' => 'LTI-1p0', 'resource_link_id' => rand(0, 9999999), 'resource_link_title' => 'Launch Title', 'resource_link_label' => 'Launch label', 'context_id' => $serviceCallId, 'context_title' => 'Launch Title', 'context_label' => 'Launch label', 'user_id' => $session->getUserUri(), 'roles' => implode(',', $roles), 'lis_person_name_full' => $session->getUserLabel(), 'tool_consumer_info_product_family_code' => PRODUCT_NAME, 'tool_consumer_info_version' => TAO_VERSION ]; // @todo add: /* user_id: roles: lis_person_name_full: lis_person_name_family: lis_person_name_given: lis_person_contact_email_primary: lis_person_sourcedid: tool_consumer_info_product_family_code: tool_consumer_info_version: tool_consumer_instance_guid: tool_consumer_instance_description: */ $request = new common_http_Request($launchUrl, common_http_Request::METHOD_POST, $ltiData); $service = new tao_models_classes_oauth_Service(); $signedRequest = $service->sign($request, $ltiConsumer); $this->setData('launchUrl', $launchUrl); $this->setData('ltiData', $signedRequest->getParams()); $this->setData('client_config_url', $this->getClientConfigUrl()); $this->setView('ltiConsumer.tpl'); } }