From 7204d77b9ff0f20dd557a26831fe45667aff094e Mon Sep 17 00:00:00 2001 From: John Okely Date: Tue, 9 Feb 2016 10:17:35 +0800 Subject: [PATCH] MDL-52821 lti: Include tool_consumer_instance_description in launch --- mod/lti/locallib.php | 2 ++ mod/lti/tests/externallib_test.php | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index 9840dba6181cf..48d284fbd5df3 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -54,6 +54,7 @@ use moodle\mod\lti as lti; require_once($CFG->dirroot.'/mod/lti/OAuth.php'); +require_once($CFG->libdir.'/weblib.php'); define('LTI_URL_DOMAIN_REGEX', '/(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i'); @@ -503,6 +504,7 @@ function lti_build_standard_request($instance, $orgid, $islti2) { } else { $requestparams['tool_consumer_instance_name'] = get_site()->fullname; } + $requestparams['tool_consumer_instance_description'] = html_to_text(get_site()->summary, 0); return $requestparams; } diff --git a/mod/lti/tests/externallib_test.php b/mod/lti/tests/externallib_test.php index 51cd7b91d422d..00b64d7068795 100644 --- a/mod/lti/tests/externallib_test.php +++ b/mod/lti/tests/externallib_test.php @@ -71,14 +71,16 @@ public function setUp() { * Test view_lti */ public function test_get_tool_launch_data() { - global $USER; + global $USER, $SITE; + + $SITE->summary = "This is a long front page summary with html, it should exceed more than seventy-five characters."; $result = mod_lti_external::get_tool_launch_data($this->lti->id); $result = external_api::clean_returnvalue(mod_lti_external::get_tool_launch_data_returns(), $result); // Basic test, the function returns what it's expected. self::assertEquals($this->lti->toolurl, $result['endpoint']); - self::assertCount(35, $result['parameters']); + self::assertCount(36, $result['parameters']); // Check some parameters. $parameters = array(); @@ -93,6 +95,8 @@ public function test_get_tool_launch_data() { self::assertEquals($USER->lastname, $parameters['lis_person_name_family']); self::assertEquals(fullname($USER), $parameters['lis_person_name_full']); self::assertEquals($USER->username, $parameters['ext_user_username']); + self::assertEquals("This is a LONG front page summary with html, it should exceed more than seventy-five characters.", + $parameters['tool_consumer_instance_description']); }