forked from UnizinAnalytics/caliper-js-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
129 lines (105 loc) · 5.74 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
<html>
<head>
<title>Caliper JS Sensor Test Page</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
<script src="dist/caliperSensor-1.0.0.js"></script>
</head>
<body>
<h1>Caliper JS Sensor Test</h1>
<script type="text/javascript">
$(document).ready(function() {
// Initialize sensor with options
var sensor = Caliper.Sensor;
sensor.initialize({
host: '127.0.0.1',
port: '8070',
path: '/v1custom/eventdata'
});
// The Actor for the Caliper Event
var actor = new Caliper.Person("https://example.edu/user/554433");
actor.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
actor.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// The Action for the Caliper Event
var action = Caliper.NavigationActions.NAVIGATED_TO;
// The Object being interacted with by the Actor
var eventObj = new Caliper.EPubVolume("https://example.com/viewer/book/34843#epubcfi(/4/3)");
eventObj.setName("The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)");
eventObj.setVersion("2nd ed.");
eventObj.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
eventObj.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// The target object (frame) within the Event Object
var target = new Caliper.Frame("https://example.com/viewer/book/34843#epubcfi(/4/3/1)");
target.setName("Key Figures: George Washington");
target.setIsPartOf(eventObj)
target.setVersion(eventObj.version);
target.setIndex(1);
target.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
target.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// Specific to the Navigation Event - the location where the user navigated from
var navigatedFrom = new Caliper.WebPage("https://example.edu/politicalScience/2015/american-revolution-101/index.html");
navigatedFrom.setName("American Revolution 101 Landing Page");
navigatedFrom.setVersion("1.0");
navigatedFrom.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
navigatedFrom.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// The edApp that is part of the Learning Context
var edApp = new Caliper.SoftwareApplication("https://example.com/viewer");
edApp.setName("ePub");
edApp.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
edApp.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// LIS Course Offering
var courseOffering = new Caliper.CourseOffering("https://example.edu/politicalScience/2015/american-revolution-101");
courseOffering.setName("Political Science 101: The American Revolution");
courseOffering.setCourseNumber("POL101");
courseOffering.setAcademicSession("Fall-2015");
courseOffering.setSubOrganizationOf(null);
courseOffering.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
courseOffering.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// LIS Course Section
var courseSection = new Caliper.CourseSection("https://example.edu/politicalScience/2015/american-revolution-101/section/001");
courseSection.setName("American Revolution 101");
courseSection.setCourseNumber("POL101");
courseSection.setAcademicSession("Fall-2015");
courseSection.setSubOrganizationOf(courseOffering);
courseSection.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
courseSection.setDateModified((new Date("2015-09-02T11:30:00Z")).toISOString());
// LIS Group
var group = new Caliper.Group("https://example.edu/politicalScience/2015/american-revolution-101/section/001/group/001");
group.setName("Discussion Group 001");
group.setSubOrganizationOf(courseSection);
group.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
// The Actor's Membership
var membership = new Caliper.Membership("https://example.edu/politicalScience/2015/american-revolution-101/roster/554433");
membership.setName("American Revolution 101");
membership.setDescription("Roster entry");
membership.setMember(actor['@id']);
membership.setOrganization(courseSection['@id']);
membership.setRoles([Caliper.Role.LEARNER]);
membership.setStatus(Caliper.Status.ACTIVE);
membership.setDateCreated((new Date("2015-08-01T06:00:00Z")).toISOString());
// Event
var event = new Caliper.Event();
event.setActor(actor);
event.setAction(action);
event.setObject(eventObj);
event.setTarget(target);
event.setNavigatedFrom(navigatedFrom);
event.setStartedAtTime((new Date("2015-09-15T10:15:00Z")).toISOString());
event.setEdApp(edApp);
event.setGroup(group);
event.setMembership(membership);
event.setFederatedSession("https://example.edu/lms/federatedSession/123456789");
console.log('created navigation event %O', event);
var currentTimeMillis = (new Date()).getTime().toISOString;
// Send the Event
var envelope = new Caliper.Envelope();
envelope.setSensor("https://example.edu/sensor/001");
envelope.setSendTime(currentTimeMillis);
envelope.setData(event);
//envelope['_id'] = 'caliper-js' + currentTimeMillis;
//envelope.d = event;
console.log('created event envelope %O', envelope);
sensor.send(envelope);
});
</script>
</body>
</html>