Skip to content
Browse files

MDL-7068 - SCORM 2004 compliance - fix mod/scorm to handle core data …

…elements correctly - now passes test DMI. backport 1.8.
  • Loading branch information...
1 parent 58208f5 commit 516ca02e7e1f05c507dd2cb743e0c0ddd204144e piers committed Oct 31, 2008
Showing with 506 additions and 196 deletions.
  1. +506 −196 mod/scorm/datamodels/scorm_13.js.php
View
702 mod/scorm/datamodels/scorm_13.js.php
@@ -13,55 +13,138 @@
}
}
?>
-// var cmi = new Object(); // Used need to debug cmi content (if you uncomment this, you must comment the definition inside SCORMapi1_3)
+
+// Used need to debug cmi content (if you uncomment this, you must comment the definition inside SCORMapi1_3)
+//var cmi = new Object();
//
// SCORM 1.3 API Implementation
//
function SCORMapi1_3() {
// Standard Data Type Definition
- CMIString200 = '^.{0,200}$';
- CMIString250 = '^.{0,250}$';
- CMILangString250 = '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,250}$)?';
- CMIString1000 = '^.{0,1500}$';
- CMIString4000 = '^.{0,4000}$';
- CMILangString4000 = '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,4000}$)?';
- CMIString64000 = '^.{0,64000}$';
- CMILang = '^([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?$|^$';
- 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})?)?)?)?)?)?)?)?$';
- 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))))?$';
- CMIInteger = '^\\d+$';
- CMISInteger = '^-?([0-9]+)$';
- CMIDecimal = '^-?([0-9]{1,4})(\\.[0-9]{1,18})?$';
- CMIIdentifier = '^\\S{0,200}[a-zA-Z0-9]$';
- CMILongIdentifier = '^\\S{0,4000}[a-zA-Z0-9]$';
- CMIFeedback = CMIString200; // This must be redefined
- CMIIndex = '[._](\\d+).';
- CMIIndexStore = '.N(\\d+).';
+
+ // language key has to be checked for language dependent strings
+ 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',
+ 'ba':'ba', 'be':'be', 'bg':'bg', 'bh':'bh', 'bi':'bi', 'bm':'bm', 'bn':'bn', 'bo':'bo', 'br':'br', 'bs':'bs',
+ 'ca':'ca', 'ce':'ce', 'ch':'ch', 'co':'co', 'cr':'cr', 'cs':'cs', 'cu':'cu', 'cv':'cv', 'cy':'cy',
+ 'da':'da', 'de':'de', 'dv':'dv', 'dz':'dz', 'ee':'ee', 'el':'el', 'en':'en', 'eo':'eo', 'es':'es', 'et':'et', 'eu':'eu',
+ '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',
+ 'ha':'ha', 'he':'he', 'hi':'hi', 'ho':'ho', 'hr':'hr', 'ht':'ht', 'hu':'hu', 'hy':'hy', 'hz':'hz',
+ 'ia':'ia', 'id':'id', 'ie':'ie', 'ig':'ig', 'ii':'ii', 'ik':'ik', 'io':'io', 'is':'is', 'it':'it', 'iu':'iu',
+ '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',
+ 'la':'la', 'lb':'lb', 'lg':'lg', 'li':'li', 'ln':'ln', 'lo':'lo', 'lt':'lt', 'lu':'lu', 'lv':'lv',
+ 'mg':'mg', 'mh':'mh', 'mi':'mi', 'mk':'mk', 'ml':'ml', 'mn':'mn', 'mo':'mo', 'mr':'mr', 'ms':'ms', 'mt':'mt', 'my':'my',
+ 'na':'na', 'nb':'nb', 'nd':'nd', 'ne':'ne', 'ng':'ng', 'nl':'nl', 'nn':'nn', 'no':'no', 'nr':'nr', 'nv':'nv', 'ny':'ny',
+ 'oc':'oc', 'oj':'oj', 'om':'om', 'or':'or', 'os':'os', 'pa':'pa', 'pi':'pi', 'pl':'pl', 'ps':'ps', 'pt':'pt',
+ 'qu':'qu', 'rm':'rm', 'rn':'rn', 'ro':'ro', 'ru':'ru', 'rw':'rw',
+ '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',
+ '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',
+ 'ug':'ug', 'uk':'uk', 'ur':'ur', 'uz':'uz', 've':'ve', 'vi':'vi', 'vo':'vo',
+ 'wa':'wa', 'wo':'wo', 'xh':'xh', 'yi':'yi', 'yo':'yo', 'za':'za', 'zh':'zh', 'zu':'zu',
+ 'aar':'aar', 'abk':'abk', 'ave':'ave', 'afr':'afr', 'aka':'aka', 'amh':'amh', 'arg':'arg', 'ara':'ara', 'asm':'asm', 'ava':'ava', 'aym':'aym', 'aze':'aze',
+ 'bak':'bak', 'bel':'bel', 'bul':'bul', 'bih':'bih', 'bis':'bis', 'bam':'bam', 'ben':'ben', 'tib':'tib', 'bod':'bod', 'bre':'bre', 'bos':'bos',
+ 'cat':'cat', 'che':'che', 'cha':'cha', 'cos':'cos', 'cre':'cre', 'cze':'cze', 'ces':'ces', 'chu':'chu', 'chv':'chv', 'wel':'wel', 'cym':'cym',
+ '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',
+ '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',
+ 'hau':'hau', 'heb':'heb', 'hin':'hin', 'hmo':'hmo', 'hrv':'hrv', 'hat':'hat', 'hun':'hun', 'arm':'arm', 'hye':'hye', 'her':'her',
+ 'ina':'ina', 'ind':'ind', 'ile':'ile', 'ibo':'ibo', 'iii':'iii', 'ipk':'ipk', 'ido':'ido', 'ice':'ice', 'isl':'isl', 'ita':'ita', 'iku':'iku',
+ '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',
+ 'lat':'lat', 'ltz':'ltz', 'lug':'lug', 'lim':'lim', 'lin':'lin', 'lao':'lao', 'lit':'lit', 'lub':'lub', 'lav':'lav',
+ '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',
+ 'nau':'nau', 'nob':'nob', 'nde':'nde', 'nep':'nep', 'ndo':'ndo', 'dut':'dut', 'nld':'nld', 'nno':'nno', 'nor':'nor', 'nbl':'nbl', 'nav':'nav', 'nya':'nya',
+ 'oci':'oci', 'oji':'oji', 'orm':'orm', 'ori':'ori', 'oss':'oss', 'pan':'pan', 'pli':'pli', 'pol':'pol', 'pus':'pus', 'por':'por', 'que':'que',
+ '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',
+ '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',
+ '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'};
+
+ var CMIString200 = '^.{0,200}$';
+ var CMIString250 = '^.{0,250}$';
+ var CMIString1000 = '^.{0,1500}$';
+ var CMIString4000 = '^.{0,4000}$';
+ var CMIString64000 = '^.{0,64000}$';
+ var CMILang = '^([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?$|^$';
+ var CMILangString250 = '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,250}$)?';
+ var CMILangcr = '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\}))(.*?)$';
+ var CMILangString250cr = '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\})?(.{0,250})?)?$';
+ var CMILangString4000 = '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,4000}$)?';
+ 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})?)?)?)?)?)?)?)?$';
+ 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))))?$';
+ var CMIInteger = '^\\d+$';
+ var CMISInteger = '^-?([0-9]+)$';
+ var CMIDecimal = '^-?([0-9]{1,5})(\\.[0-9]{1,18})?$';
+ var CMIIdentifier = '^\\S{0,250}[a-zA-Z0-9]$';
+ var CMIShortIdentifier = '^[\\w\.]{1,250}$';
+ var CMILongIdentifier = '^\\S{0,4000}[a-zA-Z0-9]$';
+ var CMIFeedback = '^.*$'; // This must be redefined
+ var CMIIndex = '[._](\\d+).';
+ var CMIIndexStore = '.N(\\d+).';
// Vocabulary Data Type Definition
- CMICStatus = '^completed$|^incomplete$|^not attempted$|^unknown$';
- CMISStatus = '^passed$|^failed$|^unknown$';
- CMIExit = '^time-out$|^suspend$|^logout$|^normal$|^$';
- CMIType = '^true-false$|^choice$|^(long-)?fill-in$|^matching$|^performance$|^sequencing$|^likert$|^numeric$|^other$';
- CMIResult = '^correct$|^incorrect$|^unanticipated$|^neutral$|^-?([0-9]{1,4})(\\.[0-9]{1,18})?$';
- NAVEvent = '^previous$|^continue$|^exit$|^exitAll$|^abandon$|^abandonAll$|^suspendAll$|^{target=\\S{0,200}[a-zA-Z0-9]}choice$';
- NAVBoolean = '^unknown$|^true$|^false$';
- NAVTarget = '^previous$|^continue$|^choice.{target=\\S{0,200}[a-zA-Z0-9]}$'
+ var CMICStatus = '^completed$|^incomplete$|^not attempted$|^unknown$';
+ var CMISStatus = '^passed$|^failed$|^unknown$';
+ var CMIExit = '^time-out$|^suspend$|^logout$|^normal$|^$';
+ var CMIType = '^true-false$|^choice$|^(long-)?fill-in$|^matching$|^performance$|^sequencing$|^likert$|^numeric$|^other$';
+ var CMIResult = '^correct$|^incorrect$|^unanticipated$|^neutral$|^-?([0-9]{1,4})(\\.[0-9]{1,18})?$';
+ var NAVEvent = '^previous$|^continue$|^exit$|^exitAll$|^abandon$|^abandonAll$|^suspendAll$|^{target=\\S{0,200}[a-zA-Z0-9]}choice$';
+ var NAVBoolean = '^unknown$|^true$|^false$';
+ var NAVTarget = '^previous$|^continue$|^choice.{target=\\S{0,200}[a-zA-Z0-9]}$'
// Children lists
- 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';
- comments_children = 'comment, timestamp, location';
- score_children = 'max, raw, scaled, min';
- objectives_children = 'progress_measure, completion_status, success_status, description, score, id';
- correct_responses_children = 'pattern';
- student_data_children = 'mastery_score, max_time_allowed, time_limit_action';
- student_preference_children = 'audio_level, audio_captioning, delivery_speed, language';
- interactions_children = 'id, type, objectives, timestamp, correct_responses, weighting, learner_response, result, latency, description';
+ 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';
+ var comments_children = 'comment, timestamp, location';
+ var score_children = 'max, raw, scaled, min';
+ var objectives_children = 'progress_measure, completion_status, success_status, description, score, id';
+ var correct_responses_children = 'pattern';
+ var student_data_children = 'mastery_score, max_time_allowed, time_limit_action';
+ var student_preference_children = 'audio_level, audio_captioning, delivery_speed, language';
+ var interactions_children = 'id, type, objectives, timestamp, correct_responses, weighting, learner_response, result, latency, description';
// Data ranges
- scaled_range = '-1#1';
- audio_range = '0#*';
- speed_range = '0#*';
- text_range = '-1#1';
- progress_range = '0#1';
+ var scaled_range = '-1#1';
+ var audio_range = '0#*';
+ var speed_range = '0#*';
+ var text_range = '-1#1';
+ var progress_range = '0#1';
+ var learner_response = {
+ 'true-false':{'format':'^true$|^false$', 'max':1, 'delimiter':'', 'unique':false},
+ 'choice':{'format':CMIShortIdentifier, 'max':36, 'delimiter':'[,]', 'unique':true},
+ 'fill-in':{'format':CMILangString250, 'max':10, 'delimiter':'[,]', 'unique':false},
+ 'long-fill-in':{'format':CMILangString4000, 'max':1, 'delimiter':'', 'unique':false},
+ 'matching':{'format':CMIShortIdentifier, 'format2':CMIShortIdentifier, 'max':36, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false},
+ 'performance':{'format':'^$|'+CMIShortIdentifier, 'format2':CMIDecimal+'|^$|'+CMIShortIdentifier, 'max':250, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false},
+ 'sequencing':{'format':CMIShortIdentifier, 'max':36, 'delimiter':'[,]', 'unique':false},
+ 'likert':{'format':CMIShortIdentifier, 'max':1, 'delimiter':'', 'unique':false},
+ 'numeric':{'format':CMIDecimal, 'max':1, 'delimiter':'', 'unique':false},
+ 'other':{'format':CMIString4000, 'max':1, 'delimiter':'', 'unique':false}
+ }
+
+ var correct_responses = {
+ 'true-false':{'pre':'', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':false,
+ 'format':'^true$|^false$',
+ 'limit':1},
+ 'choice':{'pre':'', 'max':36, 'delimiter':'[,]', 'unique':true, 'duplicate':false,
+ 'format':CMIShortIdentifier},
+// 'fill-in':{'pre':'^(((\{case_matters=(true|false)\})(\{order_matters=(true|false)\})?)|((\{order_matters=(true|false)\})(\{case_matters=(true|false)\})?))(.*?)$',
+ 'fill-in':{'pre':'',
+ 'max':10, 'delimiter':'[,]', 'unique':false, 'duplicate':false,
+ 'format':CMILangString250cr},
+ 'long-fill-in':{'pre':'^(\{case_matters=(true|false)\})?', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':true,
+ 'format':CMILangString4000},
+ 'matching':{'pre':'', 'max':36, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false,
+ 'format':CMIShortIdentifier, 'format2':CMIShortIdentifier},
+ 'performance':{'pre':'^(\{order_matters=(true|false)\})?',
+ 'max':250, 'delimiter':'[,]', 'delimiter2':'[.]', 'unique':false, 'duplicate':false,
+ 'format':'^$|'+CMIShortIdentifier, 'format2':CMIDecimal+'|^$|'+CMIShortIdentifier},
+ 'sequencing':{'pre':'', 'max':36, 'delimiter':'[,]', 'unique':false, 'duplicate':false,
+ 'format':CMIShortIdentifier},
+ 'likert':{'pre':'', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':false,
+ 'format':CMIShortIdentifier,
+ 'limit':1},
+ 'numeric':{'pre':'', 'max':2, 'delimiter':'[:]', 'unique':false, 'duplicate':false,
+ 'format':CMIDecimal,
+ 'limit':1},
+ 'other':{'pre':'', 'max':1, 'delimiter':'', 'unique':false, 'duplicate':false,
+ 'format':CMIString4000,
+ 'limit':1}
+ }
+
// The SCORM 1.3 data model
var datamodel = {
'cmi._children':{'defaultvalue':cmi_children, 'mod':'r'},
@@ -89,9 +172,9 @@ function SCORMapi1_3() {
'cmi.interactions.n.objectives.n.id':{'pattern':CMIIndex, 'format':CMILongIdentifier, 'mod':'rw'},
'cmi.interactions.n.timestamp':{'pattern':CMIIndex, 'format':CMITime, 'mod':'rw'},
'cmi.interactions.n.correct_responses._count':{'defaultvalue':'0', 'pattern':CMIIndex, 'mod':'r'},
- 'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'rw'},
+ 'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':'CMIFeedback', 'mod':'rw'},
'cmi.interactions.n.weighting':{'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'rw'},
- 'cmi.interactions.n.learner_response':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'rw'},
+ 'cmi.interactions.n.learner_response':{'pattern':CMIIndex, 'format':'CMIFeedback', 'mod':'rw'},
'cmi.interactions.n.result':{'pattern':CMIIndex, 'format':CMIResult, 'mod':'rw'},
'cmi.interactions.n.latency':{'pattern':CMIIndex, 'format':CMITimespan, 'mod':'rw'},
'cmi.interactions.n.description':{'pattern':CMIIndex, 'format':CMILangString250, 'mod':'rw'},
@@ -135,7 +218,7 @@ function SCORMapi1_3() {
//
// Datamodel inizialization
//
- var cmi = new Object();
+ var cmi = new Object();
cmi.comments_from_learner = new Object();
cmi.comments_from_learner._count = 0;
cmi.comments_from_lms = new Object();
@@ -225,7 +308,7 @@ function Terminate (param) {
?>
Initialized = false;
Terminated = true;
- result = StoreData(cmi,true);
+ var result = StoreData(cmi,true);
if (adl.nav.request != '_none_') {
switch (adl.nav.request) {
case 'continue':
@@ -274,17 +357,17 @@ function GetValue (element) {
diagnostic = "";
if ((Initialized) && (!Terminated)) {
if (element !="") {
- expression = new RegExp(CMIIndex,'g');
- elementmodel = String(element).replace(expression,'.n.');
+ var expression = new RegExp(CMIIndex,'g');
+ var elementmodel = String(element).replace(expression,'.n.');
if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
if (eval('datamodel["'+elementmodel+'"].mod') != 'w') {
element = String(element).replace(/\.(\d+)\./, ".N$1.");
element = element.replace(/\.(\d+)\./, ".N$1.");
- elementIndexes = element.split('.');
- subelement = element.substr(0,3);
- i = 1;
+ var elementIndexes = element.split('.');
+ var subelement = element.substr(0,3);
+ var i = 1;
while ((i < elementIndexes.length) && (typeof eval(subelement) != "undefined")) {
subelement += '.'+elementIndexes[i++];
}
@@ -311,8 +394,9 @@ function GetValue (element) {
errorCode = "405";
}
} else {
- childrenstr = '._children';
- countstr = '._count';
+ var childrenstr = '._children';
+ var countstr = '._count';
+ var parentmodel = '';
if (elementmodel.substr(elementmodel.length-childrenstr.length,elementmodel.length) == childrenstr) {
parentmodel = elementmodel.substr(0,elementmodel.length-childrenstr.length);
if ((typeof eval('datamodel["'+parentmodel+'"]')) != "undefined") {
@@ -370,68 +454,69 @@ function GetValue (element) {
function SetValue (element,value) {
errorCode = "0";
diagnostic = "";
-
if ((Initialized) && (!Terminated)) {
if (element != "") {
- expression = new RegExp(CMIIndex,'g');
- elementmodel = String(element).replace(expression,'.n.');
+ var expression = new RegExp(CMIIndex,'g');
+ var elementmodel = String(element).replace(expression,'.n.');
if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
- expression = new RegExp(eval('datamodel["'+elementmodel+'"].format'));
+ if (eval('datamodel["'+elementmodel+'"].format') != 'CMIFeedback') {
+ expression = new RegExp(eval('datamodel["'+elementmodel+'"].format'));
+ } else {
+ // cmi.interactions.n.type depending format accept everything at this stage
+ expression = new RegExp(CMIFeedback);
+ }
value = value+'';
- matches = value.match(expression);
+ var matches = value.match(expression);
if ((matches != null) && ((matches.join('').length > 0) || (value.length == 0))) {
-
- //Create dynamic data model element
+ // Value match dataelement format
if (element != elementmodel) {
- elementIndexes = element.split('.');
- subelement = 'cmi';
- parentelement = 'cmi';
- for (i=1;(i < elementIndexes.length-1) && (errorCode=="0");i++) {
- elementIndex = elementIndexes[i];
+ //This is a dynamic datamodel element
+
+ var elementIndexes = element.split('.');
+ var subelement = 'cmi';
+ var parentelement = 'cmi';
+ for (var i=1;(i < elementIndexes.length-1) && (errorCode=="0");i++) {
+ var elementIndex = elementIndexes[i];
if (elementIndexes[i+1].match(/^\d+$/)) {
if ((parseInt(elementIndexes[i+1]) > 0) && (elementIndexes[i+1].charAt(0) == 0)) {
// Index has a leading 0 (zero), this is not a number
errorCode = "351";
}
parentelement = subelement+'.'+elementIndex;
- if (elementIndexes[i+1] > eval(parentelement+'._count')) {
-
- errorCode = "351";
- diagnostic = "Data Model Element Collection Set Out Of Order";
- }
- subelement = subelement.concat('.'+elementIndex+'.N'+elementIndexes[i+1]);
- i++;
-
- if (((typeof eval(subelement)) == "undefined") && (i < elementIndexes.length-2)) {
+ if ((typeof eval(parentelement) == "undefined") || (typeof eval(parentelement+'._count') == "undefined")) {
errorCode="408";
+ } else {
+ if (elementIndexes[i+1] > eval(parentelement+'._count')) {
+ errorCode = "351";
+ diagnostic = "Data Model Element Collection Set Out Of Order";
+ }
+ subelement = subelement.concat('.'+elementIndex+'.N'+elementIndexes[i+1]);
+ i++;
+
+ if (((typeof eval(subelement)) == "undefined") && (i < elementIndexes.length-2)) {
+ errorCode="408";
+ }
}
} else {
subelement = subelement.concat('.'+elementIndex);
}
}
-
-
if (errorCode == "0") {
+ // Till now it's a real datamodel element
element = subelement.concat('.'+elementIndexes[elementIndexes.length-1]);
- elemlen = element.length;
- if (((typeof eval(subelement)) == "undefined") && (errorCode == "0")) {
- parentmodel = 'cmi.objectives';
- maxmodel = 'cmi.objectives.Nxxx.id';
- if (subelement.substr(0,parentmodel.length) == parentmodel) {
-
- if ((elemlen <= maxmodel.length) && (element.substr(elemlen-2) == 'id') && (errorCode=="0")) {
-
- //This is a parentmodel.n.id element
- if (!duplicatedID(parentmodel,value)) {
- if (elementIndexes[elementIndexes.length-2] == eval(parentmodel+'._count')) {
- eval(parentmodel+'._count++;');
+ if ((typeof eval(subelement)) == "undefined") {
+ switch (elementmodel) {
+ case 'cmi.objectives.n.id':
+ if (!duplicatedID(element,parentelement,value)) {
+ if (elementIndexes[elementIndexes.length-2] == eval(parentelement+'._count')) {
+ eval(parentelement+'._count++;');
eval(subelement+' = new Object();');
- subobject = eval(subelement);
+ var subobject = eval(subelement);
subobject.success_status = datamodel["cmi.objectives.n.success_status"].defaultvalue;
subobject.completion_status = datamodel["cmi.objectives.n.completion_status"].defaultvalue;
subobject.progress_measure = datamodel["cmi.objectives.n.progress_measure"].defaultvalue;
@@ -446,103 +531,204 @@ function SetValue (element,value) {
errorCode="351";
diagnostic = "Data Model Element ID Already Exists";
}
- } else {
-
-
- if (typeof eval(subelement) == "undefined") {
- errorCode="408";
- } else {
- if (duplicatedID(parentmodel,value)) {
- errorCode="351";
- diagnostic = "Data Model Element ID Already Exists";
- }
- }
- }
- } else {
-
-
-
- parentmodel = 'cmi.interactions';
- maxmodel = 'cmi.interactions.Nxxx.id';
-
- if (subelement.substr(0,parentmodel.length) == parentmodel) {
-
- if ((elemlen <= maxmodel.length) && (element.substr(elemlen-2) == 'id') && (errorCode=="0")) {
-
- //This is a parentmodel.n.id element
- if (!duplicatedID(parentmodel,value)) {
-
- if (elementIndexes[elementIndexes.length-2] == eval(parentmodel+'._count')) {
-
- eval(parentmodel+'._count++;');
-
+ break;
+ case 'cmi.interactions.n.id':
+ if (elementIndexes[elementIndexes.length-2] == eval(parentelement+'._count')) {
+ eval(parentelement+'._count++;');
+ eval(subelement+' = new Object();');
+ var subobject = eval(subelement);
+ subobject.objectives = new Object();
+ subobject.objectives._count = 0;
+ }
+ break;
+ case 'cmi.interactions.n.objectives.n.id':
+ if (typeof eval(parentelement) != "undefined") {
+ if (!duplicatedID(element,parentelement,value)) {
+ if (elementIndexes[elementIndexes.length-2] == eval(parentelement+'._count')) {
+ eval(parentelement+'._count++;');
eval(subelement+' = new Object();');
-
- subobject = eval(subelement);
- subobject.objectives = new Object();
- subobject.objectives._count = 0;
- subobject.correct_responses = new Object();
- subobject.correct_responses._count = 0;
-
-
- }
+ }
} else {
-
errorCode="351";
diagnostic = "Data Model Element ID Already Exists";
}
} else {
-
- if (typeof eval(subelement) == "undefined") {
-
- errorCode="408";
+ errorCode="408";
+ }
+ break;
+ case 'cmi.interactions.n.correct_responses.n.pattern':
+ if (typeof eval(parentelement) != "undefined") {
+ // Use cmi.interactions.n.type value to check the right dataelement format
+ if (elementIndexes[elementIndexes.length-2] == eval(parentelement+'._count')) {
+ var interactiontype = eval(String(parentelement).replace('correct_responses','type'));
+ var interactioncount = eval(parentelement+'._count');
+ // trap duplicate values, which is not allowed for type choice
+ if (interactiontype == 'choice') {
+ for (var i=0; (i < interactioncount) && (errorCode=="0"); i++) {
+ if (eval(parentelement+'.N'+i+'.pattern') == value) {
+ errorCode = "351";
+ }
+ }
+ }
+ if ((typeof correct_responses[interactiontype].limit == 'undefined') ||
+ (eval(parentelement+'._count') < correct_responses[interactiontype].limit)) {
+ var nodes = new Array();
+ if (correct_responses[interactiontype].delimiter != '') {
+ nodes = value.split(correct_responses[interactiontype].delimiter);
+ } else {
+ nodes[0] = value;
+ }
+ if (interactiontype == 'choice' && nodes.length == 1) {
+ alert('not enough choices: ' + element);
+ }
+ if ((nodes.length > 0) && (nodes.length <= correct_responses[interactiontype].max)) {
+ errorCode = CRcheckValueNodes (element, interactiontype, nodes, value, errorCode);
+ } else if (nodes.length > correct_responses[interactiontype].max) {
+ errorCode = "351";
+ diagnostic = "Data Model Element Pattern Too Long";
+ }
+ if ((errorCode == "0") && ((correct_responses[interactiontype].duplicate == false) ||
+ (!duplicatedPA(element,parentelement,value))) || (errorCode == "0" && value == "")) {
+ eval(parentelement+'._count++;');
+ eval(subelement+' = new Object();');
+ } else {
+ if (errorCode == "0") {
+ errorCode="351";
+ diagnostic = "Data Model Element Pattern Already Exists";
+ }
+ }
+ } else {
+ errorCode="351";
+ diagnostic = "Data Model Element Collection Limit Reached";
+ }
} else {
- maxmodel = 'cmi.interactions.Nxxx.type';
- if ((elemlen <= maxmodel.length) && (element.substr(elemlen-4) == 'type') && (errorCode=="0")) {
- subobject = eval(subelement);
- //subobject.correct_responses = new Object();
- //subobject.correct_responses._count = 0;
- subobject.learner_response = new Object();
- }
+ errorCode="351";
+ diagnostic = "Data Model Element Collection Set Out Of Order";
}
+ } else {
+ errorCode="408";
}
- } else {
-
-
- if (errorCode == "0") {
+ break;
+ default:
+ if ((parentelement != 'cmi.objectives') && (parentelement != 'cmi.interactions') && (typeof eval(parentelement) != "undefined")) {
if (elementIndexes[elementIndexes.length-2] == eval(parentelement+'._count')) {
eval(parentelement+'._count++;');
eval(subelement+' = new Object();');
+ } else {
+ errorCode="351";
+ diagnostic = "Data Model Element Collection Set Out Of Order";
}
+ } else {
+ errorCode="408";
}
- }
+ break;
}
- } else {
-
- parentmodel = 'cmi.objectives';
- maxmodel = 'cmi.objectives.Nxxx.id';
- if (subelement.substr(0,parentmodel.length) == parentmodel) {
- if ((elemlen <= maxmodel.length) && (element.substr(elemlen-2) == 'id') && (errorCode=="0")) {
-
- if (eval(element) != value) {
- errorCode = "351";
- diagnostic = "Write Once Violation";
- }
- }
- } else {
-
- parentmodel = 'cmi.interactions';
- maxmodel = 'cmi.interactions.Nxxx.id';
- if (subelement.substr(0,parentmodel.length) == parentmodel) {
- if ((elemlen <= maxmodel.length) && (element.substr(elemlen-2) == 'id') && (errorCode=="0")) {
- if (eval(element) != value) {
- errorCode = "351";
- diagnostic = "Write Once Violation";
- }
- }
- }
- }
- }
+ } else {
+ switch (elementmodel) {
+ case 'cmi.objectives.n.id':
+ if (eval(element) != value) {
+ errorCode = "351";
+ diagnostic = "Write Once Violation";
+ }
+ break;
+ case 'cmi.interactions.n.objectives.n.id':
+ if (duplicatedID(element,parentelement,value)) {
+ errorCode = "351";
+ diagnostic = "Data Model Element ID Already Exists";
+ }
+ break;
+ case 'cmi.interactions.n.type':
+ var subobject = eval(subelement);
+ subobject.correct_responses = new Object();
+ subobject.correct_responses._count = 0;
+ break;
+ case 'cmi.interactions.n.learner_response':
+ if (typeof eval(subelement+'.type') == "undefined") {
+ errorCode="408";
+ } else {
+ // Use cmi.interactions.n.type value to check the right dataelement format
+ interactiontype = eval(subelement+'.type');
+ var nodes = new Array();
+ if (learner_response[interactiontype].delimiter != '') {
+ nodes = value.split(learner_response[interactiontype].delimiter);
+ } else {
+ nodes[0] = value;
+ }
+ if ((nodes.length > 0) && (nodes.length <= learner_response[interactiontype].max)) {
+ expression = new RegExp(learner_response[interactiontype].format);
+ for (var i=0; (i < nodes.length) && (errorCode=="0"); i++) {
+ if (typeof learner_response[interactiontype].delimiter2 != 'undefined') {
+ values = nodes[i].split(learner_response[interactiontype].delimiter2);
+ if (values.length == 2) {
+ matches = values[0].match(expression);
+ if (matches == null) {
+ errorCode = "406";
+ } else {
+ var expression2 = new RegExp(learner_response[interactiontype].format2);
+ matches = values[1].match(expression2);
+ if (matches == null) {
+ errorCode = "406";
+ }
+ }
+ } else {
+ errorCode = "406";
+ }
+ } else {
+ matches = nodes[i].match(expression);
+ if (matches == null) {
+ errorCode = "406";
+ } else {
+ if ((nodes[i] != '') && (learner_response[interactiontype].unique)) {
+ for (var j=0; (j<i) && (errorCode=="0"); j++) {
+ if (nodes[i] == nodes[j]) {
+ errorCode = "406";
+ }
+ }
+ }
+ }
+ }
+ }
+ } else if (nodes.length > learner_response[interactiontype].max) {
+ errorCode = "351";
+ diagnostic = "Data Model Element Pattern Too Long";
+ }
+ }
+ break;
+ case 'cmi.interactions.n.correct_responses.n.pattern':
+ subel= subelement.split('.');
+ subel1= 'cmi.interactions.'+subel[2];
+
+ if (typeof eval(subel1+'.type') == "undefined") {
+ errorCode="408";
+ } else {
+ // Use cmi.interactions.n.type value to check the right //dataelement format
+ var interactiontype = eval(subel1+'.type');
+ var interactioncount = eval(parentelement+'._count');
+ // trap duplicate values, which is not allowed for type choice
+ if (interactiontype == 'choice') {
+ for (var i=0; (i < interactioncount) && (errorCode=="0"); i++) {
+ if (eval(parentelement+'.N'+i+'.pattern') == value) {
+ errorCode = "351";
+ }
+ }
+ }
+ var nodes = new Array();
+ if (correct_responses[interactiontype].delimiter != '') {
+ nodes = value.split(correct_responses[interactiontype].delimiter);
+ } else {
+ nodes[0] = value;
+ }
+
+ if ((nodes.length > 0) && (nodes.length <= correct_responses[interactiontype].max)) {
+ errorCode = CRcheckValueNodes (element, interactiontype, nodes, value, errorCode);
+ } else if (nodes.length > correct_responses[interactiontype].max) {
+ errorCode = "351";
+ diagnostic = "Data Model Element Pattern Too Long";
+ }
+ }
+ break;
+ }
+ }
}
}
//Store data
@@ -554,7 +740,7 @@ function SetValue (element,value) {
value = value*1.0;
if (value >= ranges[0]) {
if ((ranges[1] == '*') || (value <= ranges[1])) {
- eval(element+'="'+value+'";');
+ eval(element+'=value;');
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
@@ -570,7 +756,7 @@ function SetValue (element,value) {
errorCode = '407';
}
} else {
- eval(element+'="'+value+'";');
+ eval(element+'=value;');
errorCode = "0";
<?php
if (debugging('',DEBUG_DEVELOPER)) {
@@ -582,11 +768,9 @@ function SetValue (element,value) {
}
}
} else {
- //errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
errorCode = "406";
}
} else {
- //errorCode = eval('datamodel["'+elementmodel+'"].writeerror');
errorCode = "404";
}
} else {
@@ -609,6 +793,120 @@ function SetValue (element,value) {
?>
return "false";
}
+
+
+ function CRremovePrefixes (node) {
+ // check for prefixes lang, case, order
+ // case and then order
+ var seenOrder = false;
+ var seenCase = false;
+ var seenLang = false;
+ var errorCode = "0";
+ while (matches = node.match('^(\{(lang|case_matters|order_matters)=([^\}]+)\})')) {
+ switch (matches[2]) {
+ case 'lang':
+ // check for language prefix on each node
+ langmatches = node.match(CMILangcr);
+ if (langmatches != null) {
+ lang = langmatches[3];
+ // check that language string definition is valid
+ if (lang.length > 0 && lang != undefined) {
+ if (validLanguages[lang.toLowerCase()] == undefined) {
+ errorCode = "406";
+ }
+ }
+ }
+ seenLang = true;
+ break;
+
+ case 'case_matters':
+ // check for correct case answer
+ if (! seenLang && ! seenOrder && ! seenCase) {
+ if (matches[3] != 'true' && matches[3] != 'false') {
+ errorCode = "406";
+ }
+ }
+ seenCase = true;
+ break;
+
+ case 'order_matters':
+ // check for correct case answer
+ if (! seenCase && ! seenLang && ! seenOrder) {
+ if (matches[3] != 'true' && matches[3] != 'false') {
+ errorCode = "406";
+ }
+ }
+ seenOrder = true;
+ break;
+
+ default:
+ break;
+ }
+ node = node.substr(matches[1].length);
+ }
+ return {'errorCode': errorCode, 'node': node};
+ }
+
+
+ function CRcheckValueNodes(element, interactiontype, nodes, value, errorCode) {
+ expression = new RegExp(correct_responses[interactiontype].format);
+ for (var i=0; (i < nodes.length) && (errorCode=="0"); i++) {
+ if (interactiontype.match('^(fill-in|long-fill-in|matching|performance|sequencing)$')) {
+ result = CRremovePrefixes(nodes[i]);
+ errorCode = result.errorCode;
+ nodes[i] = result.node;
+ }
+
+ // check for prefix on each node
+ if (correct_responses[interactiontype].pre != '') {
+ matches = nodes[i].match(correct_responses[interactiontype].pre);
+ if (matches != null) {
+ nodes[i] = nodes[i].substr(matches[1].length);
+ }
+ }
+
+ if (correct_responses[interactiontype].delimiter2 != undefined) {
+ values = nodes[i].split(correct_responses[interactiontype].delimiter2);
+ if (values.length == 2) {
+ matches = values[0].match(expression);
+ if (matches == null) {
+ errorCode = "406";
+ } else {
+ var expression2 = new RegExp(correct_responses[interactiontype].format2);
+ matches = values[1].match(expression2);
+ if (matches == null) {
+ errorCode = "406";
+ }
+ }
+ } else {
+ errorCode = "406";
+ }
+ } else {
+ matches = nodes[i].match(expression);
+ //if ((matches == null) || (matches.join('').length == 0)) {
+ if ((matches == null && value != "")||(matches == null && interactiontype=="true-false")){
+ errorCode = "406";
+ } else {
+ // numeric range - left must be <= right
+ if (interactiontype == 'numeric' && nodes.length > 1) {
+ if (parseFloat(nodes[0]) > parseFloat(nodes[1])) {
+ errorCode = "406";
+ }
+ } else {
+ if ((nodes[i] != '') && (correct_responses[interactiontype].unique)) {
+ for (var j=0; (j < i) && (errorCode=="0"); j++) {
+ if (nodes[i] == nodes[j]) {
+ errorCode = "406";
+ }
+ }
+ }
+ }
+ }
+ }
+ } // end of for each nodes
+ return errorCode;
+ }
+
function Commit (param) {
errorCode = "0";
@@ -766,11 +1064,22 @@ function GetDiagnostic (param) {
return param;
}
- function duplicatedID (element, value) {
+ function duplicatedID (element, parent, value) {
var found = false;
- var elements = eval(element+'._count');
- for (n=0;(n < elements) && (!found);n++) {
- if (eval(element+'.N'+n+'.id') == value) {
+ var elements = eval(parent+'._count');
+ for (var n=0;(n < elements) && (!found);n++) {
+ if ((parent+'.N'+n+'.id' != element) && (eval(parent+'.N'+n+'.id') == value)) {
+ found = true;
+ }
+ }
+ return found;
+ }
+
+ function duplicatedPA (element, parent, value) {
+ var found = false;
+ var elements = eval(parent+'._count');
+ for (var n=0;(n < elements) && (!found);n++) {
+ if ((parent+'.N'+n+'.pattern' != element) && (eval(parent+'.N'+n+'.pattern') == value)) {
found = true;
}
}
@@ -781,12 +1090,13 @@ function getElementModel(element) {
if (typeof datamodel[element] != "undefined") {
return element;
} else {
- expression = new RegExp(CMIIndex,'g');
- elementmodel = String(element).replace(expression,'.n.');
+ var expression = new RegExp(CMIIndex,'g');
+ var elementmodel = String(element).replace(expression,'.n.');
if (typeof datamodel[elementmodel] != "undefined") {
return elementmodel;
}
}
+ return false;
}
function AddTime (first, second) {
@@ -801,17 +1111,17 @@ function AddTime (first, second) {
var secondarray = second.match(matchexpr);
if ((firstarray != null) && (secondarray != null)) {
var secs = parseFloat(firstarray[13],10)+parseFloat(secondarray[13],10); //Seconds
- change = Math.floor(secs / 60);
+ var change = Math.floor(secs / 60);
secs = secs - (change * 60);
- mins = parseInt(firstarray[11],10)+parseInt(secondarray[11],10)+change; //Minutes
+ var mins = parseInt(firstarray[11],10)+parseInt(secondarray[11],10)+change; //Minutes
change = Math.floor(mins / 60);
mins = mins - (change * 60);
- hours = parseInt(firstarray[9],10)+parseInt(secondarray[9],10)+change; //Hours
+ var hours = parseInt(firstarray[9],10)+parseInt(secondarray[9],10)+change; //Hours
change = Math.floor(hours / 24);
hours = hours - (change * 24);
- days = parseInt(firstarray[6],10)+parseInt(secondarray[6],10)+change; // Days
- months = parseInt(firstarray[4],10)+parseInt(secondarray[4],10)
- years = parseInt(firstarray[2],10)+parseInt(secondarray[2],10)
+ var days = parseInt(firstarray[6],10)+parseInt(secondarray[6],10)+change; // Days
+ var months = parseInt(firstarray[4],10)+parseInt(secondarray[4],10)
+ var years = parseInt(firstarray[2],10)+parseInt(secondarray[2],10)
}
if (years > 0) {
timestring += years + 'Y';
@@ -838,8 +1148,8 @@ function AddTime (first, second) {
}
function TotalTime() {
- total_time = AddTime(cmi.total_time, cmi.session_time);
- return '&'+underscore('cmi.total_time')+'='+escape(total_time);
+ var total_time = AddTime(cmi.total_time, cmi.session_time);
+ return '&'+underscore('cmi.total_time')+'='+encodeURIComponent(total_time);
}
function CollectData(data,parent) {
@@ -848,12 +1158,12 @@ function CollectData(data,parent) {
if (typeof data[property] == 'object') {
datastring += CollectData(data[property],parent+'.'+property);
} else {
- element = parent+'.'+property;
- expression = new RegExp(CMIIndexStore,'g');
- elementmodel = String(element).replace(expression,'.n.');
+ var element = parent+'.'+property;
+ var expression = new RegExp(CMIIndexStore,'g');
+ var elementmodel = String(element).replace(expression,'.n.');
if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") {
if (eval('datamodel["'+elementmodel+'"].mod') != 'r') {
- elementstring = '&'+underscore(element)+'='+escape(data[property]);
+ var elementstring = '&'+underscore(element)+'='+encodeURIComponent(data[property]);
if ((typeof eval('datamodel["'+elementmodel+'"].defaultvalue')) != "undefined") {
if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property]) {
datastring += elementstring;
@@ -869,7 +1179,7 @@ function CollectData(data,parent) {
}
function StoreData(data,storetotaltime) {
- datastring = '';
+ var datastring = '';
if (storetotaltime) {
if (cmi.mode == 'normal') {
if (cmi.credit == 'credit') {
@@ -892,8 +1202,8 @@ function StoreData(data,storetotaltime) {
datastring += TotalTime();
}
datastring += CollectData(data,'cmi');
- element = 'adl.nav.request';
- navrequest = eval(element) != datamodel[element].defaultvalue ? '&'+underscore(element)+'='+escape(eval(element)) : '';
+ var element = 'adl.nav.request';
+ var navrequest = eval(element) != datamodel[element].defaultvalue ? '&'+underscore(element)+'='+encodeURIComponent(eval(element)) : '';
datastring += navrequest;
datastring += '&attempt=<?php echo $attempt ?>';
datastring += '&scoid=<?php echo $scoid ?>';
@@ -903,13 +1213,13 @@ function StoreData(data,storetotaltime) {
// }
?>
var myRequest = NewHttpReq();
- result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
+ var result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
<?php
// if (debugging('',DEBUG_DEVELOPER)) {
// echo 'popupwin(result);';
// }
?>
- results = String(result).split('\n');
+ var results = String(result).split('\n');
if ((results.length > 2) && (navrequest != '')) {
eval(results[2]);
}

0 comments on commit 516ca02

Please sign in to comment.
Something went wrong with that request. Please try again.