-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
229 lines (198 loc) · 8.77 KB
/
index.html
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!--
Copyright 2018 Veracity Technology Consultants LLC
Licensed 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.
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Introduction to xAPI Launch</title>
<!-- jquery to support bootstrap and for general dom manipulation -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Optional CSS theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified bootstrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<!-- moment.js for date / time -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
<!-- minified xAPI wrapper to make xAPI calls and handle xAPI Launch -->
<script src="xapiwrapper.min.js"></script>
<!-- Script contains an xAPI statement template, default LRS configuration, and
convenience methods to abstact xAPI complexity -->
<script>
// default conf used if this file is not launched using xAPI launch
var conf = {
"endpoint" : "https://lrslite.veracity.it/xapi/",
"user" : "tom",
"password" : "1234",
};
ADL.XAPIWrapper.changeConfig(conf);
// statement template with default values (some that are replace by xAPI launch)
var myXAPI = {
statement: {
actor: {
account: {
homePage: "https://lrslite.veracity.it/accounts",
name: "demolearner1"
},
name: "Demo Learner"
},
object: {
id: "http://veracity.it/examples/launch-introduction/aus/introduction",
definition: {
name: {"en-US": "Introduction to xAPI Launch"},
description: {"en-US": "This lesson demonstrates the basics of xAPI launch."},
type: "http://adlnet.gov/expapi/activities/lesson"
}
},
context: {
contextActivities: {
"grouping": [
{
"id": "http://veracity.it/examples/launch-introduction"
}
],
"category": [
{
"id":"https://w3id.org/xapi/scorm",
"definition": {
"type":"http://adlnet.gov/expapi/activities/profile"
}
}
]
}
}
}
};
myXAPI.getBase = function () {
return JSON.parse(JSON.stringify(this.statement));
};
myXAPI.initialize = function(starttime) {
this.attemptGUID = ADL.ruuid();
var stmt = this.getBase();
stmt.verb = {
"id" : "http://adlnet.gov/expapi/verbs/initialized",
"display" : {"de-DE" : "initialisierte",
"en-US" : "initialized",
"fr-FR" : "a initialisé",
"es-ES" : "inicializó"}
};
stmt.timestamp = starttime.toISOString();
ADL.XAPIWrapper.sendStatement(stmt, function (resp) {
console.log(resp.status + " - statement id: " + resp.response);
});
};
myXAPI.terminate = function(starttime) {
this.attemptGUID = ADL.ruuid();
var stmt = this.getBase();
stmt.verb = {
"id" : "http://adlnet.gov/expapi/verbs/terminated",
"display" : {"de-DE" : "beendete",
"en-US" : "terminated",
"fr-FR" : "a terminé",
"es-ES" : "terminó"}
};
stmt.timestamp = starttime.toISOString();
ADL.XAPIWrapper.sendStatement(stmt, function (resp) {
console.log(resp.status + " - statement id: " + resp.response);
});
};
myXAPI.getActor = function() {
var stmt = this.getBase();
return JSON.stringify(stmt.actor, null, 2);
}
</script>
<!-- Script to handle page-specific events and display messages -->
<script>
$(document).ready(function () {
//handshake with the Launch server
ADL.launch(function(err,launchdata,wrapper) {
var launchtypemessage = "";
//fall back on the previous hard coded values not launched via xAPI launch
if(err) {
console.error("Failed to Launch!", err);
console.log("fallback on hardcoded config");
launchtypemessage = "Launched without xAPI Launch. Using default values:";
}
else {
myXAPI.statement.actor = launchdata.actor;
ADL.XAPIWrapper = wrapper;
launchtypemessage = "Congratulations. Launched with xAPI Launch. Using launch values:";
}
function showLaunchInfo(){
$('#launch-type').html(launchtypemessage);
$('#actor').html(myXAPI.getActor());
$('#endpoint').html(ADL.XAPIWrapper.lrs.endpoint);
}
function startAttempt() {
myXAPI.initialize(new Date());
showLaunchInfo();
}
// auto run on doc ready
startAttempt();
})
});
$(window).on("beforeunload", function(e) {
myXAPI.terminate(new Date());
});
</script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h2>Introduction to ADL Launch</h2>
<div class="row">
<div class="col-sm-6">
<div class="form-group" id="number-group">
<div class="row">
<div class="col-xs-12">
<span>This example implements xAPI launch to share the LRS endpoint and actor at launch time.
This solution can be used to eliminate hard coded credentials from your web app. The
panel below will display information about the launch of this content.
</span>
</div>
<div class="col-xs-12">
<!-- links to help and where statements can be found -->
</div>
</div>
</div>
</div>
</div>
<div class="row" id="stats-row" style="margin-top:2em;">
<div class="col-sm-6">
<label id="launch-type"></label>
</div>
</div>
<div class="row" id="stats-row" style="margin-top:2em;">
<div class="col-sm-6">
<label id="actor-label">Actor</label>
<pre>
<code id="actor"></code>
</pre>
</div>
</div>
<div class="row" id="stats-row" style="margin-top:2em;">
<div class="col-sm-6">
<label id="endpoint-label">LRS Endpoint: </label> <span id="endpoint"></span>
</div>
</div>
</div>
</body>
</html>