-
Notifications
You must be signed in to change notification settings - Fork 10
/
ltilaunch.php
81 lines (67 loc) · 2.64 KB
/
ltilaunch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* LTI Launch page.
* Designed to be called as a link in an iframe to prepare the lti launch data and perform the launch.
*
* @package filter_opencast
* @copyright 2024 Farbod Zamani Boroujeni, ELAN e.V.
* @author Farbod Zamani Boroujeni <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use filter_opencast\local\lti_helper;
require(__DIR__ . '/../../config.php');
global $PAGE;
$courseid = required_param('courseid', PARAM_INT);
$ocinstanceid = required_param('ocinstanceid', PARAM_INT);
$episodeid = required_param('episodeid', PARAM_ALPHANUMEXT);
$baseurl = lti_helper::get_filter_lti_launch_url($ocinstanceid, $courseid, $episodeid, false);
$PAGE->set_pagelayout('embedded');
$PAGE->set_url($baseurl);
require_login($courseid, false);
if (confirm_sesskey()) {
$ltisetobject = lti_helper::get_lti_set_object($ocinstanceid);
$customtool = "/play/{$episodeid}";
$endpoint = rtrim($ltisetobject->baseurl, '/') . '/lti';
$ltiparams = lti_helper::create_lti_parameters(
$ltisetobject->consumerkey,
$ltisetobject->consumersecret,
$endpoint,
$customtool,
$courseid
);
$formid = "ltiLaunchForm-{$episodeid}";
$formattributed = [
'action' => $endpoint,
'method' => 'post',
'id' => $formid,
'name' => $formid,
'encType' => 'application/x-www-form-urlencoded',
];
echo html_writer::start_tag('form', $formattributed);
foreach ($ltiparams as $name => $value) {
$attributes = ['type' => 'hidden', 'name' => htmlspecialchars($name), 'value' => htmlspecialchars($value)];
echo html_writer::empty_tag('input', $attributes) . "\n";
}
echo html_writer::end_tag('form');
echo html_writer::script(
"window.onload = function() {
document.getElementById('{$formid}').submit();
};"
);
exit();
}
throw new \moodle_exception('ltilaunch_failed', 'filter_opencast', $baseurl);