-
Notifications
You must be signed in to change notification settings - Fork 2
/
TinLauncher.js
94 lines (68 loc) · 2.52 KB
/
TinLauncher.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
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
/*
=============COPYRIGHT============
Tin Statement Sender - An I-Did-This prototype for Tin Can API 0.95
Copyright (C) 2012 Andrew Downes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
<http://www.gnu.org/licenses/>.
*/
/*============DOCUMENT READY==============*/
$(function(){
//Set Up LRS
//Add one blank LRS to the page by default
appendLRS();
//Set up Actor
appendGroup('actorAgent').addClass('displayNone');
appendAgent('actorAgent');
$('#actorObjectType').change({elementId: 'actor'},ObjectTypeChanged);
$('#actorAgentAdd').click({elementId: 'actorAgent'},appendAgentOnEvent);
$('#actorAgentRemove').click({elementId: 'actorAgent', propertyClass: 'agent', minimum:0},removeProperty);
//send statement
$('#sendStatement').click(launchCaptivate);
//Set debug defaults
var setDebugDefaults = true;
if (setDebugDefaults){
$('#endpoint0').val('http://cloud.scorm.com/ScormEngineInterface/TCAPI/public/');
$('#basicLogin0').val('x');
$('#basicPass0').val('x');
$('#actorAgentName1').val('Andrew Downes');
$('#actorAgentFunctionalIdentifier1').val('andrew@tincanapi.co.uk');
$('#launchURL').val('');
}
});
/*============END DOCUMENT READY==============*/
/*============SEND STATEMENT==============*/
function launchCaptivate()
{
//Create an instance of the Tin Can Library
var myTinCan = new TinCan();
myTinCan.DEBUG = 1;
var launchLink = $('#launchURL').val();
launchLink += '?endpoint=' + $('.endpoint').val();
launchLink += '&auth=Basic ' + Base64.encode($('.basicLogin').val() + ':' + $('.basicPass').val());
var myActor;
switch($('#actorObjectType').val())
{
case 'Agent':
myActor = getActor($('#actor').find('.agent:first'));
break;
case 'Group':
myActor = getActor($('#actor').find('.group:first'), 'Group');
console.log(JSON.stringify(myActor));
$('#actor').find('.agent').each(function(index){
var agentToAddToGroup = getActor($(this));
myActor.member.push(agentToAddToGroup);
});
break;
}
launchLink += '&actor=' + JSON.stringify(myActor.asVersion('1.0.0'));
if ($('#registration').val()){
launchLink += '®istration=' + $('#registration').val();
}
window.open(launchLink);
}