Skip to content

Commit

Permalink
Merge pull request #46 from oat-sa/release-1.7.1
Browse files Browse the repository at this point in the history
Release 1.7.1
  • Loading branch information
jsconan authored Jan 6, 2017
2 parents 451a43f + cb7c9bc commit d2956c1
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 105 deletions.
56 changes: 16 additions & 40 deletions actions/LtiModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
67 changes: 67 additions & 0 deletions actions/traits/LtiModuleTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*/

namespace oat\taoLti\actions\traits;

use \tao_helpers_Request;
use \common_exception_IsAjaxAction;

trait LtiModuleTrait
{
/**
* 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
* @see tao_actions_CommonModule::returnError()
* @throws \common_exception_IsAjaxAction
*/
protected function returnError($description, $returnLink = true) {
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');
}
}
}
7 changes: 4 additions & 3 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*
*
*/
use oat\tao\model\user\TaoRoles;

/**
* @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
Expand All @@ -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',
Expand All @@ -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(
Expand Down
34 changes: 34 additions & 0 deletions models/classes/LtiRoles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2016 (original work) Open Assessment Technologies SA
*
*/

namespace oat\taoLti\models\classes;

use oat\oatbox\service\ConfigurableService;
/**
* Interface containing the Lti Role URIs
*/
interface LtiRoles
{
const CONTEXT_LEARNER = 'http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#Learner';

const CONTEXT_INSTRUCTOR = 'http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#Instructor';

const CONTEXT_TEACHING_ASSISTANT = 'http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#TeachingAssistant';
}
2 changes: 2 additions & 0 deletions models/classes/class.LtiLaunchData.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class taoLti_models_classes_LtiLaunchData
const OAUTH_CONSUMER_KEY = 'oauth_consumer_key';
const RESOURCE_LINK_ID = 'resource_link_id';
const RESOURCE_LINK_TITLE = 'resource_link_title';
const CONTEXT_ID = 'context_id';
const CONTEXT_LABEL = 'context_label';

const USER_ID = 'user_id';
const ROLES = 'roles';
Expand Down
6 changes: 6 additions & 0 deletions models/classes/class.LtiUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public function getPropertyValues($property) {
case PROPERTY_USER_ROLES :
$returnValue = $this->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();
Expand Down
72 changes: 40 additions & 32 deletions models/ontology/ltiroles_membership.rdf
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
<?xml version="1.0"?>
<rdf:RDF
xml:base="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:generis="http://www.tao.lu/Ontologies/generis.rdf#"
xmlns:widget="http://www.tao.lu/datatypes/WidgetDefinitions.rdf#"
xmlns:taolti="http://www.tao.lu/Ontologies/TAOLTI.rdf#"
xml:base="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:generis="http://www.tao.lu/Ontologies/generis.rdf#"
xmlns:widget="http://www.tao.lu/datatypes/WidgetDefinitions.rdf#"
xmlns:taolti="http://www.tao.lu/Ontologies/TAOLTI.rdf#"
>

<!-- Context roles -->
<rdf:Description rdf:about="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#Learner">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Learner]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Learner Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/Learner]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Learner]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Learner Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/Learner]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#Instructor">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Instructor]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Instructor Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/Instructor]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Instructor]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Instructor Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/Instructor]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#ContentDeveloper">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Content Developer]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Content Developer Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/ContentDeveloper]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Content Developer]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Content Developer Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/ContentDeveloper]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#Administrator">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Administrator]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Administrator Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/Administrator]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
<rdf:Description rdf:about="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#TeachingAssistant">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Teaching Assistant]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Teaching Assistant Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/TeachingAssistant]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>
<rdf:Description rdf:about="http://www.imsglobal.org/imspurl/lis/v1/vocab/membership#Administrator">
<rdf:type rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LTIRole"/>
<rdfs:label xml:lang="en-US"><![CDATA[LTI Administrator]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[The LTI Context Administrator Role]]></rdfs:comment>
<taolti:RoleURN><![CDATA[urn:lti:role:ims/lis/Administrator]]></taolti:RoleURN>
<generis:includesRole rdf:resource="http://www.tao.lu/Ontologies/TAOLTI.rdf#LtiBaseRole"/>
<generis:isSystem rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>
</rdf:RDF>
Loading

0 comments on commit d2956c1

Please sign in to comment.