forked from jmkevan/xapiVisualizations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveracityDataCall.html
73 lines (61 loc) · 1.64 KB
/
veracityDataCall.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="js/d3.min.js"></script>
<title>lrsDataCall</title>
<script type="text/javascript">
// Basic example of pulling data from the LRS
window.onload = function() {
var URL = 'https://videocohort.lrs.io/xapi/statements/aggregate';
var pipeline =
[
{
$match: {
"statement.verb.display.en-US":"played"
}
},
{
$group : {
_id : "$statement.actor.mbox",
count: {$sum:1}
},
},
{
$sort : {"count" : 1}
},
{
$project : {
_id : 0,
name : "$_id",
count : "$count"
}
}
];
$.ajaxSetup({
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
xhr.setRequestHeader("X-Experience-API-Version", "1.0.0");
},
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(pipeline)
});
$.ajax({
dataType: "json",
url: URL,
success: success
});
}
function success(e) {
$('#result').html('File Loaded!');
console.log(JSON.stringify(e.result));
}
</script>
</head>
<body>
<div id="result"></div>
</body>
</html>