mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
MDL-62640 enrol_lti: Adjust code for slashargument removal
This commit is contained in:
parent
4d2ad0bff7
commit
979db77a63
@ -450,58 +450,26 @@ class helper {
|
||||
/**
|
||||
* Returns the url to the cartridge representing the tool.
|
||||
*
|
||||
* If you have slash arguments enabled, this will be a nice url ending in cartridge.xml.
|
||||
* If not it will be a php page with some parameters passed.
|
||||
*
|
||||
* @param \stdClass $tool The lti tool
|
||||
* @return string The url to the cartridge representing the tool
|
||||
* @since Moodle 3.2
|
||||
*/
|
||||
public static function get_cartridge_url($tool) {
|
||||
global $CFG;
|
||||
$url = null;
|
||||
|
||||
$id = $tool->id;
|
||||
$token = self::generate_cartridge_token($tool->id);
|
||||
if ($CFG->slasharguments) {
|
||||
$url = new \moodle_url('/enrol/lti/cartridge.php/' . $id . '/' . $token . '/cartridge.xml');
|
||||
} else {
|
||||
$url = new \moodle_url('/enrol/lti/cartridge.php',
|
||||
array(
|
||||
'id' => $id,
|
||||
'token' => $token
|
||||
)
|
||||
);
|
||||
}
|
||||
return $url;
|
||||
return new \moodle_url('/enrol/lti/cartridge.php/' . $id . '/' . $token . '/cartridge.xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the url to the tool proxy registration url.
|
||||
*
|
||||
* If you have slash arguments enabled, this will be a nice url ending in cartridge.xml.
|
||||
* If not it will be a php page with some parameters passed.
|
||||
*
|
||||
* @param \stdClass $tool The lti tool
|
||||
* @return string The url to the cartridge representing the tool
|
||||
*/
|
||||
public static function get_proxy_url($tool) {
|
||||
global $CFG;
|
||||
$url = null;
|
||||
|
||||
$id = $tool->id;
|
||||
$token = self::generate_proxy_token($tool->id);
|
||||
if ($CFG->slasharguments) {
|
||||
$url = new \moodle_url('/enrol/lti/proxy.php/' . $id . '/' . $token . '/');
|
||||
} else {
|
||||
$url = new \moodle_url('/enrol/lti/proxy.php',
|
||||
array(
|
||||
'id' => $id,
|
||||
'token' => $token
|
||||
)
|
||||
);
|
||||
}
|
||||
return $url;
|
||||
return new \moodle_url('/enrol/lti/proxy.php/' . $id . '/' . $token . '/');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,8 @@ namespace enrol_lti;
|
||||
* @package enrol_lti
|
||||
* @copyright 2016 Mark Nelson <markn@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
* @covers \enrol_lti\helper
|
||||
*/
|
||||
class helper_test extends \advanced_testcase {
|
||||
|
||||
@ -260,12 +262,6 @@ class helper_test extends \advanced_testcase {
|
||||
* Test getting the cartridge url of a tool.
|
||||
*/
|
||||
public function test_get_cartridge_url(): void {
|
||||
global $CFG;
|
||||
|
||||
$slasharguments = $CFG->slasharguments;
|
||||
|
||||
$CFG->slasharguments = false;
|
||||
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$data = new \stdClass();
|
||||
$data->courseid = $course1->id;
|
||||
@ -273,29 +269,16 @@ class helper_test extends \advanced_testcase {
|
||||
|
||||
$id = $tool1->id;
|
||||
$token = \enrol_lti\helper::generate_cartridge_token($id);
|
||||
$launchurl = \enrol_lti\helper::get_cartridge_url($tool1);
|
||||
$this->assertEquals('https://www.example.com/moodle/enrol/lti/cartridge.php?id=' . $id . '&token=' . $token,
|
||||
$launchurl->out());
|
||||
|
||||
$CFG->slasharguments = true;
|
||||
|
||||
/** @var \moodle_url $launchurl */
|
||||
$launchurl = \enrol_lti\helper::get_cartridge_url($tool1);
|
||||
$this->assertEquals('https://www.example.com/moodle/enrol/lti/cartridge.php/' . $id . '/' . $token . '/cartridge.xml',
|
||||
$launchurl->out());
|
||||
|
||||
$CFG->slasharguments = $slasharguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting the cartridge url of a tool.
|
||||
*/
|
||||
public function test_get_proxy_url(): void {
|
||||
global $CFG;
|
||||
|
||||
$slasharguments = $CFG->slasharguments;
|
||||
|
||||
$CFG->slasharguments = false;
|
||||
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$data = new \stdClass();
|
||||
$data->courseid = $course1->id;
|
||||
@ -303,17 +286,10 @@ class helper_test extends \advanced_testcase {
|
||||
|
||||
$id = $tool1->id;
|
||||
$token = \enrol_lti\helper::generate_proxy_token($id);
|
||||
$launchurl = \enrol_lti\helper::get_proxy_url($tool1);
|
||||
$this->assertEquals('https://www.example.com/moodle/enrol/lti/proxy.php?id=' . $id . '&token=' . $token,
|
||||
$launchurl->out());
|
||||
|
||||
$CFG->slasharguments = true;
|
||||
|
||||
/** @var \moodle_url $launchurl */
|
||||
$launchurl = \enrol_lti\helper::get_proxy_url($tool1);
|
||||
$this->assertEquals('https://www.example.com/moodle/enrol/lti/proxy.php/' . $id . '/' . $token . '/',
|
||||
$launchurl->out());
|
||||
|
||||
$CFG->slasharguments = $slasharguments;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user