-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathxapi_launch.php
123 lines (113 loc) · 3.93 KB
/
xapi_launch.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* Licensed to The Apereo Foundation under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
* The Apereo Foundation licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Make sure that play does not use cookie based sessions
* Thise requires to switch off cookiebased sessions and some helper functions.
*
* If this is an LTI session, do not use this functionality, because tsugi will handle the session
*
* This must be done before loading config.php
*/
global $lti_enabled;
if (!isset($lti_enabled))
{
$lti_enabled = false;
}
if (!$lti_enabled)
{
require_once(dirname(__FILE__) . "/session_helpers.php");
ini_set('session.use_cookies', 0);
ini_set('session.use_only_cookies', 0);
ini_set('session.use_trans_sid', 1);
}
require_once(dirname(__FILE__) . "/config.php");
require_once(dirname(__FILE__) . "/website_code/php/xAPI/xAPI_library.php");
global $xerte_toolkits_site;
global $xapi_enabled;
global $x_embed;
global $x_embed_activated;
$id = $_GET["template_id"];
if(is_numeric($id))
{
if (!isset($_REQUEST['group']))
{
die('group parameter not supplied!');
}
$xapi_enabled = true;
// Get LRS endpoint and see if xAPI is enabled
$prefix = $xerte_toolkits_site->database_table_prefix;
$q = "select * from {$prefix}templatedetails where template_id=?";
$params = array($id);
$row = db_query_one($q, $params);
if ($row === false)
{
die("template_id not found");
}
if ($row['tsugi_xapi_useglobal'])
{
$q = "select LRS_Endpoint, LRS_Key, LRS_Secret from {$prefix}sitedetails where site_id=1";
$globalrow = db_query_one($q);
$lrs = array('lrsendpoint' => $globalrow['LRS_Endpoint'],
'lrskey' => $globalrow['LRS_Key'],
'lrssecret' => $globalrow['LRS_Secret'],
);
}
else{
$lrs = array('lrsendpoint' => $row['tsugi_xapi_endpoint'],
'lrskey' => $row['tsugi_xapi_key'],
'lrssecret' => $row['tsugi_xapi_secret'],
);
}
$lrs = CheckLearningLocker($lrs, true);
$_SESSION['XAPI_PROXY'] = $lrs;
$xerte_toolkits_site->group = $_REQUEST['group'];
if (isset($_REQUEST['actor'])) {
$xapi_user = new stdClass();
$xapi_user->email = $_REQUEST['actor'];
$pos = strpos($xapi_user->email, '@');
if ($pos === false)
{
$xapi_user->displayname = $xapi_user->email;
$xapi_user->email .= "@example.com";
$xapi_user->email = str_replace(' ', '', $xapi_user->email);
$xapi_user->studentidmode = 2;
}
else{
$xapi_user->displayname = substr($xapi_user->email, 0, $pos);
$xapi_user->studentidmode = 0;
}
$xerte_toolkits_site->xapi_user = $xapi_user;
}
if (isset($_REQUEST['course'])) {
$xerte_toolkits_site->course = $_REQUEST['course'];
}
if (isset($_REQUEST['module'])) {
$xerte_toolkits_site->course = $_REQUEST['module'];
}
_debug("xapi_launch: SESSION=" . print_r($_SESSION, true));
if (isset($_GET['x_embed']) && $_GET['x_embed'] === 'true') {
$x_embed = true;
if ($_GET['activated'] !== 'true') {
$xapi_enabled = false;
$x_embed_activated = false;
} else {
$x_embed_activated = true;
}
}
require("play.php");
}