Skip to content

Commit

Permalink
Fix IMS/LTI plugin - refs #5333
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Sep 14, 2016
1 parent 13b1de8 commit 43f1870
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin/ims_lti/create.php
Expand Up @@ -23,7 +23,7 @@
$externalTool
->setName($formValues['name'])
->setDescription($formValues['description'])
->setLaunchUrl($formValues['url'])
->setLaunchUrl($formValues['base_url'])
->setConsumerKey($formValues['consumer_key'])
->setSharedSecret($formValues['shared_secret'])
->setCustomParams($formValues['custom_params'])
Expand Down
25 changes: 19 additions & 6 deletions plugin/ims_lti/form.php
@@ -1,5 +1,9 @@
<?php
/* For license terms, see /license.txt */

use Chamilo\UserBundle\Entity\User;
use Chamilo\CoreBundle\Entity\Course;

require '../../main/inc/global.inc.php';
require './OAuthSimple.php';

Expand All @@ -8,20 +12,29 @@
$toolId = isset($_GET['id']) ? intval($_GET['id']) : 0;

$em = Database::getManager();
/** @var ImsLtiPlugin $imsLtiPlugin */
$imsLtiPlugin = ImsLtiPlugin::create();

/** @var ImsLtiTool $tool */
$tool = ImsLtiTool::fetch($toolId);
/** @var Course $course */
$course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id());
/** @var User $user */
$user = $em->find('ChamiloUserBundle:User', api_get_user_id());

$siteName = api_get_setting('siteName');
$institution = api_get_setting('Institution');
$toolUserId = "$siteName - $institution - {$user->getId()}";
$toolUserId = api_replace_dangerous_char($toolUserId);

$params = [
'lti_message_type' => 'basic-lti-launch-request',
'lti_version' => 'LTI-1p0',

'resource_link_id' => $tool->getId(),
'resource_link_title' => $tool->getName(),

'user_id' => 'chamilo110x-' . $user->getId(),
'user_id' => $toolUserId,
'roles' => api_is_teacher() ? 'Instructor' : 'Student',

'lis_person_name_given' => $user->getFirstname(),
Expand All @@ -36,11 +49,11 @@
'launch_presentation_locale' => api_get_language_isocode(),
'launch_presentation_document_target' => 'embed',

'tool_consumer_info_product_family_code' => 'canvas',
'tool_consumer_info_version' => '1.10.2',
'tool_consumer_instance_guid' => 'campus.chamilo.org',
'tool_consumer_instance_name' => api_get_setting('siteName'),
'tool_consumer_instance_url' => api_get_setting('InstitutionUrl'),
'tool_consumer_info_product_family_code' => 'Chamilo LMS',
'tool_consumer_info_version' => api_get_version(),
'tool_consumer_instance_guid' => api_get_setting('InstitutionUrl'),
'tool_consumer_instance_name' => $siteName,
'tool_consumer_instance_url' => api_get_path(WEB_PATH),
'tool_consumer_instance_contact_email' => api_get_setting('emailAdministrator'),

'resource_link_description' => 'A quick revision PowerPoint about the Water cycle. Make sure you\'re clear about it!',
Expand Down
8 changes: 7 additions & 1 deletion plugin/ims_lti/start.php
Expand Up @@ -7,7 +7,13 @@
$toolId = isset($_GET['id']) ? intval($_GET['id']) : 0;

if (empty($toolId)) {
api_not_allowed();
if (api_is_platform_admin()) {
header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/create.php');
exit;
}

api_not_allowed(true);
exit;
}

$imsLtiPlugin = ImsLtiPlugin::create();
Expand Down

0 comments on commit 43f1870

Please sign in to comment.