diff --git a/actions/LtiModule.php b/actions/LtiModule.php index c1f5ca1f..65113669 100755 --- a/actions/LtiModule.php +++ b/actions/LtiModule.php @@ -22,8 +22,7 @@ namespace oat\taoLti\actions; use \tao_actions_CommonModule; -use \tao_helpers_Request; -use \common_exception_IsAjaxAction; +use oat\taoLti\actions\traits\LtiModuleTrait; /** * An abstract lti controller @@ -32,43 +31,20 @@ */ abstract class LtiModule extends tao_actions_CommonModule { + use LtiModuleTrait { + returnError as returnLtiError; + } - /** - * Returns an error page - * - * Ignore the parameter returnLink as LTI session always - * require a way for the consumer to return to his platform - * - * (non-PHPdoc) - * @see tao_actions_CommonModule::returnError() - */ - protected function returnError($description, $returnLink = false) { - if (tao_helpers_Request::isAjax()) { - throw new common_exception_IsAjaxAction(__CLASS__.'::'.__FUNCTION__); - } else { - try { - $launchData = \taoLti_models_classes_LtiService::singleton()->getLtiSession()->getLaunchData(); - $returnUrl = $launchData->getCustomParameter(\taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL); - - // In regard of the IMS LTI standard, we have to show a back button that refer to the - // launch_presentation_return_url url param. So we have to retrieve this parameter before trying to start - // the session - $consumerLabel = $launchData->getToolConsumerName(); - if (!is_null($consumerLabel)) { - $this->setData('consumerLabel', $consumerLabel); - } - - if($launchData->hasVariable(\taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL)) { - $this->setData('returnUrl', $launchData->getReturnUrl()); - } - } catch (\taoLti_models_classes_LtiException $exception) { - // no Lti Session started - } - if (!empty($description)) { - $this->setData('message', $description); - } - $this->setView('error.tpl', 'taoLti'); - } - } - + /** + * Returns an error page + * + * Ignore the parameter returnLink as LTI session always + * require a way for the consumer to return to his platform + * + * @param string $description error to show + * @param boolean $returnLink + */ + protected function returnError($description, $returnLink = true) { + $this->returnLtiError($description, $returnLink); + } } \ No newline at end of file diff --git a/actions/traits/LtiModuleTrait.php b/actions/traits/LtiModuleTrait.php new file mode 100644 index 00000000..3e641be6 --- /dev/null +++ b/actions/traits/LtiModuleTrait.php @@ -0,0 +1,67 @@ +getLtiSession()->getLaunchData(); + $returnUrl = $launchData->getCustomParameter(\taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL); + + // In regard of the IMS LTI standard, we have to show a back button that refer to the + // launch_presentation_return_url url param. So we have to retrieve this parameter before trying to start + // the session + $consumerLabel = $launchData->getToolConsumerName(); + if (!is_null($consumerLabel)) { + $this->setData('consumerLabel', $consumerLabel); + } + + if($launchData->hasVariable(\taoLti_models_classes_LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL)) { + $this->setData('returnUrl', $launchData->getReturnUrl()); + } + } catch (\taoLti_models_classes_LtiException $exception) { + // no Lti Session started + } + if (!empty($description)) { + $this->setData('message', $description); + } + $this->setView('error.tpl', 'taoLti'); + } + } +} \ No newline at end of file diff --git a/manifest.php b/manifest.php index 29ec94bd..980589c7 100755 --- a/manifest.php +++ b/manifest.php @@ -18,6 +18,7 @@ * * */ +use oat\tao\model\user\TaoRoles; /** * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu} @@ -31,10 +32,10 @@ 'label' => 'LTI library', 'description' => 'TAO LTI library and helpers', 'license' => 'GPL-2.0', - 'version' => '1.5.2', + 'version' => '1.7.1', 'author' => 'Open Assessment Technologies SA', 'requires' => array( - 'tao' => '>=5.4.0' + 'tao' => '>=7.45.5' ), 'models' => array( 'http://www.tao.lu/Ontologies/TAOLTI.rdf', @@ -53,7 +54,7 @@ 'managementRole' => 'http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiManagerRole', 'acl' => array( array('grant', 'http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiManagerRole', array('ext'=>'taoLti')), - array('grant', 'http://www.tao.lu/Ontologies/generis.rdf#AnonymousRole',array('ext'=>'taoLti','mod' => 'CookieUtils')), + array('grant', TaoRoles::ANONYMOUS, taoLti_actions_CookieUtils::class), array('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#BaseUserRole', array('ext'=>'taoLti','mod' => 'LtiConsumer', 'act' => 'call')) ), 'constants' => array( diff --git a/models/classes/LtiRoles.php b/models/classes/LtiRoles.php new file mode 100644 index 00000000..edfbf2f3 --- /dev/null +++ b/models/classes/LtiRoles.php @@ -0,0 +1,34 @@ +roles; break; + case PROPERTY_USER_FIRSTNAME : + $returnValue = [$this->getLaunchData()->getUserGivenName()]; + break; + case PROPERTY_USER_LASTNAME : + $returnValue = [$this->getLaunchData()->getUserFamilyName()]; + break; default: common_Logger::d('Unkown property '.$property.' requested from '.__CLASS__); $returnValue = array(); diff --git a/models/ontology/ltiroles_membership.rdf b/models/ontology/ltiroles_membership.rdf index 1629097b..5784b13a 100755 --- a/models/ontology/ltiroles_membership.rdf +++ b/models/ontology/ltiroles_membership.rdf @@ -1,45 +1,53 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + + + + + + + + + diff --git a/models/ontology/ltiroles_person.rdf b/models/ontology/ltiroles_person.rdf index 44a7f1c7..76353420 100755 --- a/models/ontology/ltiroles_person.rdf +++ b/models/ontology/ltiroles_person.rdf @@ -1,46 +1,46 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + diff --git a/scripts/update/class.Updater.php b/scripts/update/class.Updater.php index c5f25420..b3756291 100644 --- a/scripts/update/class.Updater.php +++ b/scripts/update/class.Updater.php @@ -42,5 +42,12 @@ public function update($initialVersion) } $this->skip('1.3.0', '1.5.2'); + + // add teacher assistant role + if ($this->isVersion('1.5.2')) { + OntologyUpdater::syncModels(); + $this->setVersion('1.6.0'); + } + $this->skip('1.6.0', '1.7.1'); } }