From: piers Date: Wed, 4 Feb 2009 18:37:18 +0000 (+0000) Subject: MDL-18023 - add type check to check against default to avoid 0 error X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=67859ce61ebc8635d315e2de22420d2c29784e31;p=moodle.git MDL-18023 - add type check to check against default to avoid 0 error --- diff --git a/mod/scorm/datamodels/scorm_12.js.php b/mod/scorm/datamodels/scorm_12.js.php index f7d6c9d256..6b7142f5c5 100644 --- a/mod/scorm/datamodels/scorm_12.js.php +++ b/mod/scorm/datamodels/scorm_12.js.php @@ -539,7 +539,7 @@ function SCORMapi1_2() { if (eval('datamodel["'+elementmodel+'"].mod') != 'r') { elementstring = '&'+underscore(element)+'='+encodeURIComponent(data[property]); if ((typeof eval('datamodel["'+elementmodel+'"].defaultvalue')) != "undefined") { - if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property]) { + if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property] || eval('typeof(datamodel["'+elementmodel+'"].defaultvalue)') != typeof(data[property])) { datastring += elementstring; } } else { diff --git a/mod/scorm/datamodels/scorm_13.js.php b/mod/scorm/datamodels/scorm_13.js.php index 8928b51d9c..3dda7c7886 100644 --- a/mod/scorm/datamodels/scorm_13.js.php +++ b/mod/scorm/datamodels/scorm_13.js.php @@ -57,7 +57,7 @@ function SCORMapi1_3() { '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 = '^[\\u0000-\\uFFFF]{0,200}$$'; + var CMIString200 = '^[\\u0000-\\uFFFF]{0,200}$'; var CMIString250 = '^[\\u0000-\\uFFFF]{0,250}$'; var CMIString1000 = '^[\\u0000-\\uFFFF]{0,1000}$'; var CMIString4000 = '^[\\u0000-\\uFFFF]{0,4000}$'; @@ -1189,7 +1189,7 @@ function SCORMapi1_3() { if (eval('datamodel["'+elementmodel+'"].mod') != 'r') { var elementstring = '&'+underscore(element)+'='+encodeURIComponent(data[property]); if ((typeof eval('datamodel["'+elementmodel+'"].defaultvalue')) != "undefined") { - if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property]) { + if (eval('datamodel["'+elementmodel+'"].defaultvalue') != data[property] || eval('typeof(datamodel["'+elementmodel+'"].defaultvalue)') != typeof(data[property])) { datastring += elementstring; } } else { diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 95e1142325..e96f0614b5 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -423,7 +423,7 @@ function scorm_get_tracks($scoid,$userid,$attempt='') { break; case 'cmi.core.score.raw': case 'cmi.score.raw': - $usertrack->score_raw = $track->value; + $usertrack->score_raw = sprintf('%0d', $track->value); break; case 'cmi.core.session_time': case 'cmi.session_time':