-
Notifications
You must be signed in to change notification settings - Fork 0
/
offline_xapi_adl_wrapper.js
60 lines (48 loc) · 1.31 KB
/
offline_xapi_adl_wrapper.js
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
var actor = {
"objectType": "Agent",
"name": "Testy McTestface",
"account": {
"homePage": "http://www.example.com/users",
"name": "1234567890"
}
};
window.xapiWrapper = Object.create(window.ADL.XAPIWrapper);
Object.assign(window.xapiWrapper, {
lrs: {
actor: JSON.stringify(actor)
},
getState: function(activityid, agent, stateid, registration, since, callback) {
var existingState = Cookies.get(stateid);
if (existingState) {
return callback(null, {
status: 200,
response: existingState
});
}
return callback(null, {
status: 404,
response: null
});
},
sendStatement: function(stmt, callback) {
console.log("xAPI statement sent:");
console.log(JSON.stringify(stmt));
return callback();
},
sendState: function(activityid, agent, stateid, registration, stateval, matchHash, noneMatchHash, callback) {
console.log("xAPI state sent - " + stateid + ":");
console.log(stateval);
Cookies.set(stateid, stateval);
return true;
},
updateAuth: function(a, b, c) {
return true;
}
});
window.ADL.launch = function(cb, terminate_on_unload, strict_callbacks) {
return cb(null, {
actor: actor,
endpoint: 'http://launch-server.example.com'
}, window.xapiWrapper);
};
window.ADL = Object.freeze(window.ADL);