1 |
efrain |
1 |
// This file is part of Moodle - http://moodle.org/
|
|
|
2 |
//
|
|
|
3 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
15 |
|
|
|
16 |
// Used need to debug cmi content (if you uncomment this, you must comment the definition inside SCORMapi1_3)
|
|
|
17 |
//var cmi = new Object();
|
|
|
18 |
|
|
|
19 |
//
|
|
|
20 |
// SCORM 1.3 API Implementation
|
|
|
21 |
//
|
|
|
22 |
function SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit) {
|
|
|
23 |
|
|
|
24 |
var prerequrl = cfgwwwroot + "/mod/scorm/prereqs.php?a=" + scormid + "&scoid=" + scoid + "&attempt=" + attempt + "&mode=" + viewmode + "¤torg=" + currentorg + "&sesskey=" + sesskey;
|
|
|
25 |
var datamodelurl = cfgwwwroot + "/mod/scorm/datamodel.php";
|
|
|
26 |
var datamodelurlparams = "id=" + cmid + "&a=" + scormid + "&sesskey=" + sesskey + "&attempt=" + attempt + "&scoid=" + scoid;
|
|
|
27 |
|
|
|
28 |
// Standard Data Type Definition
|
|
|
29 |
|
|
|
30 |
// language key has to be checked for language dependent strings
|
|
|
31 |
var validLanguages = {'aa':'aa', 'ab':'ab', 'ae':'ae', 'af':'af', 'ak':'ak', 'am':'am', 'an':'an', 'ar':'ar', 'as':'as', 'av':'av', 'ay':'ay', 'az':'az',
|
|
|
32 |
'ba':'ba', 'be':'be', 'bg':'bg', 'bh':'bh', 'bi':'bi', 'bm':'bm', 'bn':'bn', 'bo':'bo', 'br':'br', 'bs':'bs',
|
|
|
33 |
'ca':'ca', 'ce':'ce', 'ch':'ch', 'co':'co', 'cr':'cr', 'cs':'cs', 'cu':'cu', 'cv':'cv', 'cy':'cy',
|
|
|
34 |
'da':'da', 'de':'de', 'dv':'dv', 'dz':'dz', 'ee':'ee', 'el':'el', 'en':'en', 'eo':'eo', 'es':'es', 'et':'et', 'eu':'eu',
|
|
|
35 |
'fa':'fa', 'ff':'ff', 'fi':'fi', 'fj':'fj', 'fo':'fo', 'fr':'fr', 'fy':'fy', 'ga':'ga', 'gd':'gd', 'gl':'gl', 'gn':'gn', 'gu':'gu', 'gv':'gv',
|
|
|
36 |
'ha':'ha', 'he':'he', 'hi':'hi', 'ho':'ho', 'hr':'hr', 'ht':'ht', 'hu':'hu', 'hy':'hy', 'hz':'hz',
|
|
|
37 |
'ia':'ia', 'id':'id', 'ie':'ie', 'ig':'ig', 'ii':'ii', 'ik':'ik', 'io':'io', 'is':'is', 'it':'it', 'iu':'iu',
|
|
|
38 |
'ja':'ja', 'jv':'jv', 'ka':'ka', 'kg':'kg', 'ki':'ki', 'kj':'kj', 'kk':'kk', 'kl':'kl', 'km':'km', 'kn':'kn', 'ko':'ko', 'kr':'kr', 'ks':'ks', 'ku':'ku', 'kv':'kv', 'kw':'kw', 'ky':'ky',
|
|
|
39 |
'la':'la', 'lb':'lb', 'lg':'lg', 'li':'li', 'ln':'ln', 'lo':'lo', 'lt':'lt', 'lu':'lu', 'lv':'lv',
|
|
|
40 |
'mg':'mg', 'mh':'mh', 'mi':'mi', 'mk':'mk', 'ml':'ml', 'mn':'mn', 'mo':'mo', 'mr':'mr', 'ms':'ms', 'mt':'mt', 'my':'my',
|
|
|
41 |
'na':'na', 'nb':'nb', 'nd':'nd', 'ne':'ne', 'ng':'ng', 'nl':'nl', 'nn':'nn', 'no':'no', 'nr':'nr', 'nv':'nv', 'ny':'ny',
|
|
|
42 |
'oc':'oc', 'oj':'oj', 'om':'om', 'or':'or', 'os':'os', 'pa':'pa', 'pi':'pi', 'pl':'pl', 'ps':'ps', 'pt':'pt',
|
|
|
43 |
'qu':'qu', 'rm':'rm', 'rn':'rn', 'ro':'ro', 'ru':'ru', 'rw':'rw',
|
|
|
44 |
'sa':'sa', 'sc':'sc', 'sd':'sd', 'se':'se', 'sg':'sg', 'sh':'sh', 'si':'si', 'sk':'sk', 'sl':'sl', 'sm':'sm', 'sn':'sn', 'so':'so', 'sq':'sq', 'sr':'sr', 'ss':'ss', 'st':'st', 'su':'su', 'sv':'sv', 'sw':'sw',
|
|
|
45 |
'ta':'ta', 'te':'te', 'tg':'tg', 'th':'th', 'ti':'ti', 'tk':'tk', 'tl':'tl', 'tn':'tn', 'to':'to', 'tr':'tr', 'ts':'ts', 'tt':'tt', 'tw':'tw', 'ty':'ty',
|
|
|
46 |
'ug':'ug', 'uk':'uk', 'ur':'ur', 'uz':'uz', 've':'ve', 'vi':'vi', 'vo':'vo',
|
|
|
47 |
'wa':'wa', 'wo':'wo', 'xh':'xh', 'yi':'yi', 'yo':'yo', 'za':'za', 'zh':'zh', 'zu':'zu',
|
|
|
48 |
'aar':'aar', 'abk':'abk', 'ave':'ave', 'afr':'afr', 'aka':'aka', 'amh':'amh', 'arg':'arg', 'ara':'ara', 'asm':'asm', 'ava':'ava', 'aym':'aym', 'aze':'aze',
|
|
|
49 |
'bak':'bak', 'bel':'bel', 'bul':'bul', 'bih':'bih', 'bis':'bis', 'bam':'bam', 'ben':'ben', 'tib':'tib', 'bod':'bod', 'bre':'bre', 'bos':'bos',
|
|
|
50 |
'cat':'cat', 'che':'che', 'cha':'cha', 'cos':'cos', 'cre':'cre', 'cze':'cze', 'ces':'ces', 'chu':'chu', 'chv':'chv', 'wel':'wel', 'cym':'cym',
|
|
|
51 |
'dan':'dan', 'ger':'ger', 'deu':'deu', 'div':'div', 'dzo':'dzo', 'ewe':'ewe', 'gre':'gre', 'ell':'ell', 'eng':'eng', 'epo':'epo', 'spa':'spa', 'est':'est', 'baq':'baq', 'eus':'eus', 'per':'per',
|
|
|
52 |
'fas':'fas', 'ful':'ful', 'fin':'fin', 'fij':'fij', 'fao':'fao', 'fre':'fre', 'fra':'fra', 'fry':'fry', 'gle':'gle', 'gla':'gla', 'glg':'glg', 'grn':'grn', 'guj':'guj', 'glv':'glv',
|
|
|
53 |
'hau':'hau', 'heb':'heb', 'hin':'hin', 'hmo':'hmo', 'hrv':'hrv', 'hat':'hat', 'hun':'hun', 'arm':'arm', 'hye':'hye', 'her':'her',
|
|
|
54 |
'ina':'ina', 'ind':'ind', 'ile':'ile', 'ibo':'ibo', 'iii':'iii', 'ipk':'ipk', 'ido':'ido', 'ice':'ice', 'isl':'isl', 'ita':'ita', 'iku':'iku',
|
|
|
55 |
'jpn':'jpn', 'jav':'jav', 'geo':'geo', 'kat':'kat', 'kon':'kon', 'kik':'kik', 'kua':'kua', 'kaz':'kaz', 'kal':'kal', 'khm':'khm', 'kan':'kan', 'kor':'kor', 'kau':'kau', 'kas':'kas', 'kur':'kur', 'kom':'kom', 'cor':'cor', 'kir':'kir',
|
|
|
56 |
'lat':'lat', 'ltz':'ltz', 'lug':'lug', 'lim':'lim', 'lin':'lin', 'lao':'lao', 'lit':'lit', 'lub':'lub', 'lav':'lav',
|
|
|
57 |
'mlg':'mlg', 'mah':'mah', 'mao':'mao', 'mri':'mri', 'mac':'mac', 'mkd':'mkd', 'mal':'mal', 'mon':'mon', 'mol':'mol', 'mar':'mar', 'may':'may', 'msa':'msa', 'mlt':'mlt', 'bur':'bur', 'mya':'mya',
|
|
|
58 |
'nau':'nau', 'nob':'nob', 'nde':'nde', 'nep':'nep', 'ndo':'ndo', 'dut':'dut', 'nld':'nld', 'nno':'nno', 'nor':'nor', 'nbl':'nbl', 'nav':'nav', 'nya':'nya',
|
|
|
59 |
'oci':'oci', 'oji':'oji', 'orm':'orm', 'ori':'ori', 'oss':'oss', 'pan':'pan', 'pli':'pli', 'pol':'pol', 'pus':'pus', 'por':'por', 'que':'que',
|
|
|
60 |
'roh':'roh', 'run':'run', 'rum':'rum', 'ron':'ron', 'rus':'rus', 'kin':'kin', 'san':'san', 'srd':'srd', 'snd':'snd', 'sme':'sme', 'sag':'sag', 'slo':'slo', 'sin':'sin', 'slk':'slk', 'slv':'slv', 'smo':'smo', 'sna':'sna', 'som':'som', 'alb':'alb', 'sqi':'sqi', 'srp':'srp', 'ssw':'ssw', 'sot':'sot', 'sun':'sun', 'swe':'swe', 'swa':'swa',
|
|
|
61 |
'tam':'tam', 'tel':'tel', 'tgk':'tgk', 'tha':'tha', 'tir':'tir', 'tuk':'tuk', 'tgl':'tgl', 'tsn':'tsn', 'ton':'ton', 'tur':'tur', 'tso':'tso', 'tat':'tat', 'twi':'twi', 'tah':'tah',
|
|
|
62 |
'uig':'uig', 'ukr':'ukr', 'urd':'urd', 'uzb':'uzb', 'ven':'ven', 'vie':'vie', 'vol':'vol', 'wln':'wln', 'wol':'wol', 'xho':'xho', 'yid':'yid', 'yor':'yor', 'zha':'zha', 'chi':'chi', 'zho':'zho', 'zul':'zul'};
|
|
|
63 |
|
|
|
64 |
var CMIString200 = '^[\\u0000-\\uFFFF]{0,200}$';
|
|
|
65 |
var CMIString250 = '^[\\u0000-\\uFFFF]{0,250}$';
|
|
|
66 |
var CMIString1000 = '^[\\u0000-\\uFFFF]{0,1000}$';
|
|
|
67 |
var CMIString4000 = '^[\\u0000-\\uFFFF]{0,4000}$';
|
|
|
68 |
var CMIString64000 = '^[\\u0000-\\uFFFF]{0,64000}$';
|
|
|
69 |
var CMILang = '^([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?$|^$';
|
|
|
70 |
var CMILangString250 = '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,250}$)?';
|
|
|
71 |
var CMILangcr = '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\}))(.*?)$';
|
|
|
72 |
var CMILangString250cr = '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\})?(.{0,250})?)?$';
|
|
|
73 |
var CMILangString4000 = '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,4000}$)?';
|
|
|
74 |
var CMITime = '^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$';
|
|
|
75 |
var CMITimespan = '^P(\\d+Y)?(\\d+M)?(\\d+D)?(T(((\\d+H)(\\d+M)?(\\d+(\.\\d{1,2})?S)?)|((\\d+M)(\\d+(\.\\d{1,2})?S)?)|((\\d+(\.\\d{1,2})?S))))?$';
|
|
|
76 |
var CMIInteger = '^\\d+$';
|
|
|
77 |
var CMISInteger = '^-?([0-9]+)$';
|
|
|
78 |
var CMIDecimal = '^-?([0-9]{1,5})(\\.[0-9]{1,18})?$';
|
|
|
79 |
var CMIIdentifier = '^\\S{1,250}[a-zA-Z0-9]$';
|
|
|
80 |
var CMIShortIdentifier = '^[\\w\.]{1,250}$';
|
|
|
81 |
var CMILongIdentifier = '^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000})$';
|
|
|
82 |
var CMIFeedback = '^.*$'; // This must be redefined
|
|
|
83 |
var CMIIndex = '[._](\\d+).';
|
|
|
84 |
var CMIIndexStore = '.N(\\d+).';
|
|
|
85 |
// Vocabulary Data Type Definition
|
|
|
86 |
var CMICStatus = '^completed$|^incomplete$|^not attempted$|^unknown$';
|
|
|
87 |
var CMISStatus = '^passed$|^failed$|^unknown$';
|
|
|
88 |
var CMIExit = '^time-out$|^suspend$|^logout$|^normal$|^$';
|
|
|
89 |
var CMIType = '^true-false$|^choice$|^(long-)?fill-in$|^matching$|^performance$|^sequencing$|^likert$|^numeric$|^other$';
|
|
|
90 |
var CMIResult = '^correct$|^incorrect$|^unanticipated$|^neutral$|^-?([0-9]{1,4})(\\.[0-9]{1,18})?$';
|
|
|
91 |
var NAVEvent = '^previous$|^continue$|^exit$|^exitAll$|^abandon$|^abandonAll$|^suspendAll$|^\{target=\\S{0,200}[a-zA-Z0-9]\}choice|jump$';
|
|
|
92 |
var NAVBoolean = '^unknown$|^true$|^false$';
|
|
|
93 |
var NAVTarget = '^previous$|^continue$|^choice.{target=\\S{0,200}[a-zA-Z0-9]}$'
|
|
|
94 |
// Children lists
|
|
|
95 |
var cmi_children = '_version,comments_from_learner,comments_from_lms,completion_status,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time';
|
|
|
96 |
var comments_children = 'comment,timestamp,location';
|
|
|
97 |
var score_children = 'max,raw,scaled,min';
|
|
|
98 |
var objectives_children = 'progress_measure,completion_status,success_status,description,score,id';
|
|
|
99 |
var correct_responses_children = 'pattern';
|
|
|
100 |
var student_data_children = 'mastery_score,max_time_allowed,time_limit_action';
|
|
|
101 |
var student_preference_children = 'audio_level,audio_captioning,delivery_speed,language';
|
|
|
102 |
var interactions_children = 'id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description';
|
|
|
103 |
// Data ranges
|
|
|
104 |
var scaled_range = '-1#1';
|
|
|
105 |
var audio_range = '0#*';
|
|
|
106 |
var speed_range = '0#*';
|
|
|
107 |
var text_range = '-1#1';
|
|
|
108 |
var progress_range = '0#1';
|
|
|
109 |
var learner_response = {
|
|
|
110 |
'true-false':{'format':'^true$|^false$', 'max':1, 'delimiter':'', 'unique':false},
|
|
|
111 |
'choice':{'format':CMIShortIdentifier, 'max':36, 'delimiter':'[,]', 'unique':true},
|
|
|
112 |
'fill-in':{'format':CMILangString250, 'max':10, 'delimiter':'[,]', 'unique':false},
|
|
|
113 |
'long-fill-in':{'format':CMILangString4000, 'max':1, 'delimiter':'', 'unique':false},
|
|
|
114 |
'matching':{'format':CMIShortIdentifier, 'format2':CMIShortIdentifier, 'max':36, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false},
|
|
|
115 |
'performance':{'format':'^$|' + CMIShortIdentifier, 'format2':CMIDecimal + '|^$|' + CMIShortIdentifier, 'max':250, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false},
|
|
|
116 |
'sequencing':{'format':CMIShortIdentifier, 'max':36, 'delimiter':'[,]', 'unique':false},
|
|
|
117 |
'likert':{'format':CMIShortIdentifier, 'max':1, 'delimiter':'', 'unique':false},
|
|
|
118 |
'numeric':{'format':CMIDecimal, 'max':1, 'delimiter':'', 'unique':false},
|
|
|
119 |
'other':{'format':CMIString4000, 'max':1, 'delimiter':'', 'unique':false}
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
var correct_responses = {
|
|
|
123 |
'true-false':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':false,
|
|
|
124 |
'format':'^true$|^false$',
|
|
|
125 |
'limit':1},
|
|
|
126 |
'choice':{'max':36, 'delimiter':'[,]', 'unique':true, 'duplicate':false,
|
|
|
127 |
'format':CMIShortIdentifier},
|
|
|
128 |
'fill-in':{'max':10, 'delimiter':'[,]', 'unique':false, 'duplicate':false,
|
|
|
129 |
'format':CMILangString250cr},
|
|
|
130 |
'long-fill-in':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':true,
|
|
|
131 |
'format':CMILangString4000},
|
|
|
132 |
'matching':{'max':36, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false,
|
|
|
133 |
'format':CMIShortIdentifier, 'format2':CMIShortIdentifier},
|
|
|
134 |
'performance':{'max':250, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false,
|
|
|
135 |
'format':'^$|' + CMIShortIdentifier, 'format2':CMIDecimal + '|^$|' + CMIShortIdentifier},
|
|
|
136 |
'sequencing':{'max':36, 'delimiter':'[,]', 'unique':false, 'duplicate':false,
|
|
|
137 |
'format':CMIShortIdentifier},
|
|
|
138 |
'likert':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':false,
|
|
|
139 |
'format':CMIShortIdentifier,
|
|
|
140 |
'limit':1},
|
|
|
141 |
'numeric':{'max':2, 'delimiter':'[:]', 'unique':false, 'duplicate':false,
|
|
|
142 |
'format':CMIDecimal,
|
|
|
143 |
'limit':1},
|
|
|
144 |
'other':{'max':1, 'delimiter':'', 'unique':false, 'duplicate':false,
|
|
|
145 |
'format':CMIString4000,
|
|
|
146 |
'limit':1}
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
// The SCORM 1.3 data model
|
|
|
150 |
// Set up data model for each sco
|
|
|
151 |
var datamodel = {};
|
|
|
152 |
for(scoid in def){
|
|
|
153 |
datamodel[scoid] = {
|
|
|
154 |
'cmi._children':{'defaultvalue':cmi_children, 'mod':'r'},
|
|
|
155 |
'cmi._version':{'defaultvalue':'1.0', 'mod':'r'},
|
|
|
156 |
'cmi.comments_from_learner._children':{'defaultvalue':comments_children, 'mod':'r'},
|
|
|
157 |
'cmi.comments_from_learner._count':{'mod':'r', 'defaultvalue':'0'},
|
|
|
158 |
'cmi.comments_from_learner.n.comment':{'format':CMILangString4000, 'mod':'rw'},
|
|
|
159 |
'cmi.comments_from_learner.n.location':{'format':CMIString250, 'mod':'rw'},
|
|
|
160 |
'cmi.comments_from_learner.n.timestamp':{'format':CMITime, 'mod':'rw'},
|
|
|
161 |
'cmi.comments_from_lms._children':{'defaultvalue':comments_children, 'mod':'r'},
|
|
|
162 |
'cmi.comments_from_lms._count':{'mod':'r', 'defaultvalue':'0'},
|
|
|
163 |
'cmi.comments_from_lms.n.comment':{'format':CMILangString4000, 'mod':'r'},
|
|
|
164 |
'cmi.comments_from_lms.n.location':{'format':CMIString250, 'mod':'r'},
|
|
|
165 |
'cmi.comments_from_lms.n.timestamp':{'format':CMITime, 'mod':'r'},
|
|
|
166 |
'cmi.completion_status':{'defaultvalue':def[scoid]['cmi.completion_status'], 'format':CMICStatus, 'mod':'rw'},
|
|
|
167 |
'cmi.completion_threshold':{'defaultvalue':def[scoid]['cmi.completion_threshold'], 'mod':'r'},
|
|
|
168 |
'cmi.credit':{'defaultvalue':def[scoid]['cmi.credit'], 'mod':'r'},
|
|
|
169 |
'cmi.entry':{'defaultvalue':def[scoid]['cmi.entry'], 'mod':'r'},
|
|
|
170 |
'cmi.exit':{'defaultvalue':def[scoid]['cmi.exit'], 'format':CMIExit, 'mod':'w'},
|
|
|
171 |
'cmi.interactions._children':{'defaultvalue':interactions_children, 'mod':'r'},
|
|
|
172 |
'cmi.interactions._count':{'mod':'r', 'defaultvalue':'0'},
|
|
|
173 |
'cmi.interactions.n.id':{'pattern':CMIIndex, 'format':CMILongIdentifier, 'mod':'rw'},
|
|
|
174 |
'cmi.interactions.n.type':{'pattern':CMIIndex, 'format':CMIType, 'mod':'rw'},
|
|
|
175 |
'cmi.interactions.n.objectives._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0'},
|
|
|
176 |
'cmi.interactions.n.objectives.n.id':{'pattern':CMIIndex, 'format':CMILongIdentifier, 'mod':'rw'},
|
|
|
177 |
'cmi.interactions.n.timestamp':{'pattern':CMIIndex, 'format':CMITime, 'mod':'rw'},
|
|
|
178 |
'cmi.interactions.n.correct_responses._count':{'defaultvalue':'0', 'pattern':CMIIndex, 'mod':'r'},
|
|
|
179 |
'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':'CMIFeedback', 'mod':'rw'},
|
|
|
180 |
'cmi.interactions.n.weighting':{'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'rw'},
|
|
|
181 |
'cmi.interactions.n.learner_response':{'pattern':CMIIndex, 'format':'CMIFeedback', 'mod':'rw'},
|
|
|
182 |
'cmi.interactions.n.result':{'pattern':CMIIndex, 'format':CMIResult, 'mod':'rw'},
|
|
|
183 |
'cmi.interactions.n.latency':{'pattern':CMIIndex, 'format':CMITimespan, 'mod':'rw'},
|
|
|
184 |
'cmi.interactions.n.description':{'pattern':CMIIndex, 'format':CMILangString250, 'mod':'rw'},
|
|
|
185 |
'cmi.launch_data':{'defaultvalue':def[scoid]['cmi.launch_data'], 'mod':'r'},
|
|
|
186 |
'cmi.learner_id':{'defaultvalue':def[scoid]['cmi.learner_id'], 'mod':'r'},
|
|
|
187 |
'cmi.learner_name':{'defaultvalue':def[scoid]['cmi.learner_name'], 'mod':'r'},
|
|
|
188 |
'cmi.learner_preference._children':{'defaultvalue':student_preference_children, 'mod':'r'},
|
|
|
189 |
'cmi.learner_preference.audio_level':{'defaultvalue':def[scoid]['cmi.learner_preference.audio_level'], 'format':CMIDecimal, 'range':audio_range, 'mod':'rw'},
|
|
|
190 |
'cmi.learner_preference.language':{'defaultvalue':def[scoid]['cmi.learner_preference.language'], 'format':CMILang, 'mod':'rw'},
|
|
|
191 |
'cmi.learner_preference.delivery_speed':{'defaultvalue':def[scoid]['cmi.learner_preference.delivery_speed'], 'format':CMIDecimal, 'range':speed_range, 'mod':'rw'},
|
|
|
192 |
'cmi.learner_preference.audio_captioning':{'defaultvalue':def[scoid]['cmi.learner_preference.audio_captioning'], 'format':CMISInteger, 'range':text_range, 'mod':'rw'},
|
|
|
193 |
'cmi.location':{'defaultvalue':def[scoid]['cmi.location'], 'format':CMIString1000, 'mod':'rw'},
|
|
|
194 |
'cmi.max_time_allowed':{'defaultvalue':def[scoid]['cmi.max_time_allowed'], 'mod':'r'},
|
|
|
195 |
'cmi.mode':{'defaultvalue':def[scoid]['cmi.mode'], 'mod':'r'},
|
|
|
196 |
'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r'},
|
|
|
197 |
'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0'},
|
|
|
198 |
'cmi.objectives.n.id':{'pattern':CMIIndex, 'format':CMILongIdentifier, 'mod':'rw'},
|
|
|
199 |
'cmi.objectives.n.score._children':{'defaultvalue':score_children, 'pattern':CMIIndex, 'mod':'r'},
|
|
|
200 |
'cmi.objectives.n.score.scaled':{'defaultvalue':null, 'pattern':CMIIndex, 'format':CMIDecimal, 'range':scaled_range, 'mod':'rw'},
|
|
|
201 |
'cmi.objectives.n.score.raw':{'defaultvalue':null, 'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'rw'},
|
|
|
202 |
'cmi.objectives.n.score.min':{'defaultvalue':null, 'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'rw'},
|
|
|
203 |
'cmi.objectives.n.score.max':{'defaultvalue':null, 'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'rw'},
|
|
|
204 |
'cmi.objectives.n.success_status':{'defaultvalue':'unknown', 'pattern':CMIIndex, 'format':CMISStatus, 'mod':'rw'},
|
|
|
205 |
'cmi.objectives.n.completion_status':{'defaultvalue':'unknown', 'pattern':CMIIndex, 'format':CMICStatus, 'mod':'rw'},
|
|
|
206 |
'cmi.objectives.n.progress_measure':{'defaultvalue':null, 'format':CMIDecimal, 'range':progress_range, 'mod':'rw'},
|
|
|
207 |
'cmi.objectives.n.description':{'pattern':CMIIndex, 'format':CMILangString250, 'mod':'rw'},
|
|
|
208 |
'cmi.progress_measure':{'defaultvalue':def[scoid]['cmi.progress_measure'], 'format':CMIDecimal, 'range':progress_range, 'mod':'rw'},
|
|
|
209 |
'cmi.scaled_passing_score':{'defaultvalue':def[scoid]['cmi.scaled_passing_score'], 'format':CMIDecimal, 'range':scaled_range, 'mod':'r'},
|
|
|
210 |
'cmi.score._children':{'defaultvalue':score_children, 'mod':'r'},
|
|
|
211 |
'cmi.score.scaled':{'defaultvalue':def[scoid]['cmi.score.scaled'], 'format':CMIDecimal, 'range':scaled_range, 'mod':'rw'},
|
|
|
212 |
'cmi.score.raw':{'defaultvalue':def[scoid]['cmi.score.raw'], 'format':CMIDecimal, 'mod':'rw'},
|
|
|
213 |
'cmi.score.min':{'defaultvalue':def[scoid]['cmi.score.min'], 'format':CMIDecimal, 'mod':'rw'},
|
|
|
214 |
'cmi.score.max':{'defaultvalue':def[scoid]['cmi.score.max'], 'format':CMIDecimal, 'mod':'rw'},
|
|
|
215 |
'cmi.session_time':{'format':CMITimespan, 'mod':'w', 'defaultvalue':'PT0H0M0S'},
|
|
|
216 |
'cmi.success_status':{'defaultvalue':def[scoid]['cmi.success_status'], 'format':CMISStatus, 'mod':'rw'},
|
|
|
217 |
'cmi.suspend_data':{'defaultvalue':def[scoid]['cmi.suspend_data'], 'format':CMIString64000, 'mod':'rw'},
|
|
|
218 |
'cmi.time_limit_action':{'defaultvalue':def[scoid]['cmi.time_limit_action'], 'mod':'r'},
|
|
|
219 |
'cmi.total_time':{'defaultvalue':def[scoid]['cmi.total_time'], 'mod':'r'},
|
|
|
220 |
'adl.nav.request':{'defaultvalue':'_none_', 'format':NAVEvent, 'mod':'rw'}
|
|
|
221 |
};
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
var cmi, adl;
|
|
|
225 |
function initdatamodel(scoid){
|
|
|
226 |
|
|
|
227 |
prerequrl = cfgwwwroot + "/mod/scorm/prereqs.php?a=" + scormid + "&scoid=" + scoid + "&attempt=" + attempt + "&mode=" + viewmode + "¤torg=" + currentorg + "&sesskey=" + sesskey;
|
|
|
228 |
datamodelurlparams = "id=" + cmid + "&a=" + scormid + "&sesskey=" + sesskey + "&attempt=" + attempt + "&scoid=" + scoid;
|
|
|
229 |
|
|
|
230 |
//
|
|
|
231 |
// Datamodel inizialization
|
|
|
232 |
//
|
|
|
233 |
cmi = new Object();
|
|
|
234 |
cmi.comments_from_learner = new Object();
|
|
|
235 |
cmi.comments_from_learner._count = 0;
|
|
|
236 |
cmi.comments_from_lms = new Object();
|
|
|
237 |
cmi.comments_from_lms._count = 0;
|
|
|
238 |
cmi.interactions = new Object();
|
|
|
239 |
cmi.interactions._count = 0;
|
|
|
240 |
cmi.learner_preference = new Object();
|
|
|
241 |
cmi.objectives = new Object();
|
|
|
242 |
cmi.objectives._count = 0;
|
|
|
243 |
cmi.score = new Object();
|
|
|
244 |
|
|
|
245 |
// Navigation Object
|
|
|
246 |
adl = new Object();
|
|
|
247 |
adl.nav = new Object();
|
|
|
248 |
adl.nav.request_valid = new Array();
|
|
|
249 |
|
|
|
250 |
for (element in datamodel[scoid]) {
|
|
|
251 |
if (element.match(/\.n\./) == null) {
|
|
|
252 |
if (typeof datamodel[scoid][element].defaultvalue != 'undefined') {
|
|
|
253 |
eval(element + ' = datamodel["' + scoid + '"]["' + element + '"].defaultvalue;');
|
|
|
254 |
} else {
|
|
|
255 |
eval(element + ' = "";');
|
|
|
256 |
}
|
|
|
257 |
}
|
|
|
258 |
}
|
|
|
259 |
|
|
|
260 |
eval(cmiobj[scoid]);
|
|
|
261 |
eval(cmiint[scoid]);
|
|
|
262 |
eval(cmicommentsuser[scoid]);
|
|
|
263 |
eval(cmicommentslms[scoid]);
|
|
|
264 |
|
|
|
265 |
if (cmi.completion_status == '') {
|
|
|
266 |
cmi.completion_status = 'not attempted';
|
|
|
267 |
}
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
//
|
|
|
271 |
// API Methods definition
|
|
|
272 |
//
|
|
|
273 |
var Initialized = false;
|
|
|
274 |
var Terminated = false;
|
|
|
275 |
var diagnostic = "";
|
|
|
276 |
var errorCode = "0";
|
|
|
277 |
|
|
|
278 |
function Initialize (param) {
|
|
|
279 |
scoid = scorm_current_node ? scorm_current_node.scoid : scoid;
|
|
|
280 |
initdatamodel(scoid);
|
|
|
281 |
|
|
|
282 |
errorCode = "0";
|
|
|
283 |
if (param == "") {
|
|
|
284 |
if ((!Initialized) && (!Terminated)) {
|
|
|
285 |
Initialized = true;
|
|
|
286 |
errorCode = "0";
|
|
|
287 |
if (scormdebugging) {
|
|
|
288 |
LogAPICall("Initialize", param, "", errorCode);
|
|
|
289 |
}
|
|
|
290 |
return "true";
|
|
|
291 |
} else {
|
|
|
292 |
if (Initialized) {
|
|
|
293 |
errorCode = "103";
|
|
|
294 |
} else {
|
|
|
295 |
errorCode = "104";
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
} else {
|
|
|
299 |
errorCode = "201";
|
|
|
300 |
}
|
|
|
301 |
if (scormdebugging) {
|
|
|
302 |
LogAPICall("Initialize", param, "", errorCode);
|
|
|
303 |
}
|
|
|
304 |
return "false";
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
function Terminate (param) {
|
|
|
308 |
errorCode = "0";
|
|
|
309 |
if (param == "") {
|
|
|
310 |
if ((Initialized) && (!Terminated)) {
|
|
|
311 |
var AJAXResult = StoreData(cmi,true);
|
|
|
312 |
if (scormdebugging) {
|
|
|
313 |
LogAPICall("Terminate", "AJAXResult", AJAXResult, 0);
|
|
|
314 |
}
|
|
|
315 |
result = ('true' == AJAXResult) ? 'true' : 'false';
|
|
|
316 |
errorCode = ('true' == result) ? '0' : '101'; // General exception for any AJAX fault.
|
|
|
317 |
if (scormdebugging) {
|
|
|
318 |
LogAPICall("Terminate", "result", result, errorCode);
|
|
|
319 |
}
|
|
|
320 |
if ('true' == result) {
|
|
|
321 |
Initialized = false;
|
|
|
322 |
Terminated = true;
|
|
|
323 |
if (adl.nav.request != '_none_') {
|
|
|
324 |
switch (adl.nav.request) {
|
|
|
325 |
case 'continue':
|
|
|
326 |
setTimeout('mod_scorm_launch_next_sco();',500);
|
|
|
327 |
break;
|
|
|
328 |
case 'previous':
|
|
|
329 |
setTimeout('mod_scorm_launch_prev_sco();',500);
|
|
|
330 |
break;
|
|
|
331 |
case 'choice':
|
|
|
332 |
break;
|
|
|
333 |
case 'exit':
|
|
|
334 |
break;
|
|
|
335 |
case 'exitAll':
|
|
|
336 |
break;
|
|
|
337 |
case 'abandon':
|
|
|
338 |
break;
|
|
|
339 |
case 'abandonAll':
|
|
|
340 |
break;
|
|
|
341 |
}
|
|
|
342 |
} else {
|
|
|
343 |
if (scormauto == 1) {
|
|
|
344 |
setTimeout('mod_scorm_launch_next_sco();',500);
|
|
|
345 |
}
|
|
|
346 |
}
|
|
|
347 |
// trigger TOC update
|
|
|
348 |
var callback = M.mod_scorm.connectPrereqCallback;
|
|
|
349 |
YUI().use('io-base', function(Y) {
|
|
|
350 |
Y.on('io:complete', callback.success, Y);
|
|
|
351 |
Y.io(prerequrl);
|
|
|
352 |
});
|
|
|
353 |
} else {
|
|
|
354 |
diagnostic = "Failure calling the Terminate remote callback: the server replied with HTTP Status " + AJAXResult;
|
|
|
355 |
}
|
|
|
356 |
return result;
|
|
|
357 |
} else {
|
|
|
358 |
if (Terminated) {
|
|
|
359 |
errorCode = "113";
|
|
|
360 |
} else {
|
|
|
361 |
errorCode = "112";
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
} else {
|
|
|
365 |
errorCode = "201";
|
|
|
366 |
}
|
|
|
367 |
if (scormdebugging) {
|
|
|
368 |
LogAPICall("Terminate", param, "", errorCode);
|
|
|
369 |
}
|
|
|
370 |
return "false";
|
|
|
371 |
}
|
|
|
372 |
|
|
|
373 |
function GetValue (element) {
|
|
|
374 |
errorCode = "0";
|
|
|
375 |
diagnostic = "";
|
|
|
376 |
if ((Initialized) && (!Terminated)) {
|
|
|
377 |
if (element != "") {
|
|
|
378 |
var expression = new RegExp(CMIIndex,'g');
|
|
|
379 |
var elementmodel = String(element).replace(expression,'.n.');
|
|
|
380 |
if (typeof datamodel[scoid][elementmodel] != "undefined") {
|
|
|
381 |
if (datamodel[scoid][elementmodel].mod != 'w') {
|
|
|
382 |
|
|
|
383 |
element = String(element).replace(/\.(\d+)\./, ".N$1.");
|
|
|
384 |
element = element.replace(/\.(\d+)\./, ".N$1.");
|
|
|
385 |
|
|
|
386 |
var elementIndexes = element.split('.');
|
|
|
387 |
var subelement = element.substr(0,3);
|
|
|
388 |
var i = 1;
|
|
|
389 |
while ((i < elementIndexes.length) && (typeof eval(subelement) != "undefined")) {
|
|
|
390 |
subelement += '.' + elementIndexes[i++];
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
if (subelement == element) {
|
|
|
394 |
|
|
|
395 |
if ((typeof eval(subelement) != "undefined") && (eval(subelement) != null)) {
|
|
|
396 |
errorCode = "0";
|
|
|
397 |
if (scormdebugging) {
|
|
|
398 |
LogAPICall("GetValue", element, eval(element), 0);
|
|
|
399 |
}
|
|
|
400 |
return eval(element);
|
|
|
401 |
} else {
|
|
|
402 |
errorCode = "403";
|
|
|
403 |
}
|
|
|
404 |
} else {
|
|
|
405 |
errorCode = "301";
|
|
|
406 |
}
|
|
|
407 |
} else {
|
|
|
408 |
//errorCode = eval('datamodel["' + scoid + '"]["' + elementmodel + '"].readerror');
|
|
|
409 |
errorCode = "405";
|
|
|
410 |
}
|
|
|
411 |
} else {
|
|
|
412 |
var childrenstr = '._children';
|
|
|
413 |
var countstr = '._count';
|
|
|
414 |
var parentmodel = '';
|
|
|
415 |
if (elementmodel.substr(elementmodel.length - childrenstr.length,elementmodel.length) == childrenstr) {
|
|
|
416 |
parentmodel = elementmodel.substr(0,elementmodel.length - childrenstr.length);
|
|
|
417 |
if (datamodel[scoid][parentmodel] != "undefined") {
|
|
|
418 |
errorCode = "301";
|
|
|
419 |
diagnostic = "Data Model Element Does Not Have Children";
|
|
|
420 |
} else {
|
|
|
421 |
errorCode = "401";
|
|
|
422 |
}
|
|
|
423 |
} else if (elementmodel.substr(elementmodel.length - countstr.length,elementmodel.length) == countstr) {
|
|
|
424 |
parentmodel = elementmodel.substr(0,elementmodel.length - countstr.length);
|
|
|
425 |
if (typeof datamodel[scoid][parentmodel] != "undefined") {
|
|
|
426 |
errorCode = "301";
|
|
|
427 |
diagnostic = "Data Model Element Cannot Have Count";
|
|
|
428 |
} else {
|
|
|
429 |
errorCode = "401";
|
|
|
430 |
}
|
|
|
431 |
} else {
|
|
|
432 |
parentmodel = 'adl.nav.request_valid.';
|
|
|
433 |
if (element.substr(0,parentmodel.length) == parentmodel) {
|
|
|
434 |
if (element.substr(parentmodel.length).match(NAVTarget) == null) {
|
|
|
435 |
errorCode = "301";
|
|
|
436 |
} else {
|
|
|
437 |
if (adl.nav.request == element.substr(parentmodel.length)) {
|
|
|
438 |
return "true";
|
|
|
439 |
} else if (adl.nav.request == '_none_') {
|
|
|
440 |
return "unknown";
|
|
|
441 |
} else {
|
|
|
442 |
return "false";
|
|
|
443 |
}
|
|
|
444 |
}
|
|
|
445 |
} else {
|
|
|
446 |
errorCode = "401";
|
|
|
447 |
}
|
|
|
448 |
}
|
|
|
449 |
}
|
|
|
450 |
} else {
|
|
|
451 |
errorCode = "301";
|
|
|
452 |
}
|
|
|
453 |
} else {
|
|
|
454 |
if (Terminated) {
|
|
|
455 |
errorCode = "123";
|
|
|
456 |
} else {
|
|
|
457 |
errorCode = "122";
|
|
|
458 |
}
|
|
|
459 |
}
|
|
|
460 |
if (scormdebugging) {
|
|
|
461 |
LogAPICall("GetValue", element, "", errorCode);
|
|
|
462 |
}
|
|
|
463 |
return "";
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
function SetValue (element,value) {
|
|
|
467 |
errorCode = "0";
|
|
|
468 |
diagnostic = "";
|
|
|
469 |
if ((Initialized) && (!Terminated)) {
|
|
|
470 |
if (element != "") {
|
|
|
471 |
var expression = new RegExp(CMIIndex,'g');
|
|
|
472 |
var elementmodel = String(element).replace(expression,'.n.');
|
|
|
473 |
if (typeof datamodel[scoid][elementmodel] != "undefined") {
|
|
|
474 |
if (datamodel[scoid][elementmodel].mod != 'r') {
|
|
|
475 |
if (datamodel[scoid][elementmodel].format != 'CMIFeedback') {
|
|
|
476 |
expression = new RegExp(datamodel[scoid][elementmodel].format);
|
|
|
477 |
} else {
|
|
|
478 |
// cmi.interactions.n.type depending format accept everything at this stage
|
|
|
479 |
expression = new RegExp(CMIFeedback);
|
|
|
480 |
}
|
|
|
481 |
value = value + '';
|
|
|
482 |
var matches = value.match(expression);
|
|
|
483 |
if ((matches != null) && ((matches.join('').length > 0) || (value.length == 0))) {
|
|
|
484 |
// Value match dataelement format
|
|
|
485 |
|
|
|
486 |
if (element != elementmodel) {
|
|
|
487 |
//This is a dynamic datamodel element
|
|
|
488 |
|
|
|
489 |
var elementIndexes = element.split('.');
|
|
|
490 |
var subelement = 'cmi';
|
|
|
491 |
var parentelement = 'cmi';
|
|
|
492 |
for (var i = 1; (i < elementIndexes.length - 1) && (errorCode == "0"); i++) {
|
|
|
493 |
var elementIndex = elementIndexes[i];
|
|
|
494 |
if (elementIndexes[i + 1].match(/^\d+$/)) {
|
|
|
495 |
if ((parseInt(elementIndexes[i + 1]) > 0) && (elementIndexes[i + 1].charAt(0) == 0)) {
|
|
|
496 |
// Index has a leading 0 (zero), this is not a number
|
|
|
497 |
errorCode = "351";
|
|
|
498 |
}
|
|
|
499 |
parentelement = subelement + '.' + elementIndex;
|
|
|
500 |
if ((typeof eval(parentelement) == "undefined") || (typeof eval(parentelement + '._count') == "undefined")) {
|
|
|
501 |
errorCode = "408";
|
|
|
502 |
} else {
|
|
|
503 |
if (elementIndexes[i + 1] > eval(parentelement + '._count')) {
|
|
|
504 |
errorCode = "351";
|
|
|
505 |
diagnostic = "Data Model Element Collection Set Out Of Order";
|
|
|
506 |
}
|
|
|
507 |
subelement = subelement.concat('.' + elementIndex + '.N' + elementIndexes[i + 1]);
|
|
|
508 |
i++;
|
|
|
509 |
|
|
|
510 |
if (((typeof eval(subelement)) == "undefined") && (i < elementIndexes.length - 2)) {
|
|
|
511 |
errorCode = "408";
|
|
|
512 |
}
|
|
|
513 |
}
|
|
|
514 |
} else {
|
|
|
515 |
subelement = subelement.concat('.' + elementIndex);
|
|
|
516 |
}
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
if (errorCode == "0") {
|
|
|
520 |
// Till now it's a real datamodel element
|
|
|
521 |
|
|
|
522 |
element = subelement.concat('.' + elementIndexes[elementIndexes.length - 1]);
|
|
|
523 |
|
|
|
524 |
if ((typeof eval(subelement)) == "undefined") {
|
|
|
525 |
switch (elementmodel) {
|
|
|
526 |
case 'cmi.objectives.n.id':
|
|
|
527 |
if (!duplicatedID(element,parentelement,value)) {
|
|
|
528 |
if (elementIndexes[elementIndexes.length - 2] == eval(parentelement + '._count')) {
|
|
|
529 |
eval(parentelement + '._count++;');
|
|
|
530 |
eval(subelement + ' = new Object();');
|
|
|
531 |
var subobject = eval(subelement);
|
|
|
532 |
subobject.success_status = datamodel[scoid]["cmi.objectives.n.success_status"].defaultvalue;
|
|
|
533 |
subobject.completion_status = datamodel[scoid]["cmi.objectives.n.completion_status"].defaultvalue;
|
|
|
534 |
subobject.progress_measure = datamodel[scoid]["cmi.objectives.n.progress_measure"].defaultvalue;
|
|
|
535 |
subobject.score = new Object();
|
|
|
536 |
subobject.score._children = score_children;
|
|
|
537 |
subobject.score.scaled = datamodel[scoid]["cmi.objectives.n.score.scaled"].defaultvalue;
|
|
|
538 |
subobject.score.raw = datamodel[scoid]["cmi.objectives.n.score.raw"].defaultvalue;
|
|
|
539 |
subobject.score.min = datamodel[scoid]["cmi.objectives.n.score.min"].defaultvalue;
|
|
|
540 |
subobject.score.max = datamodel[scoid]["cmi.objectives.n.score.max"].defaultvalue;
|
|
|
541 |
}
|
|
|
542 |
} else {
|
|
|
543 |
errorCode = "351";
|
|
|
544 |
diagnostic = "Data Model Element ID Already Exists";
|
|
|
545 |
}
|
|
|
546 |
break;
|
|
|
547 |
case 'cmi.interactions.n.id':
|
|
|
548 |
if (elementIndexes[elementIndexes.length - 2] == eval(parentelement + '._count')) {
|
|
|
549 |
eval(parentelement + '._count++;');
|
|
|
550 |
eval(subelement + ' = new Object();');
|
|
|
551 |
var subobject = eval(subelement);
|
|
|
552 |
subobject.objectives = new Object();
|
|
|
553 |
subobject.objectives._count = 0;
|
|
|
554 |
}
|
|
|
555 |
break;
|
|
|
556 |
case 'cmi.interactions.n.objectives.n.id':
|
|
|
557 |
if (typeof eval(parentelement) != "undefined") {
|
|
|
558 |
if (!duplicatedID(element,parentelement,value)) {
|
|
|
559 |
if (elementIndexes[elementIndexes.length - 2] == eval(parentelement + '._count')) {
|
|
|
560 |
eval(parentelement + '._count++;');
|
|
|
561 |
eval(subelement + ' = new Object();');
|
|
|
562 |
}
|
|
|
563 |
} else {
|
|
|
564 |
errorCode = "351";
|
|
|
565 |
diagnostic = "Data Model Element ID Already Exists";
|
|
|
566 |
}
|
|
|
567 |
} else {
|
|
|
568 |
errorCode = "408";
|
|
|
569 |
}
|
|
|
570 |
break;
|
|
|
571 |
case 'cmi.interactions.n.correct_responses.n.pattern':
|
|
|
572 |
if (typeof eval(parentelement) != "undefined") {
|
|
|
573 |
// Use cmi.interactions.n.type value to check the right dataelement format
|
|
|
574 |
if (elementIndexes[elementIndexes.length - 2] == eval(parentelement + '._count')) {
|
|
|
575 |
var interactiontype = eval(String(parentelement).replace('correct_responses','type'));
|
|
|
576 |
var interactioncount = eval(parentelement + '._count');
|
|
|
577 |
// trap duplicate values, which is not allowed for type choice
|
|
|
578 |
if (interactiontype == 'choice') {
|
|
|
579 |
for (var i = 0; (i < interactioncount) && (errorCode == "0"); i++) {
|
|
|
580 |
if (eval(parentelement + '.N' + i + '.pattern') == value) {
|
|
|
581 |
errorCode = "351";
|
|
|
582 |
}
|
|
|
583 |
}
|
|
|
584 |
}
|
|
|
585 |
if ((typeof correct_responses[interactiontype].limit == 'undefined') ||
|
|
|
586 |
(eval(parentelement + '._count') < correct_responses[interactiontype].limit)) {
|
|
|
587 |
var nodes = new Array();
|
|
|
588 |
if (correct_responses[interactiontype].delimiter != '') {
|
|
|
589 |
nodes = value.split(correct_responses[interactiontype].delimiter);
|
|
|
590 |
} else {
|
|
|
591 |
nodes[0] = value;
|
|
|
592 |
}
|
|
|
593 |
if ((nodes.length > 0) && (nodes.length <= correct_responses[interactiontype].max)) {
|
|
|
594 |
errorCode = CRcheckValueNodes (element, interactiontype, nodes, value, errorCode);
|
|
|
595 |
} else if (nodes.length > correct_responses[interactiontype].max) {
|
|
|
596 |
errorCode = "351";
|
|
|
597 |
diagnostic = "Data Model Element Pattern Too Long";
|
|
|
598 |
}
|
|
|
599 |
if ((errorCode == "0") && ((correct_responses[interactiontype].duplicate == false) ||
|
|
|
600 |
(!duplicatedPA(element,parentelement,value))) || (errorCode == "0" && value == "")) {
|
|
|
601 |
eval(parentelement + '._count++;');
|
|
|
602 |
eval(subelement + ' = new Object();');
|
|
|
603 |
} else {
|
|
|
604 |
if (errorCode == "0") {
|
|
|
605 |
errorCode = "351";
|
|
|
606 |
diagnostic = "Data Model Element Pattern Already Exists";
|
|
|
607 |
}
|
|
|
608 |
}
|
|
|
609 |
} else {
|
|
|
610 |
errorCode = "351";
|
|
|
611 |
diagnostic = "Data Model Element Collection Limit Reached";
|
|
|
612 |
}
|
|
|
613 |
} else {
|
|
|
614 |
errorCode = "351";
|
|
|
615 |
diagnostic = "Data Model Element Collection Set Out Of Order";
|
|
|
616 |
}
|
|
|
617 |
} else {
|
|
|
618 |
errorCode = "408";
|
|
|
619 |
}
|
|
|
620 |
break;
|
|
|
621 |
default:
|
|
|
622 |
if ((parentelement != 'cmi.objectives') && (parentelement != 'cmi.interactions') && (typeof eval(parentelement) != "undefined")) {
|
|
|
623 |
if (elementIndexes[elementIndexes.length - 2] == eval(parentelement + '._count')) {
|
|
|
624 |
eval(parentelement + '._count++;');
|
|
|
625 |
eval(subelement + ' = new Object();');
|
|
|
626 |
} else {
|
|
|
627 |
errorCode = "351";
|
|
|
628 |
diagnostic = "Data Model Element Collection Set Out Of Order";
|
|
|
629 |
}
|
|
|
630 |
} else {
|
|
|
631 |
errorCode = "408";
|
|
|
632 |
}
|
|
|
633 |
break;
|
|
|
634 |
}
|
|
|
635 |
} else {
|
|
|
636 |
switch (elementmodel) {
|
|
|
637 |
case 'cmi.objectives.n.id':
|
|
|
638 |
if (eval(element) != value) {
|
|
|
639 |
errorCode = "351";
|
|
|
640 |
diagnostic = "Write Once Violation";
|
|
|
641 |
}
|
|
|
642 |
break;
|
|
|
643 |
case 'cmi.interactions.n.objectives.n.id':
|
|
|
644 |
if (duplicatedID(element,parentelement,value)) {
|
|
|
645 |
errorCode = "351";
|
|
|
646 |
diagnostic = "Data Model Element ID Already Exists";
|
|
|
647 |
}
|
|
|
648 |
break;
|
|
|
649 |
case 'cmi.interactions.n.type':
|
|
|
650 |
var subobject = eval(subelement);
|
|
|
651 |
subobject.correct_responses = new Object();
|
|
|
652 |
subobject.correct_responses._count = 0;
|
|
|
653 |
break;
|
|
|
654 |
case 'cmi.interactions.n.learner_response':
|
|
|
655 |
if (typeof eval(subelement + '.type') == "undefined") {
|
|
|
656 |
errorCode = "408";
|
|
|
657 |
} else {
|
|
|
658 |
// Use cmi.interactions.n.type value to check the right dataelement format
|
|
|
659 |
interactiontype = eval(subelement + '.type');
|
|
|
660 |
var nodes = new Array();
|
|
|
661 |
if (learner_response[interactiontype].delimiter != '') {
|
|
|
662 |
nodes = value.split(learner_response[interactiontype].delimiter);
|
|
|
663 |
} else {
|
|
|
664 |
nodes[0] = value;
|
|
|
665 |
}
|
|
|
666 |
if ((nodes.length > 0) && (nodes.length <= learner_response[interactiontype].max)) {
|
|
|
667 |
expression = new RegExp(learner_response[interactiontype].format);
|
|
|
668 |
for (var i = 0; (i < nodes.length) && (errorCode == "0"); i++) {
|
|
|
669 |
if (typeof learner_response[interactiontype].delimiter2 != 'undefined') {
|
|
|
670 |
values = nodes[i].split(learner_response[interactiontype].delimiter2);
|
|
|
671 |
if (values.length == 2) {
|
|
|
672 |
matches = values[0].match(expression);
|
|
|
673 |
if (matches == null) {
|
|
|
674 |
errorCode = "406";
|
|
|
675 |
} else {
|
|
|
676 |
var expression2 = new RegExp(learner_response[interactiontype].format2);
|
|
|
677 |
matches = values[1].match(expression2);
|
|
|
678 |
if (matches == null) {
|
|
|
679 |
errorCode = "406";
|
|
|
680 |
}
|
|
|
681 |
}
|
|
|
682 |
} else {
|
|
|
683 |
errorCode = "406";
|
|
|
684 |
}
|
|
|
685 |
} else {
|
|
|
686 |
matches = nodes[i].match(expression);
|
|
|
687 |
if (matches == null) {
|
|
|
688 |
errorCode = "406";
|
|
|
689 |
} else {
|
|
|
690 |
if ((nodes[i] != '') && (learner_response[interactiontype].unique)) {
|
|
|
691 |
for (var j = 0; (j < i) && (errorCode == "0"); j++) {
|
|
|
692 |
if (nodes[i] == nodes[j]) {
|
|
|
693 |
errorCode = "406";
|
|
|
694 |
}
|
|
|
695 |
}
|
|
|
696 |
}
|
|
|
697 |
}
|
|
|
698 |
}
|
|
|
699 |
}
|
|
|
700 |
} else if (nodes.length > learner_response[interactiontype].max) {
|
|
|
701 |
errorCode = "351";
|
|
|
702 |
diagnostic = "Data Model Element Pattern Too Long";
|
|
|
703 |
}
|
|
|
704 |
}
|
|
|
705 |
break;
|
|
|
706 |
case 'cmi.interactions.n.correct_responses.n.pattern':
|
|
|
707 |
subel = subelement.split('.');
|
|
|
708 |
subel1 = 'cmi.interactions.' + subel[2];
|
|
|
709 |
|
|
|
710 |
if (typeof eval(subel1 + '.type') == "undefined") {
|
|
|
711 |
errorCode = "408";
|
|
|
712 |
} else {
|
|
|
713 |
// Use cmi.interactions.n.type value to check the right //dataelement format
|
|
|
714 |
var interactiontype = eval(subel1 + '.type');
|
|
|
715 |
var interactioncount = eval(parentelement + '._count');
|
|
|
716 |
// trap duplicate values, which is not allowed for type choice
|
|
|
717 |
if (interactiontype == 'choice') {
|
|
|
718 |
for (var i = 0; (i < interactioncount) && (errorCode == "0"); i++) {
|
|
|
719 |
if (eval(parentelement + '.N' + i + '.pattern') == value) {
|
|
|
720 |
errorCode = "351";
|
|
|
721 |
}
|
|
|
722 |
}
|
|
|
723 |
}
|
|
|
724 |
var nodes = new Array();
|
|
|
725 |
if (correct_responses[interactiontype].delimiter != '') {
|
|
|
726 |
nodes = value.split(correct_responses[interactiontype].delimiter);
|
|
|
727 |
} else {
|
|
|
728 |
nodes[0] = value;
|
|
|
729 |
}
|
|
|
730 |
|
|
|
731 |
if ((nodes.length > 0) && (nodes.length <= correct_responses[interactiontype].max)) {
|
|
|
732 |
errorCode = CRcheckValueNodes (element, interactiontype, nodes, value, errorCode);
|
|
|
733 |
} else if (nodes.length > correct_responses[interactiontype].max) {
|
|
|
734 |
errorCode = "351";
|
|
|
735 |
diagnostic = "Data Model Element Pattern Too Long";
|
|
|
736 |
}
|
|
|
737 |
}
|
|
|
738 |
break;
|
|
|
739 |
}
|
|
|
740 |
}
|
|
|
741 |
}
|
|
|
742 |
}
|
|
|
743 |
//Store data
|
|
|
744 |
if (errorCode == "0") {
|
|
|
745 |
if (autocommit && !(SCORMapi1_3.timeout)) {
|
|
|
746 |
SCORMapi1_3.timeout = Y.later(60000, API_1484_11, 'Commit', [""], false);
|
|
|
747 |
}
|
|
|
748 |
|
|
|
749 |
if (typeof datamodel[scoid][elementmodel].range != "undefined") {
|
|
|
750 |
range = datamodel[scoid][elementmodel].range;
|
|
|
751 |
ranges = range.split('#');
|
|
|
752 |
value = value * 1.0;
|
|
|
753 |
if (value >= ranges[0]) {
|
|
|
754 |
if ((ranges[1] == '*') || (value <= ranges[1])) {
|
|
|
755 |
eval(element + '=value;');
|
|
|
756 |
errorCode = "0";
|
|
|
757 |
if (scormdebugging) {
|
|
|
758 |
LogAPICall("SetValue", element, value, errorCode);
|
|
|
759 |
}
|
|
|
760 |
return "true";
|
|
|
761 |
} else {
|
|
|
762 |
errorCode = '407';
|
|
|
763 |
}
|
|
|
764 |
} else {
|
|
|
765 |
errorCode = '407';
|
|
|
766 |
}
|
|
|
767 |
} else {
|
|
|
768 |
eval(element + '=value;');
|
|
|
769 |
errorCode = "0";
|
|
|
770 |
if (scormdebugging) {
|
|
|
771 |
LogAPICall("SetValue", element, value, errorCode);
|
|
|
772 |
}
|
|
|
773 |
return "true";
|
|
|
774 |
}
|
|
|
775 |
}
|
|
|
776 |
} else {
|
|
|
777 |
errorCode = "406";
|
|
|
778 |
}
|
|
|
779 |
} else {
|
|
|
780 |
errorCode = "404";
|
|
|
781 |
}
|
|
|
782 |
} else {
|
|
|
783 |
errorCode = "401"
|
|
|
784 |
}
|
|
|
785 |
} else {
|
|
|
786 |
errorCode = "351";
|
|
|
787 |
}
|
|
|
788 |
} else {
|
|
|
789 |
if (Terminated) {
|
|
|
790 |
errorCode = "133";
|
|
|
791 |
} else {
|
|
|
792 |
errorCode = "132";
|
|
|
793 |
}
|
|
|
794 |
}
|
|
|
795 |
if (scormdebugging) {
|
|
|
796 |
LogAPICall("SetValue", element, value, errorCode);
|
|
|
797 |
}
|
|
|
798 |
return "false";
|
|
|
799 |
}
|
|
|
800 |
|
|
|
801 |
function CRremovePrefixes (node) {
|
|
|
802 |
// check for prefixes lang, case, order
|
|
|
803 |
// case and then order
|
|
|
804 |
var seenOrder = false;
|
|
|
805 |
var seenCase = false;
|
|
|
806 |
var seenLang = false;
|
|
|
807 |
var errorCode = "0";
|
|
|
808 |
while (matches = node.match('^(\{(lang|case_matters|order_matters)=([^\}]+)\})')) {
|
|
|
809 |
switch (matches[2]) {
|
|
|
810 |
case 'lang':
|
|
|
811 |
// check for language prefix on each node
|
|
|
812 |
langmatches = node.match(CMILangcr);
|
|
|
813 |
if (langmatches != null) {
|
|
|
814 |
lang = langmatches[3];
|
|
|
815 |
// check that language string definition is valid
|
|
|
816 |
if (lang.length > 0 && lang != undefined) {
|
|
|
817 |
if (validLanguages[lang.toLowerCase()] == undefined) {
|
|
|
818 |
errorCode = "406";
|
|
|
819 |
}
|
|
|
820 |
}
|
|
|
821 |
}
|
|
|
822 |
seenLang = true;
|
|
|
823 |
break;
|
|
|
824 |
|
|
|
825 |
case 'case_matters':
|
|
|
826 |
// check for correct case answer
|
|
|
827 |
if (! seenLang && ! seenOrder && ! seenCase) {
|
|
|
828 |
if (matches[3] != 'true' && matches[3] != 'false') {
|
|
|
829 |
errorCode = "406";
|
|
|
830 |
}
|
|
|
831 |
}
|
|
|
832 |
seenCase = true;
|
|
|
833 |
break;
|
|
|
834 |
|
|
|
835 |
case 'order_matters':
|
|
|
836 |
// check for correct case answer
|
|
|
837 |
if (! seenCase && ! seenLang && ! seenOrder) {
|
|
|
838 |
if (matches[3] != 'true' && matches[3] != 'false') {
|
|
|
839 |
errorCode = "406";
|
|
|
840 |
}
|
|
|
841 |
}
|
|
|
842 |
seenOrder = true;
|
|
|
843 |
break;
|
|
|
844 |
|
|
|
845 |
default:
|
|
|
846 |
break;
|
|
|
847 |
}
|
|
|
848 |
node = node.substr(matches[1].length);
|
|
|
849 |
}
|
|
|
850 |
return {'errorCode': errorCode, 'node': node};
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
function CRcheckValueNodes(element, interactiontype, nodes, value, errorCode) {
|
|
|
854 |
expression = new RegExp(correct_responses[interactiontype].format);
|
|
|
855 |
for (var i = 0; (i < nodes.length) && (errorCode == "0"); i++) {
|
|
|
856 |
if (interactiontype.match('^(fill-in|long-fill-in|matching|performance|sequencing)$')) {
|
|
|
857 |
result = CRremovePrefixes(nodes[i]);
|
|
|
858 |
errorCode = result.errorCode;
|
|
|
859 |
nodes[i] = result.node;
|
|
|
860 |
}
|
|
|
861 |
|
|
|
862 |
if (correct_responses[interactiontype].delimiter2 != undefined) {
|
|
|
863 |
values = nodes[i].split(correct_responses[interactiontype].delimiter2);
|
|
|
864 |
if (values.length == 2) {
|
|
|
865 |
matches = values[0].match(expression);
|
|
|
866 |
if (matches == null) {
|
|
|
867 |
errorCode = "406";
|
|
|
868 |
} else {
|
|
|
869 |
var expression2 = new RegExp(correct_responses[interactiontype].format2);
|
|
|
870 |
matches = values[1].match(expression2);
|
|
|
871 |
if (matches == null) {
|
|
|
872 |
errorCode = "406";
|
|
|
873 |
}
|
|
|
874 |
}
|
|
|
875 |
} else {
|
|
|
876 |
errorCode = "406";
|
|
|
877 |
}
|
|
|
878 |
} else {
|
|
|
879 |
matches = nodes[i].match(expression);
|
|
|
880 |
//if ((matches == null) || (matches.join('').length == 0)) {
|
|
|
881 |
if ((matches == null && value != "") || (matches == null && interactiontype == "true-false")){
|
|
|
882 |
errorCode = "406";
|
|
|
883 |
} else {
|
|
|
884 |
// numeric range - left must be <= right
|
|
|
885 |
if (interactiontype == 'numeric' && nodes.length > 1) {
|
|
|
886 |
if (parseFloat(nodes[0]) > parseFloat(nodes[1])) {
|
|
|
887 |
errorCode = "406";
|
|
|
888 |
}
|
|
|
889 |
} else {
|
|
|
890 |
if ((nodes[i] != '') && (correct_responses[interactiontype].unique)) {
|
|
|
891 |
for (var j = 0; (j < i) && (errorCode == "0"); j++) {
|
|
|
892 |
if (nodes[i] == nodes[j]) {
|
|
|
893 |
errorCode = "406";
|
|
|
894 |
}
|
|
|
895 |
}
|
|
|
896 |
}
|
|
|
897 |
}
|
|
|
898 |
}
|
|
|
899 |
}
|
|
|
900 |
} // end of for each nodes
|
|
|
901 |
return errorCode;
|
|
|
902 |
}
|
|
|
903 |
|
|
|
904 |
function Commit (param) {
|
|
|
905 |
if (SCORMapi1_3.timeout) {
|
|
|
906 |
SCORMapi1_3.timeout.cancel();
|
|
|
907 |
SCORMapi1_3.timeout = null;
|
|
|
908 |
}
|
|
|
909 |
errorCode = "0";
|
|
|
910 |
if (param == "") {
|
|
|
911 |
if ((Initialized) && (!Terminated)) {
|
|
|
912 |
var AJAXResult = StoreData(cmi,false);
|
|
|
913 |
if (scormdebugging) {
|
|
|
914 |
LogAPICall("Commit", "AJAXResult", AJAXResult, 0);
|
|
|
915 |
}
|
|
|
916 |
var result = ('true' == AJAXResult) ? 'true' : 'false';
|
|
|
917 |
errorCode = ('true' == result) ? '0' : '101'; // General exception for any AJAX fault
|
|
|
918 |
if (scormdebugging) {
|
|
|
919 |
LogAPICall("Commit", "result", result, errorCode);
|
|
|
920 |
}
|
|
|
921 |
if ('false' == result) {
|
|
|
922 |
diagnostic = "Failure calling the Commit remote callback: the server replied with HTTP Status " + AJAXResult;
|
|
|
923 |
}
|
|
|
924 |
return result;
|
|
|
925 |
} else {
|
|
|
926 |
if (Terminated) {
|
|
|
927 |
errorCode = "143";
|
|
|
928 |
} else {
|
|
|
929 |
errorCode = "142";
|
|
|
930 |
}
|
|
|
931 |
}
|
|
|
932 |
} else {
|
|
|
933 |
errorCode = "201";
|
|
|
934 |
}
|
|
|
935 |
if (scormdebugging) {
|
|
|
936 |
LogAPICall("Commit", param, "", errorCode);
|
|
|
937 |
}
|
|
|
938 |
return "false";
|
|
|
939 |
}
|
|
|
940 |
|
|
|
941 |
function GetLastError () {
|
|
|
942 |
if (scormdebugging) {
|
|
|
943 |
LogAPICall("GetLastError", "", "", errorCode);
|
|
|
944 |
}
|
|
|
945 |
return errorCode;
|
|
|
946 |
}
|
|
|
947 |
|
|
|
948 |
function GetErrorString (param) {
|
|
|
949 |
if (param != "") {
|
|
|
950 |
var errorString = "";
|
|
|
951 |
switch(param) {
|
|
|
952 |
case "0":
|
|
|
953 |
errorString = "No error";
|
|
|
954 |
break;
|
|
|
955 |
case "101":
|
|
|
956 |
errorString = "General exception";
|
|
|
957 |
break;
|
|
|
958 |
case "102":
|
|
|
959 |
errorString = "General Inizialization Failure";
|
|
|
960 |
break;
|
|
|
961 |
case "103":
|
|
|
962 |
errorString = "Already Initialized";
|
|
|
963 |
break;
|
|
|
964 |
case "104":
|
|
|
965 |
errorString = "Content Instance Terminated";
|
|
|
966 |
break;
|
|
|
967 |
case "111":
|
|
|
968 |
errorString = "General Termination Failure";
|
|
|
969 |
break;
|
|
|
970 |
case "112":
|
|
|
971 |
errorString = "Termination Before Inizialization";
|
|
|
972 |
break;
|
|
|
973 |
case "113":
|
|
|
974 |
errorString = "Termination After Termination";
|
|
|
975 |
break;
|
|
|
976 |
case "122":
|
|
|
977 |
errorString = "Retrieve Data Before Initialization";
|
|
|
978 |
break;
|
|
|
979 |
case "123":
|
|
|
980 |
errorString = "Retrieve Data After Termination";
|
|
|
981 |
break;
|
|
|
982 |
case "132":
|
|
|
983 |
errorString = "Store Data Before Inizialization";
|
|
|
984 |
break;
|
|
|
985 |
case "133":
|
|
|
986 |
errorString = "Store Data After Termination";
|
|
|
987 |
break;
|
|
|
988 |
case "142":
|
|
|
989 |
errorString = "Commit Before Inizialization";
|
|
|
990 |
break;
|
|
|
991 |
case "143":
|
|
|
992 |
errorString = "Commit After Termination";
|
|
|
993 |
break;
|
|
|
994 |
case "201":
|
|
|
995 |
errorString = "General Argument Error";
|
|
|
996 |
break;
|
|
|
997 |
case "301":
|
|
|
998 |
errorString = "General Get Failure";
|
|
|
999 |
break;
|
|
|
1000 |
case "351":
|
|
|
1001 |
errorString = "General Set Failure";
|
|
|
1002 |
break;
|
|
|
1003 |
case "391":
|
|
|
1004 |
errorString = "General Commit Failure";
|
|
|
1005 |
break;
|
|
|
1006 |
case "401":
|
|
|
1007 |
errorString = "Undefinited Data Model";
|
|
|
1008 |
break;
|
|
|
1009 |
case "402":
|
|
|
1010 |
errorString = "Unimplemented Data Model Element";
|
|
|
1011 |
break;
|
|
|
1012 |
case "403":
|
|
|
1013 |
errorString = "Data Model Element Value Not Initialized";
|
|
|
1014 |
break;
|
|
|
1015 |
case "404":
|
|
|
1016 |
errorString = "Data Model Element Is Read Only";
|
|
|
1017 |
break;
|
|
|
1018 |
case "405":
|
|
|
1019 |
errorString = "Data Model Element Is Write Only";
|
|
|
1020 |
break;
|
|
|
1021 |
case "406":
|
|
|
1022 |
errorString = "Data Model Element Type Mismatch";
|
|
|
1023 |
break;
|
|
|
1024 |
case "407":
|
|
|
1025 |
errorString = "Data Model Element Value Out Of Range";
|
|
|
1026 |
break;
|
|
|
1027 |
case "408":
|
|
|
1028 |
errorString = "Data Model Dependency Not Established";
|
|
|
1029 |
break;
|
|
|
1030 |
}
|
|
|
1031 |
if (scormdebugging) {
|
|
|
1032 |
LogAPICall("GetErrorString", param, errorString, 0);
|
|
|
1033 |
}
|
|
|
1034 |
return errorString;
|
|
|
1035 |
} else {
|
|
|
1036 |
if (scormdebugging) {
|
|
|
1037 |
LogAPICall("GetErrorString", param, "No error string found!", 0);
|
|
|
1038 |
}
|
|
|
1039 |
return "";
|
|
|
1040 |
}
|
|
|
1041 |
}
|
|
|
1042 |
|
|
|
1043 |
function GetDiagnostic (param) {
|
|
|
1044 |
if (diagnostic != "") {
|
|
|
1045 |
if (scormdebugging) {
|
|
|
1046 |
LogAPICall("GetDiagnostic", param, diagnostic, 0);
|
|
|
1047 |
}
|
|
|
1048 |
return diagnostic;
|
|
|
1049 |
}
|
|
|
1050 |
if (scormdebugging) {
|
|
|
1051 |
LogAPICall("GetDiagnostic", param, param, 0);
|
|
|
1052 |
}
|
|
|
1053 |
return param;
|
|
|
1054 |
}
|
|
|
1055 |
|
|
|
1056 |
function duplicatedID (element, parent, value) {
|
|
|
1057 |
var found = false;
|
|
|
1058 |
var elements = eval(parent + '._count');
|
|
|
1059 |
for (var n = 0; (n < elements) && (!found); n++) {
|
|
|
1060 |
if ((parent + '.N' + n + '.id' != element) && (eval(parent + '.N' + n + '.id') == value)) {
|
|
|
1061 |
found = true;
|
|
|
1062 |
}
|
|
|
1063 |
}
|
|
|
1064 |
return found;
|
|
|
1065 |
}
|
|
|
1066 |
|
|
|
1067 |
function duplicatedPA (element, parent, value) {
|
|
|
1068 |
var found = false;
|
|
|
1069 |
var elements = eval(parent + '._count');
|
|
|
1070 |
for (var n = 0; (n < elements) && (!found); n++) {
|
|
|
1071 |
if ((parent + '.N' + n + '.pattern' != element) && (eval(parent + '.N' + n + '.pattern') == value)) {
|
|
|
1072 |
found = true;
|
|
|
1073 |
}
|
|
|
1074 |
}
|
|
|
1075 |
return found;
|
|
|
1076 |
}
|
|
|
1077 |
|
|
|
1078 |
function getElementModel(element) {
|
|
|
1079 |
if (typeof datamodel[scoid][element] != "undefined") {
|
|
|
1080 |
return element;
|
|
|
1081 |
} else {
|
|
|
1082 |
var expression = new RegExp(CMIIndex,'g');
|
|
|
1083 |
var elementmodel = String(element).replace(expression,'.n.');
|
|
|
1084 |
if (typeof datamodel[scoid][elementmodel] != "undefined") {
|
|
|
1085 |
return elementmodel;
|
|
|
1086 |
}
|
|
|
1087 |
}
|
|
|
1088 |
return false;
|
|
|
1089 |
}
|
|
|
1090 |
|
|
|
1091 |
function AddTime (first, second) {
|
|
|
1092 |
var timestring = 'P';
|
|
|
1093 |
var matchexpr = /^P((\d+)Y)?((\d+)M)?((\d+)D)?(T((\d+)H)?((\d+)M)?((\d+(\.\d{1,2})?)S)?)?$/;
|
|
|
1094 |
var firstarray = first.match(matchexpr);
|
|
|
1095 |
var secondarray = second.match(matchexpr);
|
|
|
1096 |
if ((firstarray != null) && (secondarray != null)) {
|
|
|
1097 |
var firstsecs = 0;
|
|
|
1098 |
if(parseFloat(firstarray[13],10) > 0){ firstsecs = parseFloat(firstarray[13],10); }
|
|
|
1099 |
var secondsecs = 0;
|
|
|
1100 |
if(parseFloat(secondarray[13],10) > 0){ secondsecs = parseFloat(secondarray[13],10); }
|
|
|
1101 |
var secs = firstsecs + secondsecs; //Seconds
|
|
|
1102 |
var change = Math.floor(secs / 60);
|
|
|
1103 |
secs = Math.round((secs - (change * 60)) * 100) / 100;
|
|
|
1104 |
var firstmins = 0;
|
|
|
1105 |
if(parseInt(firstarray[11],10) > 0){ firstmins = parseInt(firstarray[11],10); }
|
|
|
1106 |
var secondmins = 0;
|
|
|
1107 |
if(parseInt(secondarray[11],10) > 0){ secondmins = parseInt(secondarray[11],10); }
|
|
|
1108 |
var mins = firstmins + secondmins + change; //Minutes
|
|
|
1109 |
change = Math.floor(mins / 60);
|
|
|
1110 |
mins = Math.round(mins - (change * 60));
|
|
|
1111 |
var firsthours = 0;
|
|
|
1112 |
if(parseInt(firstarray[9],10) > 0){ firsthours = parseInt(firstarray[9],10); }
|
|
|
1113 |
var secondhours = 0;
|
|
|
1114 |
if(parseInt(secondarray[9],10) > 0){ secondhours = parseInt(secondarray[9],10); }
|
|
|
1115 |
var hours = firsthours + secondhours + change; //Hours
|
|
|
1116 |
change = Math.floor(hours / 24);
|
|
|
1117 |
hours = Math.round(hours - (change * 24));
|
|
|
1118 |
var firstdays = 0;
|
|
|
1119 |
if(parseInt(firstarray[6],10) > 0){ firstdays = parseInt(firstarray[6],10); }
|
|
|
1120 |
var seconddays = 0;
|
|
|
1121 |
if(parseInt(secondarray[6],10) > 0){ firstdays = parseInt(secondarray[6],10); }
|
|
|
1122 |
var days = Math.round(firstdays + seconddays + change); // Days
|
|
|
1123 |
var firstmonths = 0;
|
|
|
1124 |
if(parseInt(firstarray[4],10) > 0){ firstmonths = parseInt(firstarray[4],10); }
|
|
|
1125 |
var secondmonths = 0;
|
|
|
1126 |
if(parseInt(secondarray[4],10) > 0){ secondmonths = parseInt(secondarray[4],10); }
|
|
|
1127 |
var months = Math.round(firstmonths + secondmonths);
|
|
|
1128 |
var firstyears = 0;
|
|
|
1129 |
if(parseInt(firstarray[2],10) > 0){ firstyears = parseInt(firstarray[2],10); }
|
|
|
1130 |
var secondyears = 0;
|
|
|
1131 |
if(parseInt(secondarray[2],10) > 0){ secondyears = parseInt(secondarray[2],10); }
|
|
|
1132 |
var years = Math.round(firstyears + secondyears);
|
|
|
1133 |
}
|
|
|
1134 |
if (years > 0) {
|
|
|
1135 |
timestring += years + 'Y';
|
|
|
1136 |
}
|
|
|
1137 |
if (months > 0) {
|
|
|
1138 |
timestring += months + 'M';
|
|
|
1139 |
}
|
|
|
1140 |
if (days > 0) {
|
|
|
1141 |
timestring += days + 'D';
|
|
|
1142 |
}
|
|
|
1143 |
if ((hours > 0) || (mins > 0) || (secs > 0)) {
|
|
|
1144 |
timestring += 'T';
|
|
|
1145 |
if (hours > 0) {
|
|
|
1146 |
timestring += hours + 'H';
|
|
|
1147 |
}
|
|
|
1148 |
if (mins > 0) {
|
|
|
1149 |
timestring += mins + 'M';
|
|
|
1150 |
}
|
|
|
1151 |
if (secs > 0) {
|
|
|
1152 |
timestring += secs + 'S';
|
|
|
1153 |
}
|
|
|
1154 |
}
|
|
|
1155 |
return timestring;
|
|
|
1156 |
}
|
|
|
1157 |
|
|
|
1158 |
function TotalTime() {
|
|
|
1159 |
var total_time = AddTime(cmi.total_time, cmi.session_time);
|
|
|
1160 |
return '&' + underscore('cmi.total_time') + '=' + encodeURIComponent(total_time);
|
|
|
1161 |
}
|
|
|
1162 |
|
|
|
1163 |
function CollectData(data,parent) {
|
|
|
1164 |
var datastring = '';
|
|
|
1165 |
for (property in data) {
|
|
|
1166 |
if (typeof data[property] == 'object') {
|
|
|
1167 |
datastring += CollectData(data[property],parent + '.' + property);
|
|
|
1168 |
} else {
|
|
|
1169 |
var element = parent + '.' + property;
|
|
|
1170 |
var expression = new RegExp(CMIIndexStore,'g');
|
|
|
1171 |
var elementmodel = String(element).replace(expression,'.n.');
|
|
|
1172 |
if (typeof datamodel[scoid][elementmodel] != "undefined") {
|
|
|
1173 |
if (datamodel[scoid][elementmodel].mod != 'r') {
|
|
|
1174 |
var elementstring = '&' + underscore(element) + '=' + encodeURIComponent(data[property]);
|
|
|
1175 |
if (typeof datamodel[scoid][elementmodel].defaultvalue != "undefined") {
|
|
|
1176 |
if (datamodel[scoid][elementmodel].defaultvalue != data[property] ||
|
|
|
1177 |
typeof datamodel[scoid][elementmodel].defaultvalue != typeof data[property]) {
|
|
|
1178 |
datastring += elementstring;
|
|
|
1179 |
}
|
|
|
1180 |
} else {
|
|
|
1181 |
datastring += elementstring;
|
|
|
1182 |
}
|
|
|
1183 |
}
|
|
|
1184 |
}
|
|
|
1185 |
}
|
|
|
1186 |
}
|
|
|
1187 |
return datastring;
|
|
|
1188 |
}
|
|
|
1189 |
|
|
|
1190 |
function StoreData(data,storetotaltime) {
|
|
|
1191 |
var datastring = '';
|
|
|
1192 |
if (storetotaltime) {
|
|
|
1193 |
if (cmi.mode == 'normal') {
|
|
|
1194 |
if (cmi.credit == 'credit') {
|
|
|
1195 |
if ((cmi.completion_threshold) && (cmi.progress_measure)) {
|
|
|
1196 |
if (cmi.progress_measure >= cmi.completion_threshold) {
|
|
|
1197 |
cmi.completion_status = 'completed';
|
|
|
1198 |
} else {
|
|
|
1199 |
cmi.completion_status = 'incomplete';
|
|
|
1200 |
}
|
|
|
1201 |
}
|
|
|
1202 |
if ((cmi.scaled_passed_score != null) && (cmi.score.scaled != '')) {
|
|
|
1203 |
if (cmi.score.scaled >= cmi.scaled_passed_score) {
|
|
|
1204 |
cmi.success_status = 'passed';
|
|
|
1205 |
} else {
|
|
|
1206 |
cmi.success_status = 'failed';
|
|
|
1207 |
}
|
|
|
1208 |
}
|
|
|
1209 |
}
|
|
|
1210 |
}
|
|
|
1211 |
datastring += TotalTime();
|
|
|
1212 |
}
|
|
|
1213 |
datastring += CollectData(data,'cmi');
|
|
|
1214 |
var element = 'adl.nav.request';
|
|
|
1215 |
var navrequest = eval(element) != datamodel[scoid][element].defaultvalue ? '&' + underscore(element) + '=' + encodeURIComponent(eval(element)) : '';
|
|
|
1216 |
datastring += navrequest;
|
|
|
1217 |
|
|
|
1218 |
var myRequest = NewHttpReq();
|
|
|
1219 |
var result = DoRequest(myRequest, datamodelurl, datamodelurlparams + datastring);
|
|
|
1220 |
|
|
|
1221 |
if (result === false) {
|
|
|
1222 |
return false;
|
|
|
1223 |
}
|
|
|
1224 |
|
|
|
1225 |
var results = String(result).split('\n');
|
|
|
1226 |
if ((results.length > 2) && (navrequest != '')) {
|
|
|
1227 |
eval(results[2]);
|
|
|
1228 |
}
|
|
|
1229 |
errorCode = results[1];
|
|
|
1230 |
return results[0];
|
|
|
1231 |
}
|
|
|
1232 |
|
|
|
1233 |
this.Initialize = Initialize;
|
|
|
1234 |
this.Terminate = Terminate;
|
|
|
1235 |
this.GetValue = GetValue;
|
|
|
1236 |
this.SetValue = SetValue;
|
|
|
1237 |
this.Commit = Commit;
|
|
|
1238 |
this.GetLastError = GetLastError;
|
|
|
1239 |
this.GetErrorString = GetErrorString;
|
|
|
1240 |
this.GetDiagnostic = GetDiagnostic;
|
|
|
1241 |
this.version = '1.0';
|
|
|
1242 |
}
|
|
|
1243 |
|
|
|
1244 |
M.scorm_api = {};
|
|
|
1245 |
|
|
|
1246 |
M.scorm_api.init = function(Y, def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit) {
|
|
|
1247 |
window.API_1484_11 = new SCORMapi1_3(def, cmiobj, cmiint, cmicommentsuser, cmicommentslms, scormdebugging, scormauto, scormid, cfgwwwroot, sesskey, scoid, attempt, viewmode, cmid, currentorg, autocommit);
|
|
|
1248 |
}
|