getServiceManager()->get(ThemeServiceInterface::SERVICE_ID); if ($themeService instanceof ThemeServiceInterface || $themeService instanceof LtiHeadless) { return !$themeService->isHeadless(); } return false; } protected function getReturnUrl() { $deliveryExecution = $this->getCurrentDeliveryExecution(); return _url( 'ltiReturn', 'DeliveryRunner', 'ltiDeliveryProvider', ['deliveryExecution' => $deliveryExecution->getIdentifier()] ); } public function ltiReturn() { $navigation = $this->getServiceLocator()->get(LtiNavigationService::SERVICE_ID); $deliveryExecution = $this->getCurrentDeliveryExecution(); $launchData = LtiService::singleton()->getLtiSession()->getLaunchData(); $this->redirect($navigation->getReturnUrl($launchData, $deliveryExecution)); } /** * Shown uppon returning to a finished delivery execution */ public function ltiOverview() { $this->setData('delivery', $this->getRequestParameter('delivery')); $this->setData('allowRepeat', true); $this->setView('learner/overview.tpl'); } /** * @throws LtiException * @throws \InterruptedActionException * @throws \ResolverException * @throws \common_exception_Error * @throws \common_exception_IsAjaxAction * @throws \oat\taoLti\models\classes\LtiVariableMissingException */ public function repeat() { $delivery = new \core_kernel_classes_Resource($this->getRequestParameter('delivery')); $remoteLink = LtiService::singleton()->getLtiSession()->getLtiLinkResource(); $user = \common_session_SessionManager::getSession()->getUser(); try { $newExecution = $this->getServiceLocator()->get(LTIDeliveryTool::class)->startDelivery( $delivery, $remoteLink, $user ); $deliveryExecutionStateService = $this->getServiceLocator()->get(StateServiceInterface::SERVICE_ID); $deliveryExecutionStateService->pause($newExecution); $runDeliveryExecutionUrl = $this->getServiceLocator()->get(UrlHelper::class)->buildUrl( 'runDeliveryExecution', null, null, ['deliveryExecution' => $newExecution->getIdentifier()] ); $this->redirect($runDeliveryExecutionUrl); } catch (\common_exception_Unauthorized $e) { $ltiException = new LtiException( $e->getMessage(), LtiErrorMessage::ERROR_LAUNCH_FORBIDDEN ); $this->returnLtiError($ltiException); } } /** * @throws LtiException * @throws \common_exception_Error * @throws \oat\taoLti\models\classes\LtiVariableMissingException */ public function thankYou() { $launchData = LtiService::singleton()->getLtiSession()->getLaunchData(); if ($launchData->hasVariable(LtiLaunchData::TOOL_CONSUMER_INSTANCE_NAME)) { $this->setData('consumerLabel', $launchData->getVariable(LtiLaunchData::TOOL_CONSUMER_INSTANCE_NAME)); } elseif ($launchData->hasVariable(LtiLaunchData::TOOL_CONSUMER_INSTANCE_DESCRIPTION)) { $this->setData('consumerLabel', $launchData->getVariable(LtiLaunchData::TOOL_CONSUMER_INSTANCE_DESCRIPTION)); } if ($launchData->hasReturnUrl()) { $this->setData('returnUrl', $launchData->getReturnUrl()); } if ($launchData->hasVariable(DeliveryTool::PARAM_THANKYOU_MESSAGE)) { $this->setData('message', $launchData->getVariable(DeliveryTool::PARAM_THANKYOU_MESSAGE)); } $this->setData('allowRepeat', false); $this->setView('learner/thankYou.tpl'); } /** * Redirect user to return URL */ public function finishDeliveryExecution() { $deliveryExecution = null; if ($this->hasRequestParameter('deliveryExecution')) { $deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution( $this->getRequestParameter('deliveryExecution') ); if ($deliveryExecution->getState() !== DeliveryExecution::STATE_FINISHIED) { $stateService = $this->getServiceLocator()->get(StateServiceInterface::SERVICE_ID); $stateService->finish($deliveryExecution); } } $redirectUrl = $this->getServiceLocator()->get(LTIDeliveryTool::class)->getFinishUrl($deliveryExecution); $this->redirect($redirectUrl); } }