From 5e5b6b7f19d576e3b902c0f0256f45f304aefd66 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 16 May 2005 23:41:58 +0000 Subject: [PATCH] Tabs are out. Please don't use tabs in source code. Set your editor to 4 cc per tab.! --- mod/scorm/api.php | 46 +- mod/scorm/config.html | 8 +- mod/scorm/datamodel.php | 50 +- mod/scorm/datamodels/scorm1_3.js.php | 414 ++-- mod/scorm/db/mysql.php | 132 +- mod/scorm/db/postgres7.php | 126 +- mod/scorm/lib.php | 840 +++---- mod/scorm/loadSCO.php | 106 +- mod/scorm/mod.html | 206 +- mod/scorm/playscorm.php | 90 +- mod/scorm/report.php | 164 +- mod/scorm/request.js | 22 +- mod/scorm/restorelib.php | 2 +- mod/scorm/validate.php | 86 +- mod/scorm/validatordomxml.php | 3150 +++++++++++++------------- mod/scorm/view.php | 156 +- 16 files changed, 2799 insertions(+), 2799 deletions(-) diff --git a/mod/scorm/api.php b/mod/scorm/api.php index 16bcf2b23f0..c7e8467c3ba 100644 --- a/mod/scorm/api.php +++ b/mod/scorm/api.php @@ -36,44 +36,44 @@ require_login($course->id, false, $cm); if ($usertrack=scorm_get_tracks($scoid,$USER->id)) { - $userdata = $usertrack; + $userdata = $usertrack; } else { - $userdata->status = ''; - $userdata->scorre_raw = ''; + $userdata->status = ''; + $userdata->scorre_raw = ''; } $userdata->student_id = $USER->username; $userdata->student_name = $USER->lastname .', '. $USER->firstname; $userdata->mode = 'normal'; if (isset($mode)) { - $userdata->mode = $mode; + $userdata->mode = $mode; } if ($sco = get_record('scorm_scoes','id',$scoid)) { - $userdata->datafromlms = $sco->datafromlms; - $userdata->masteryscore = $sco->masteryscore; - $userdata->maxtimeallowed = $sco->maxtimeallowed; - $userdata->timelimitaction = $sco->timelimitaction; + $userdata->datafromlms = $sco->datafromlms; + $userdata->masteryscore = $sco->masteryscore; + $userdata->maxtimeallowed = $sco->maxtimeallowed; + $userdata->timelimitaction = $sco->timelimitaction; if (!empty($sco->masteryscore)) { - $userdata->credit = 'credit'; - } else { - $userdata->credit = 'no-credit'; - } + $userdata->credit = 'credit'; + } else { + $userdata->credit = 'no-credit'; + } } else { - error('Sco not found'); + error('Sco not found'); } switch ($scorm->version) { - case 'SCORM_1.2': - include_once ('datamodels/scorm1_2.js.php'); - break; - case 'SCORM_1.3': + case 'SCORM_1.2': + include_once ('datamodels/scorm1_2.js.php'); + break; + case 'SCORM_1.3': include_once ('datamodels/scorm1_3.js.php'); - break; - case 'AICC': + break; + case 'AICC': include_once ('datamodels/aicc.js.php'); - break; - default: - include_once ('datamodels/scorm1_2.js.php'); - break; + break; + default: + include_once ('datamodels/scorm1_2.js.php'); + break; } ?> diff --git a/mod/scorm/config.html b/mod/scorm/config.html index 29a9fa3174b..ee860c7a177 100755 --- a/mod/scorm/config.html +++ b/mod/scorm/config.html @@ -1,6 +1,6 @@ scorm_frameheight)) { - $CFG->scorm_frameheight = 600; + $CFG->scorm_frameheight = 600; } if (empty($CFG->scorm_framewidth)) { $CFG->scorm_structurewidth = 800; @@ -33,7 +33,7 @@ scorm_framewidth: - + @@ -42,7 +42,7 @@ scorm_frameheight: - + @@ -50,7 +50,7 @@ - " /> + " /> diff --git a/mod/scorm/datamodel.php b/mod/scorm/datamodel.php index b9c4abb1ca7..1de1652c8c0 100755 --- a/mod/scorm/datamodel.php +++ b/mod/scorm/datamodel.php @@ -33,31 +33,31 @@ require_login($course->id, false, $cm); if (confirm_sesskey() && (isset($SESSION->scorm_scoid))) { - $scoid = $SESSION->scorm_scoid; - $result = true; - foreach ($_GET as $element => $value) { - if (substr($element,0,3) == 'cmi') { - $element = str_replace('__','.',$element); - $element = preg_replace('/_(\d+)/',".\$1",$element); - if ($track = get_record_select('scorm_scoes_track',"userid='$USER->id' AND scormid='$scorm->id' AND scoid='$scoid' AND element='$element'")) { - $track->value = $value; - $result = update_record('scorm_scoes_track',$track) && $result; - } else { - $track->userid = $USER->id; - $track->scormid = $scorm->id; - $track->scoid = $scoid; - $track->element = $element; - $track->value = $value; - $result = insert_record('scorm_scoes_track',$track) && $result; - } - //print_r($track); - } - } - if ($result) { - echo "true\n0"; - } else { - echo "false\n101"; - } + $scoid = $SESSION->scorm_scoid; + $result = true; + foreach ($_GET as $element => $value) { + if (substr($element,0,3) == 'cmi') { + $element = str_replace('__','.',$element); + $element = preg_replace('/_(\d+)/',".\$1",$element); + if ($track = get_record_select('scorm_scoes_track',"userid='$USER->id' AND scormid='$scorm->id' AND scoid='$scoid' AND element='$element'")) { + $track->value = $value; + $result = update_record('scorm_scoes_track',$track) && $result; + } else { + $track->userid = $USER->id; + $track->scormid = $scorm->id; + $track->scoid = $scoid; + $track->element = $element; + $track->value = $value; + $result = insert_record('scorm_scoes_track',$track) && $result; + } + //print_r($track); + } + } + if ($result) { + echo "true\n0"; + } else { + echo "false\n101"; + } } ?> diff --git a/mod/scorm/datamodels/scorm1_3.js.php b/mod/scorm/datamodels/scorm1_3.js.php index a9fc68c1d21..0252c309804 100644 --- a/mod/scorm/datamodels/scorm1_3.js.php +++ b/mod/scorm/datamodels/scorm1_3.js.php @@ -33,80 +33,80 @@ function SCORMapi1_3() { text_range = '-1#1'; // The SCORM 1.3 data model var datamodel = { - 'cmi._children':{'defaultvalue':cmi_children, 'mod':'r', 'writeerror':'402'}, - 'cmi._version':{'defaultvalue':'3.4', 'mod':'r', 'writeerror':'402'}, - 'cmi.core._children':{'defaultvalue':core_children, 'mod':'r', 'writeerror':'402'}, - 'cmi.core.student_id':{'defaultvalue':'username ?>', 'mod':'r', 'writeerror':'403'}, - 'cmi.core.student_name':{'defaultvalue':'lastname.', '.$user->firstname ?>', 'mod':'r', 'writeerror':'403'}, - 'cmi.core.lesson_location':{'format':CMIString255, 'mod':'rw', 'writeerror':'405'}, - 'cmi.core.credit':{'mod':'r', 'writeerror':'403'}, - 'cmi.core.lesson_status':{'format':CMIStatus, 'mod':'rw', 'writeerror':'405'}, - 'cmi.core.entry':{'mod':'r', 'writeerror':'403'}, - 'cmi.core.score._children':{'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'}, - 'cmi.core.score.raw':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.core.score.max':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.core.score.min':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.core.total_time':{'mod':'r', 'writeerror':'403'}, - 'cmi.core.lesson_mode':{'mod':'r', 'writeerror':'405'}, - 'cmi.core.exit':{'format':CMIExit, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.core.session_time':{'format':CMITimespan, 'mod':'w', 'defaultvalue':'00:00:00', 'readerror':'404', 'writeerror':'405'}, - 'cmi.suspend_data':{'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, - 'cmi.launch_data':{'mod':'r', 'writeerror':'403'}, - 'cmi.comments':{'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, - 'cmi.comments_from_lms':{'mod':'r', 'writeerror':'403'}, - 'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r', 'writeerror':'403'}, - 'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, - 'cmi.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'rw', 'writeerror':'405'}, - 'cmi.objectives.n.score._children':{'pattern':CMIIndex, 'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'}, - 'cmi.objectives.n.score.raw':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.objectives.n.score.min':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.objectives.n.score.max':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.objectives.n.status':{'pattern':CMIIndex, 'format':CMIStatus, 'mod':'rw', 'writeerror':'405'}, - 'cmi.student_data._children':{'defaultvalue':student_data_children, 'mod':'r', 'writeerror':'403'}, - 'cmi.student_data.mastery_score':{'mod':'r', 'writeerror':'403'}, - 'cmi.student_data.max_time_allowed':{'mod':'r', 'writeerror':'403'}, - 'cmi.student_data.time_limit_action':{'mod':'r', 'writeerror':'403'}, - 'cmi.student_preference._children':{'defaultvalue':student_preference_children, 'mod':'r', 'writeerror':'403'}, - 'cmi.student_preference.audio':{'format':CMISInteger, 'range':audio_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.student_preference.language':{'format':CMIString255, 'mod':'rw', 'writeerror':'405'}, - 'cmi.student_preference.speed':{'format':CMISInteger, 'range':speed_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.student_preference.text':{'format':CMISInteger, 'range':text_range, 'mod':'rw', 'writeerror':'405'}, - 'cmi.interactions._children':{'defaultvalue':interactions_children, 'mod':'r', 'writeerror':'403'}, - 'cmi.interactions._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, - 'cmi.interactions.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.objectives._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, - 'cmi.interactions.n.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.time':{'pattern':CMIIndex, 'format':CMITime, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.type':{'pattern':CMIIndex, 'format':CMIType, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.correct_responses._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, - 'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.weighting':{'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.student_response':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.result':{'pattern':CMIIndex, 'format':CMIResult, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, - 'cmi.interactions.n.latency':{'pattern':CMIIndex, 'format':CMITimespan, 'mod':'w', 'readerror':'404', 'writeerror':'405'} + 'cmi._children':{'defaultvalue':cmi_children, 'mod':'r', 'writeerror':'402'}, + 'cmi._version':{'defaultvalue':'3.4', 'mod':'r', 'writeerror':'402'}, + 'cmi.core._children':{'defaultvalue':core_children, 'mod':'r', 'writeerror':'402'}, + 'cmi.core.student_id':{'defaultvalue':'username ?>', 'mod':'r', 'writeerror':'403'}, + 'cmi.core.student_name':{'defaultvalue':'lastname.', '.$user->firstname ?>', 'mod':'r', 'writeerror':'403'}, + 'cmi.core.lesson_location':{'format':CMIString255, 'mod':'rw', 'writeerror':'405'}, + 'cmi.core.credit':{'mod':'r', 'writeerror':'403'}, + 'cmi.core.lesson_status':{'format':CMIStatus, 'mod':'rw', 'writeerror':'405'}, + 'cmi.core.entry':{'mod':'r', 'writeerror':'403'}, + 'cmi.core.score._children':{'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'}, + 'cmi.core.score.raw':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.core.score.max':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.core.score.min':{'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.core.total_time':{'mod':'r', 'writeerror':'403'}, + 'cmi.core.lesson_mode':{'mod':'r', 'writeerror':'405'}, + 'cmi.core.exit':{'format':CMIExit, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.core.session_time':{'format':CMITimespan, 'mod':'w', 'defaultvalue':'00:00:00', 'readerror':'404', 'writeerror':'405'}, + 'cmi.suspend_data':{'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, + 'cmi.launch_data':{'mod':'r', 'writeerror':'403'}, + 'cmi.comments':{'format':CMIString4096, 'mod':'rw', 'writeerror':'405'}, + 'cmi.comments_from_lms':{'mod':'r', 'writeerror':'403'}, + 'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r', 'writeerror':'403'}, + 'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, + 'cmi.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'rw', 'writeerror':'405'}, + 'cmi.objectives.n.score._children':{'pattern':CMIIndex, 'defaultvalue':score_children, 'mod':'r', 'writeerror':'402'}, + 'cmi.objectives.n.score.raw':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.objectives.n.score.min':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.objectives.n.score.max':{'pattern':CMIIndex, 'format':CMIDecimal, 'range':score_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.objectives.n.status':{'pattern':CMIIndex, 'format':CMIStatus, 'mod':'rw', 'writeerror':'405'}, + 'cmi.student_data._children':{'defaultvalue':student_data_children, 'mod':'r', 'writeerror':'403'}, + 'cmi.student_data.mastery_score':{'mod':'r', 'writeerror':'403'}, + 'cmi.student_data.max_time_allowed':{'mod':'r', 'writeerror':'403'}, + 'cmi.student_data.time_limit_action':{'mod':'r', 'writeerror':'403'}, + 'cmi.student_preference._children':{'defaultvalue':student_preference_children, 'mod':'r', 'writeerror':'403'}, + 'cmi.student_preference.audio':{'format':CMISInteger, 'range':audio_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.student_preference.language':{'format':CMIString255, 'mod':'rw', 'writeerror':'405'}, + 'cmi.student_preference.speed':{'format':CMISInteger, 'range':speed_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.student_preference.text':{'format':CMISInteger, 'range':text_range, 'mod':'rw', 'writeerror':'405'}, + 'cmi.interactions._children':{'defaultvalue':interactions_children, 'mod':'r', 'writeerror':'403'}, + 'cmi.interactions._count':{'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, + 'cmi.interactions.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.objectives._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, + 'cmi.interactions.n.objectives.n.id':{'pattern':CMIIndex, 'format':CMIIdentifier, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.time':{'pattern':CMIIndex, 'format':CMITime, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.type':{'pattern':CMIIndex, 'format':CMIType, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.correct_responses._count':{'pattern':CMIIndex, 'mod':'r', 'defaultvalue':'0', 'writeerror':'402'}, + 'cmi.interactions.n.correct_responses.n.pattern':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.weighting':{'pattern':CMIIndex, 'format':CMIDecimal, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.student_response':{'pattern':CMIIndex, 'format':CMIFeedback, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.result':{'pattern':CMIIndex, 'format':CMIResult, 'mod':'w', 'readerror':'404', 'writeerror':'405'}, + 'cmi.interactions.n.latency':{'pattern':CMIIndex, 'format':CMITimespan, 'mod':'w', 'readerror':'404', 'writeerror':'405'} }; // // Datamodel inizialization // var cmi = new Object(); - cmi.core = new Object(); - cmi.core.score = new Object(); - cmi.objectives = new Object(); - cmi.student_data = new Object(); - cmi.student_preference = new Object(); - cmi.interactions = new Object(); + cmi.core = new Object(); + cmi.core.score = new Object(); + cmi.objectives = new Object(); + cmi.student_data = new Object(); + cmi.student_preference = new Object(); + cmi.interactions = new Object(); var nav = new Object(); for (element in datamodel) { - if (element.match(/\.n\./) == null) { - //alert (element+' = '+eval('datamodel["'+element+'"].defaultvalue')); - if ((typeof eval('datamodel["'+element+'"].defaultvalue')) != 'undefined') { - eval(element+' = datamodel["'+element+'"].defaultvalue;'); - } else { - eval(element+' = "";'); - } - //alert (element+' = '+eval(element)); - } + if (element.match(/\.n\./) == null) { + //alert (element+' = '+eval('datamodel["'+element+'"].defaultvalue')); + if ((typeof eval('datamodel["'+element+'"].defaultvalue')) != 'undefined') { + eval(element+' = datamodel["'+element+'"].defaultvalue;'); + } else { + eval(element+' = "";'); + } + //alert (element+' = '+eval(element)); + } } // @@ -117,12 +117,12 @@ function SCORMapi1_3() { function Initialize (param) { if (param == "") { if (!Initialized) { - Initialized = true; - errorCode = "0"; - return "true"; + Initialized = true; + errorCode = "0"; + return "true"; } else { - errorCode = "101"; - } + errorCode = "101"; + } } else { errorCode = "201"; } @@ -130,131 +130,131 @@ function SCORMapi1_3() { } function Terminate (param) { - if (param == "") { + if (param == "") { if (Initialized) { - LMSCommit(""); - Initialized = false; - errorCode = "0"; - return "true"; + LMSCommit(""); + Initialized = false; + errorCode = "0"; + return "true"; } else { - errorCode = "301"; + errorCode = "301"; } } else { errorCode = "201"; - } + } } function GetValue (element) { - if (Initialized) { - if (element !="") { - expression = new RegExp(CMIIndex,'g'); - element = element.replace(expression,'.n.'); - if ((typeof eval('datamodel["'+element+'"]')) != "undefined") { - if (eval('datamodel["'+element+'"].mod') != 'w') { - errorCode = "0"; - return eval(element); - } else { - errorCode = eval('datamodel["'+element+'"].readerror'); - } - } else { - errorCode = "401" - } - } else { - errorCode = "201"; - } - } else { + if (Initialized) { + if (element !="") { + expression = new RegExp(CMIIndex,'g'); + element = element.replace(expression,'.n.'); + if ((typeof eval('datamodel["'+element+'"]')) != "undefined") { + if (eval('datamodel["'+element+'"].mod') != 'w') { + errorCode = "0"; + return eval(element); + } else { + errorCode = eval('datamodel["'+element+'"].readerror'); + } + } else { + errorCode = "401" + } + } else { + errorCode = "201"; + } + } else { errorCode = "301"; } - return ""; + return ""; } function SetValue (element,value) { - if (Initialized) { - if (element != "") { - expression = new RegExp(CMIIndex,'g'); - elementmodel = element.replace(expression,'.n.'); - if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") { - if (eval('datamodel["'+elementmodel+'"].mod') != 'r') { - expression.compile(eval('datamodel["'+elementmodel+'"].format')); - value = value+''; - matches = value.match(expression); - if (matches != null) { - //Create dynamic data model element - if (element != elementmodel) { - elementIndexes = element.split('.'); - subelement = 'cmi'; - for (i=1;i < elementIndexes.length-1;i++) { - elementIndex = elementIndexes[i]; - if (elementIndexes[i+1].match(/^\d+$/)) { - //alert(eval(subelement+'.'+elementIndex+'._count')+1.0); - //if (elementIndexes[i+1] > eval(subelement+'.'+elementIndex+'._count')) { - // if (elementIndexes[i+1] == eval(subelement+'.'+elementIndex+'._count')) { - // eval(subelement+'.'+elementIndex+'._count')+1.0; - // } - subelement = subelement.concat('.'+elementIndex+'_'+elementIndexes[i+1]); - i++; - //} - } else { - subelement = subelement.concat('.'+elementIndex); - } - - if ((typeof eval(subelement)) == "undefined") { - eval(subelement+' = new Object();'); - /*if (elementIndexes[i].match(/^\d+$/)) { - alert(subelement.substring(0,subelement.length-elementIndexes[i]-1)); - if ((typeof eval(subelement.substring(0,subelement.length-elementIndexes[i]-1))) == "undefined") { - // create new count - } - } */ - } - } - element = subelement.concat('.'+elementIndexes[elementIndexes.length-1]); - //alert('LMSSetValue: '+element+'\nModel: '+elementmodel+'\nValue: '+value+'\nMatches: '+matches); - } - //Store data - if ((typeof eval('datamodel["'+elementmodel+'"].range')) != "undefined") { - range = eval('datamodel["'+elementmodel+'"].range'); - ranges = range.split('#'); - value = value+0.0; - if ((value >= ranges[0]) && (value <= ranges[1])) { - eval(element+'="'+value+'";'); - errorCode = "0"; - return "true"; - } else { - errorCode = eval('datamodel["'+elementmodel+'"].writeerror'); - } - } else { - eval(element+'="'+value+'";'); - errorCode = "0"; - return "true"; - } - } else { - errorCode = eval('datamodel["'+elementmodel+'"].writeerror'); - } - } else { - errorCode = eval('datamodel["'+elementmodel+'"].writeerror'); - } - } else { - errorCode = "401" - } - } else { - errorCode = "201"; - } - } else { + if (Initialized) { + if (element != "") { + expression = new RegExp(CMIIndex,'g'); + elementmodel = element.replace(expression,'.n.'); + if ((typeof eval('datamodel["'+elementmodel+'"]')) != "undefined") { + if (eval('datamodel["'+elementmodel+'"].mod') != 'r') { + expression.compile(eval('datamodel["'+elementmodel+'"].format')); + value = value+''; + matches = value.match(expression); + if (matches != null) { + //Create dynamic data model element + if (element != elementmodel) { + elementIndexes = element.split('.'); + subelement = 'cmi'; + for (i=1;i < elementIndexes.length-1;i++) { + elementIndex = elementIndexes[i]; + if (elementIndexes[i+1].match(/^\d+$/)) { + //alert(eval(subelement+'.'+elementIndex+'._count')+1.0); + //if (elementIndexes[i+1] > eval(subelement+'.'+elementIndex+'._count')) { + //if (elementIndexes[i+1] == eval(subelement+'.'+elementIndex+'._count')) { + // eval(subelement+'.'+elementIndex+'._count')+1.0; + // } + subelement = subelement.concat('.'+elementIndex+'_'+elementIndexes[i+1]); + i++; + //} + } else { + subelement = subelement.concat('.'+elementIndex); + } + + if ((typeof eval(subelement)) == "undefined") { + eval(subelement+' = new Object();'); + /*if (elementIndexes[i].match(/^\d+$/)) { + alert(subelement.substring(0,subelement.length-elementIndexes[i]-1)); + if ((typeof eval(subelement.substring(0,subelement.length-elementIndexes[i]-1))) == "undefined") { + // create new count + } + } */ + } + } + element = subelement.concat('.'+elementIndexes[elementIndexes.length-1]); + //alert('LMSSetValue: '+element+'\nModel: '+elementmodel+'\nValue: '+value+'\nMatches: '+matches); + } + //Store data + if ((typeof eval('datamodel["'+elementmodel+'"].range')) != "undefined") { + range = eval('datamodel["'+elementmodel+'"].range'); + ranges = range.split('#'); + value = value+0.0; + if ((value >= ranges[0]) && (value <= ranges[1])) { + eval(element+'="'+value+'";'); + errorCode = "0"; + return "true"; + } else { + errorCode = eval('datamodel["'+elementmodel+'"].writeerror'); + } + } else { + eval(element+'="'+value+'";'); + errorCode = "0"; + return "true"; + } + } else { + errorCode = eval('datamodel["'+elementmodel+'"].writeerror'); + } + } else { + errorCode = eval('datamodel["'+elementmodel+'"].writeerror'); + } + } else { + errorCode = "401" + } + } else { + errorCode = "201"; + } + } else { errorCode = "301"; } - alert('LMSSetValue: '+element+'\nValue: '+value+'\nPattern: '+expression+'\nMatches: '+matches+'\nError Code: '+errorCode); - return "false"; + alert('LMSSetValue: '+element+'\nValue: '+value+'\nPattern: '+expression+'\nMatches: '+matches+'\nError Code: '+errorCode); + return "false"; } function Commit (param) { - if (param == "") { + if (param == "") { if (Initialized) { - errorCode = "0"; - return "true"; + errorCode = "0"; + return "true"; } else { - errorCode = "301"; - } + errorCode = "301"; + } } else { errorCode = "201"; } @@ -262,41 +262,41 @@ function SCORMapi1_3() { } function GetLastError () { - return errorCode; + return errorCode; } function GetErrorString (param) { - var errorString = new Array(); - errorString["0"] = "No error"; - errorString["101"] = "General exception"; - errorString["102"] = "General Inizialization Failure"; - errorString["103"] = "Already Initialized"; - errorString["104"] = "Content Instance Terminated"; - errorString["111"] = "General Termination Failure"; - errorString["112"] = "Termination Before Inizialization"; - errorString["113"] = "Termination After Termination"; - errorString["122"] = "Retrieve Data Before Initialization"; - errorString["123"] = "Retrieve Data After Termination"; - errorString["132"] = "Store Data Before Inizialization"; - errorString["133"] = "Store Data After Termination"; - errorString["142"] = "Commit Before Inizialization"; - errorString["143"] = "Commit After Termination"; - errorString["201"] = "General Argument Error"; - errorString["301"] = "General Get Failure"; - errorString["351"] = "General Set Failure"; - errorString["391"] = "General Commit Failure"; - errorString["401"] = "Undefinited Data Model"; - errorString["402"] = "Unimplemented Data Model Element"; - errorString["403"] = "Data Model Element Value Not Initialized"; - errorString["404"] = "Data Model Element Is Read Only"; - errorString["405"] = "Data Model Element Is Write Only"; - errorString["406"] = "Data Model Element Type Mismatch"; - errorString["407"] = "Data Model Element Value Out Of Range"; - errorString["408"] = "Data Model Dependency Not Established"; - return errorString[param]; + var errorString = new Array(); + errorString["0"] = "No error"; + errorString["101"] = "General exception"; + errorString["102"] = "General Inizialization Failure"; + errorString["103"] = "Already Initialized"; + errorString["104"] = "Content Instance Terminated"; + errorString["111"] = "General Termination Failure"; + errorString["112"] = "Termination Before Inizialization"; + errorString["113"] = "Termination After Termination"; + errorString["122"] = "Retrieve Data Before Initialization"; + errorString["123"] = "Retrieve Data After Termination"; + errorString["132"] = "Store Data Before Inizialization"; + errorString["133"] = "Store Data After Termination"; + errorString["142"] = "Commit Before Inizialization"; + errorString["143"] = "Commit After Termination"; + errorString["201"] = "General Argument Error"; + errorString["301"] = "General Get Failure"; + errorString["351"] = "General Set Failure"; + errorString["391"] = "General Commit Failure"; + errorString["401"] = "Undefinited Data Model"; + errorString["402"] = "Unimplemented Data Model Element"; + errorString["403"] = "Data Model Element Value Not Initialized"; + errorString["404"] = "Data Model Element Is Read Only"; + errorString["405"] = "Data Model Element Is Write Only"; + errorString["406"] = "Data Model Element Type Mismatch"; + errorString["407"] = "Data Model Element Value Out Of Range"; + errorString["408"] = "Data Model Dependency Not Established"; + return errorString[param]; } function GetDiagnostic (param) { - return SCORM_Call('GetDiagnostic',param); + return SCORM_Call('GetDiagnostic',param); } this.Initialize = Initialize; @@ -309,4 +309,4 @@ function SCORMapi1_3() { this.GetDiagnostic = GetDiagnostic; } -var API_1484_11 = new SCORMapi1_3(); \ No newline at end of file +var API_1484_11 = new SCORMapi1_3(); diff --git a/mod/scorm/db/mysql.php b/mod/scorm/db/mysql.php index 923c67a58a4..988445187c8 100755 --- a/mod/scorm/db/mysql.php +++ b/mod/scorm/db/mysql.php @@ -23,8 +23,8 @@ function scorm_upgrade($oldversion) { table_column("scorm_scoes", "", "organization", "VARCHAR", "255", "", "", "NOT NULL", "manifest"); } if ($oldversion < 2004071900) { - table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference"); - table_column("scorm", "", "grademethod", "TINYINT", "2", "", "0", "NOT NULL", "maxgrade"); + table_column("scorm", "", "maxgrade", "FLOAT", "3", "", "0", "NOT NULL", "reference"); + table_column("scorm", "", "grademethod", "TINYINT", "2", "", "0", "NOT NULL", "maxgrade"); } if ($oldversion < 2004111200) { @@ -42,57 +42,57 @@ function scorm_upgrade($oldversion) { } if ($oldversion < 2005031300) { - table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title"); - table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites"); - modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction SET('exit,message','exit,no message','continue,message','continue,no message') DEFAULT '' AFTER `maxtimeallowed`"); - table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms"); - - $oldscoes = get_records_select("scorm_scoes","1","id ASC"); - modify_database('',"ALTER TABLE prefix_scorm_scoes CHANGE type scormtype SET('sco','asset') DEFAULT '' NOT NULL"); - if(!empty($oldscoes)) { - foreach ($oldscoes as $sco) { - $sco->scormtype = $sco->type; - unset($sco->type); - update_record("scorm_scoes",$sco); - } - } - - execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track ( - id int(10) unsigned NOT NULL auto_increment, - userid int(10) unsigned NOT NULL default '0', - scormid int(10) NOT NULL default '0', - scoid int(10) unsigned NOT NULL default '0', - element varchar(255) NOT NULL default '', - value longtext NOT NULL default '', - PRIMARY KEY (userid, scormid, scoid, element), - UNIQUE (userid, scormid, scoid, element), - KEY userdata (userid, scormid, scoid), - KEY id (id) - ) TYPE=MyISAM;",false); - - $oldtrackingdata = get_records_select("scorm_sco_users","1","id ASC"); - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); + table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title"); + table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites"); + modify_database('',"ALTER TABLE prefix_scorm_scoes ADD timelimitaction SET('exit,message','exit,no message','continue,message','continue,no message') DEFAULT '' AFTER `maxtimeallowed`"); + table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms"); - if(!empty($oldtrackingdata)) { - foreach ($oldtrackingdata as $oldtrack) { - $newtrack = ''; - $newtrack->userid = $oldtrack->userid; - $newtrack->scormid = $oldtrack->scormid; - $newtrack->scoid = $oldtrack->scoid; - - foreach ( $oldelements as $element) { - $newtrack->element = $element; - $newtrack->value = $oldtrack->$element; - if ($newtrack->value == NULL) { - $newtrack->value = ''; - } - insert_record("scorm_scoes_track",$newtrack,false); - } - } - } + $oldscoes = get_records_select("scorm_scoes","1","id ASC"); + modify_database('',"ALTER TABLE prefix_scorm_scoes CHANGE type scormtype SET('sco','asset') DEFAULT '' NOT NULL"); + if(!empty($oldscoes)) { + foreach ($oldscoes as $sco) { + $sco->scormtype = $sco->type; + unset($sco->type); + update_record("scorm_scoes",$sco); + } + } - modify_database('',"DROP TABLE prefix_scorm_sco_users"); - modify_database('',"INSERT INTO prefix_log_display VALUES ('scorm', 'review', 'resource', 'name')"); + execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track ( + id int(10) unsigned NOT NULL auto_increment, + userid int(10) unsigned NOT NULL default '0', + scormid int(10) NOT NULL default '0', + scoid int(10) unsigned NOT NULL default '0', + element varchar(255) NOT NULL default '', + value longtext NOT NULL default '', + PRIMARY KEY (userid, scormid, scoid, element), + UNIQUE (userid, scormid, scoid, element), + KEY userdata (userid, scormid, scoid), + KEY id (id) + ) TYPE=MyISAM;",false); + + $oldtrackingdata = get_records_select("scorm_sco_users","1","id ASC"); + $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); + + if(!empty($oldtrackingdata)) { + foreach ($oldtrackingdata as $oldtrack) { + $newtrack = ''; + $newtrack->userid = $oldtrack->userid; + $newtrack->scormid = $oldtrack->scormid; + $newtrack->scoid = $oldtrack->scoid; + + foreach ( $oldelements as $element) { + $newtrack->element = $element; + $newtrack->value = $oldtrack->$element; + if ($newtrack->value == NULL) { + $newtrack->value = ''; + } + insert_record("scorm_scoes_track",$newtrack,false); + } + } + } + + modify_database('',"DROP TABLE prefix_scorm_sco_users"); + modify_database('',"INSERT INTO prefix_log_display VALUES ('scorm', 'review', 'resource', 'name')"); } if ($oldversion < 2005040200) { @@ -109,7 +109,7 @@ function scorm_upgrade($oldversion) { execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX userid"); modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD UNIQUE track (userid,scormid,scoid,element);'); modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD PRIMARY KEY id (id);'); - modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scormid (scormid);'); + modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scormid (scormid);'); modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX userid (userid);'); modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX scoid (scoid);'); modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD INDEX element (element);'); @@ -123,9 +123,9 @@ function scorm_upgrade($oldversion) { foreach ($scorms as $scorm) { if (strlen($scorm->datadir) == 14) { $basedir = $CFG->dataroot.'/'.$scorm->course; - $scormdir = '/moddata/scorm'; - rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id); - } + $scormdir = '/moddata/scorm'; + rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id); + } } } execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `datadir`'); // Old field @@ -136,17 +136,17 @@ function scorm_upgrade($oldversion) { } if ($oldversion < 2005042700) { - $trackingdata = get_records_select("scorm_scoes_track","1","id ASC"); - if (!empty($trackingdata)) { - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); - $newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data'); - foreach ($trackingdata as $track) { - if (($pos = array_search($track->element,$oldelements)) !== false) { - $track->element = $newelements[$pos]; - update_record('scorm_scoes_track',$track); - } - } - } + $trackingdata = get_records_select("scorm_scoes_track","1","id ASC"); + if (!empty($trackingdata)) { + $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); + $newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data'); + foreach ($trackingdata as $track) { + if (($pos = array_search($track->element,$oldelements)) !== false) { + $track->element = $newelements[$pos]; + update_record('scorm_scoes_track',$track); + } + } + } } if ($oldversion < 2005042800) { diff --git a/mod/scorm/db/postgres7.php b/mod/scorm/db/postgres7.php index 80a76503226..ffee4f62bf1 100755 --- a/mod/scorm/db/postgres7.php +++ b/mod/scorm/db/postgres7.php @@ -42,57 +42,57 @@ function scorm_upgrade($oldversion) { } if ($oldversion < 2005031300) { - table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title"); - table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites"); - table_column("scorm_scoes", "", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL", "maxtimeallowed"); - table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms"); - - $oldscoes = get_records_select("scorm_scoes",null,"id ASC"); - table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL"); - if(!empty($oldscoes)) { - foreach ($oldscoes as $sco) { - $sco->scormtype = $sco->type; - unset($sco->type); - update_record("scorm_scoes",$sco); - } - } - - execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track ( - id SERIAL, - userid integer NOT NULL default '0', - scormid integer NOT NULL default '0', - scoid integer NOT NULL default '0', - element varchar(255) NOT NULL default '', - value text NOT NULL default '', - PRIMARY KEY (userid, scormid, scoid, element), - UNIQUE (userid, scormid, scoid, element) - );",true); - - modify_database('','CREATE INDEX prefix_scorm_scoes_track_userdata_idx ON prefix_scorm_scoes_track (userid, scormid, scoid);'); - - $oldtracking = get_records_select('scorm_sco_users',null,'id ASC'); - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); + table_column("scorm_scoes", "", "prerequisites", "VARCHAR", "200", "", "", "NOT NULL", "title"); + table_column("scorm_scoes", "", "maxtimeallowed", "VARCHAR", "13", "", "", "NOT NULL", "prerequisites"); + table_column("scorm_scoes", "", "timelimitaction", "VARCHAR", "19", "", "", "NOT NULL", "maxtimeallowed"); + table_column("scorm_scoes", "", "masteryscore", "VARCHAR", "200", "", "", "NOT NULL", "datafromlms"); - if(!empty($oldtrackings)) { - foreach ($oldtrackings as $oldtrack) { - $newtrack = ''; - $newtrack->userid = $oldtrack->userid; - $newtrack->scormid = $oldtrack->scormid; - $newtrack->scoid = $oldtrack->scoid; - - foreach ( $oldelements as $element) { - $newtrack->element = $element; - $newtrack->value = $oldtrack->$element; - if ($newtrack->value == NULL) { - $newtrack->value = ''; - } - insert_record('scorm_scoes_track',$newtrack,false); - } - } - } + $oldscoes = get_records_select("scorm_scoes",null,"id ASC"); + table_column("scorm_scoes", "type", "scormtype", "VARCHAR", "5", "", "", "NOT NULL"); + if(!empty($oldscoes)) { + foreach ($oldscoes as $sco) { + $sco->scormtype = $sco->type; + unset($sco->type); + update_record("scorm_scoes",$sco); + } + } - modify_database('',"DROP TABLE prefix_scorm_sco_users"); - modify_database('',"INSERT INTO prefix_log_display VALUES ('resource', 'review', 'resource', 'name')"); + execute_sql("CREATE TABLE {$CFG->prefix}scorm_scoes_track ( + id SERIAL, + userid integer NOT NULL default '0', + scormid integer NOT NULL default '0', + scoid integer NOT NULL default '0', + element varchar(255) NOT NULL default '', + value text NOT NULL default '', + PRIMARY KEY (userid, scormid, scoid, element), + UNIQUE (userid, scormid, scoid, element) + );",true); + + modify_database('','CREATE INDEX prefix_scorm_scoes_track_userdata_idx ON prefix_scorm_scoes_track (userid, scormid, scoid);'); + + $oldtracking = get_records_select('scorm_sco_users',null,'id ASC'); + $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); + + if(!empty($oldtrackings)) { + foreach ($oldtrackings as $oldtrack) { + $newtrack = ''; + $newtrack->userid = $oldtrack->userid; + $newtrack->scormid = $oldtrack->scormid; + $newtrack->scoid = $oldtrack->scoid; + + foreach ( $oldelements as $element) { + $newtrack->element = $element; + $newtrack->value = $oldtrack->$element; + if ($newtrack->value == NULL) { + $newtrack->value = ''; + } + insert_record('scorm_scoes_track',$newtrack,false); + } + } + } + + modify_database('',"DROP TABLE prefix_scorm_sco_users"); + modify_database('',"INSERT INTO prefix_log_display VALUES ('resource', 'review', 'resource', 'name')"); } if ($oldversion < 2005040200) { @@ -120,9 +120,9 @@ function scorm_upgrade($oldversion) { foreach ($scorms as $scorm) { if (strlen($scorm->datadir) == 14) { $basedir = $CFG->dataroot.'/'.$scorm->course; - $scormdir = '/moddata/scorm'; - rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id); - } + $scormdir = '/moddata/scorm'; + rename($basedir.$scormdir.$scorm->datadir,$basedir.$scormdir.'/'.$scorm->id); + } } } execute_sql('ALTER TABLE '.$CFG->prefix.'scorm DROP datadir'); // Old field @@ -133,17 +133,17 @@ function scorm_upgrade($oldversion) { } if ($oldversion < 2005042700) { - $trackingdata = get_records_select("scorm_scoes_track",null,"id ASC"); - if (!empty($trackingdata)) { - $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); - $newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data'); - foreach ($trackingdata as $track) { - if (($pos = array_search($track->element,$oldelements)) !== false) { - $track->element = $newelements[$pos]; - update_record('scorm_scoes_track',$track); - } - } - } + $trackingdata = get_records_select("scorm_scoes_track",null,"id ASC"); + if (!empty($trackingdata)) { + $oldelements = array ('cmi_core_lesson_location','cmi_core_lesson_status','cmi_core_exit','cmi_core_total_time','cmi_core_score_raw','cmi_suspend_data'); + $newelements = array ('cmi.core.lesson_location','cmi.core.lesson_status','cmi.core.exit','cmi.core.total_time','cmi.core.score.raw','cmi.suspend_data'); + foreach ($trackingdata as $track) { + if (($pos = array_search($track->element,$oldelements)) !== false) { + $track->element = $newelements[$pos]; + update_record('scorm_scoes_track',$track); + } + } + } } if ($oldversion < 2005042800) { diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 34853531cfd..e0abff0bab0 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -8,7 +8,7 @@ define('VALUEHIGHEST', '1'); define('VALUEAVERAGE', '2'); define('VALUESUM', '3'); $SCORM_GRADE_METHOD = array (VALUESCOES => get_string('gradescoes', 'scorm'), - VALUEHIGHEST => get_string('gradehighest', 'scorm'), + VALUEHIGHEST => get_string('gradehighest', 'scorm'), VALUEAVERAGE => get_string('gradeaverage', 'scorm'), VALUESUM => get_string('gradesum', 'scorm')); @@ -54,8 +54,8 @@ function scorm_add_instance($scorm) { // Parse scorm manifest // if ($scorm->launch == 0) { - $scorm->launch = scorm_parse($scormdir.'/'.$id,$scorm->pkgtype,$id); - set_field('scorm','launch',$scorm->launch,'id',$id); + $scorm->launch = scorm_parse($scormdir.'/'.$id,$scorm->pkgtype,$id); + set_field('scorm','launch',$scorm->launch,'id',$id); } return $id; @@ -78,12 +78,12 @@ function scorm_update_instance($scorm) { // Check if scorm manifest needs to be reparsed // if ($scorm->launch == 0) { - $scormdir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm'; - if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id)) { - scorm_delete_files($scormdir.'/'.$scorm->id); - rename($scormdir.$scorm->datadir,$scormdir.'/'.$scorm->id); - } - $scorm->launch = scorm_parse($scormdir.'/'.$scorm->id,$scorm->pkgtype,$scorm->id); + $scormdir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm'; + if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id)) { + scorm_delete_files($scormdir.'/'.$scorm->id); + rename($scormdir.$scorm->datadir,$scormdir.'/'.$scorm->id); + } + $scorm->launch = scorm_parse($scormdir.'/'.$scorm->id,$scorm->pkgtype,$scorm->id); } return update_record('scorm', $scorm); @@ -167,56 +167,56 @@ function scorm_grades($scormid) { return NULL; } if (!$scoes = get_records('scorm_scoes','scorm',$scormid)) { - return NULL; + return NULL; } if ($scorm->grademethod == VALUESCOES) { - if (!$return->maxgrade = count_records_select('scorm_scoes',"scorm='$scormid' AND launch<>''")) { + if (!$return->maxgrade = count_records_select('scorm_scoes',"scorm='$scormid' AND launch<>''")) { return NULL; - } + } } else { - $return->maxgrade = $scorm->maxgrade; + $return->maxgrade = $scorm->maxgrade; } $return->grades = NULL; if ($scousers=get_records_select('scorm_scoes_track', "scormid='$scormid' GROUP BY userid", "", "userid,null")) { foreach ($scousers as $scouser) { - $scores = NULL; + $scores = NULL; $scores->scoes = 0; - $scores->values = 0; - $scores->max = 0; - $scores->sum = 0; - - foreach ($scoes as $sco) { - $userdata=scorm_get_tracks($sco->id, $scouser->userid); - if (($userdata->status == 'completed') || ($userdata->status == 'passed')) { - $scores->scoes++; - } - if (!empty($userdata->score_raw)) { - $scores->values++; - $scores->sum += $userdata->score_raw; - $scores->max = ($userdata->score_raw > $scores->max)?$userdata->score_raw:$scores->max; - } + $scores->values = 0; + $scores->max = 0; + $scores->sum = 0; + + foreach ($scoes as $sco) { + $userdata=scorm_get_tracks($sco->id, $scouser->userid); + if (($userdata->status == 'completed') || ($userdata->status == 'passed')) { + $scores->scoes++; + } + if (!empty($userdata->score_raw)) { + $scores->values++; + $scores->sum += $userdata->score_raw; + $scores->max = ($userdata->score_raw > $scores->max)?$userdata->score_raw:$scores->max; + } } - switch ($scorm->grademethod) { - case VALUEHIGHEST: - $return->grades[$scouser->userid] = $scores->max; - break; - case VALUEAVERAGE: - if ($score->values > 0) { - $return->grades[$scouser->userid] = $scores->sum/$scores->values; - } else { - $return->grades[$scouser->userid] = 0; - } - break; - case VALUESUM: - $return->grades[$scouser->userid] = $scores->sum; - break; - case VALUESCOES: - $return->grades[$scouser->userid] = $scores->scoes; - break; - } - } + switch ($scorm->grademethod) { + case VALUEHIGHEST: + $return->grades[$scouser->userid] = $scores->max; + break; + case VALUEAVERAGE: + if ($score->values > 0) { + $return->grades[$scouser->userid] = $scores->sum/$scores->values; + } else { + $return->grades[$scouser->userid] = 0; + } + break; + case VALUESUM: + $return->grades[$scouser->userid] = $scores->sum; + break; + case VALUESCOES: + $return->grades[$scouser->userid] = $scores->scoes; + break; + } + } } return $return; } @@ -267,23 +267,23 @@ function scorm_validate($packagedir) { if (is_file($packagedir.'/imsmanifest.xml')) { $validation->result = 'found'; - $validation->pkgtype = 'SCORM'; + $validation->pkgtype = 'SCORM'; } else { - if ($handle = opendir($packagedir)) { - while (($file = readdir($handle)) !== false) { - $ext = substr($file,strrpos($file,'.')); - if (strtolower($ext) == '.cst') { - $validation->result = 'found'; - $validation->pkgtype = 'AICC'; - break; - } - } - closedir($handle); - } - if (!isset($validation)) { + if ($handle = opendir($packagedir)) { + while (($file = readdir($handle)) !== false) { + $ext = substr($file,strrpos($file,'.')); + if (strtolower($ext) == '.cst') { + $validation->result = 'found'; + $validation->pkgtype = 'AICC'; + break; + } + } + closedir($handle); + } + if (!isset($validation)) { $validation->result = 'nomanifest'; - $validation->pkgtype = 'SCORM'; - } + $validation->pkgtype = 'SCORM'; + } } return $validation; } @@ -294,12 +294,12 @@ function scorm_delete_files($directory) { //print_r($files); foreach($files as $file) { if (($file != '.') && ($file != '..')) { - if (!is_dir($directory.'/'.$file)) { - //chmod($directory.'/'.$file,0777); + if (!is_dir($directory.'/'.$file)) { + //chmod($directory.'/'.$file,0777); unlink($directory.'/'.$file); - } else { - scorm_delete_files($directory.'/'.$file); - } + } else { + scorm_delete_files($directory.'/'.$file); + } } } rmdir($directory); @@ -308,16 +308,16 @@ function scorm_delete_files($directory) { function scorm_scandir($directory) { if (version_compare(phpversion(),'5.0.0','>=')) { - return scandir($directory); + return scandir($directory); } else { $files = null; - if ($dh = opendir($directory)) { - while (($file = readdir($dh)) !== false) { - $files[] = $file; - } - closedir($dh); - } - return $files; + if ($dh = opendir($directory)) { + while (($file = readdir($dh)) !== false) { + $files[] = $file; + } + closedir($dh); + } + return $files; } } @@ -364,16 +364,16 @@ function scorm_startElement($parser, $name, $attrs) { $scoes[$i]['parent'] = $parent[$level]; $level++; $parent[$level] = $attrs['IDENTIFIER']; - $organization = $attrs['IDENTIFIER']; + $organization = $attrs['IDENTIFIER']; break; case 'MANIFEST': - $manifest = $attrs['IDENTIFIER']; + $manifest = $attrs['IDENTIFIER']; break; case 'ORGANIZATIONS': - if (!isset($attrs['DEFAULT'])) { - $attrs['DEFAULT'] = ''; - } - $defaultorg = $attrs['DEFAULT']; + if (!isset($attrs['DEFAULT'])) { + $attrs['DEFAULT'] = ''; + } + $defaultorg = $attrs['DEFAULT']; break; } } @@ -391,32 +391,32 @@ function scorm_endElement($parser, $name) { $scoes[$i][$datacontent] = 1; } if ($name == 'ADLCP:DATAFROMLMS') { - $scoes[$i]['datafromlms'] = $datacontent; + $scoes[$i]['datafromlms'] = $datacontent; } if ($name == 'ADLCP:PREREQUISITES') { - $scoes[$i]['prerequisites'] = $datacontent; + $scoes[$i]['prerequisites'] = $datacontent; } if ($name == 'ADLCP:MAXTIMEALLOWED') { - $scoes[$i]['maxtimeallowed'] = $datacontent; + $scoes[$i]['maxtimeallowed'] = $datacontent; } if ($name == 'ADLCP:TIMELIMITACTION') { - $scoes[$i]['timelimitaction'] = $datacontent; + $scoes[$i]['timelimitaction'] = $datacontent; } if ($name == 'ADLCP:MASTERYSCORE') { - $scoes[$i]['masteryscore'] = $datacontent; + $scoes[$i]['masteryscore'] = $datacontent; } if ($name == 'ORGANIZATION') { - $organization = ''; - $level--; + $organization = ''; + $level--; } if ($name == 'MANIFEST') { - $manifest = ''; + $manifest = ''; } if ($name == 'SCHEMAVERSION') { - if (preg_match("/(\d+)\.(\d+)$/",$datacontent,$matches)) { - $version = 'SCORM_'.$matches[1].'.'.$matches[2]; - } - //$version = $datacontent; + if (preg_match("/(\d+)\.(\d+)$/",$datacontent,$matches)) { + $version = 'SCORM_'.$matches[1].'.'.$matches[2]; + } + //$version = $datacontent; } } @@ -427,9 +427,9 @@ function scorm_characterData($parser, $data) { function scorm_parse($pkgdir,$pkgtype,$scormid){ if ($pkgtype == 'AICC') { - return scorm_parse_aicc($pkgdir,$scormid); + return scorm_parse_aicc($pkgdir,$scormid); } else { - return scorm_parse_scorm($pkgdir,'/imsmanifest.xml',$scormid); + return scorm_parse_scorm($pkgdir,'/imsmanifest.xml',$scormid); } } @@ -438,14 +438,14 @@ function scorm_get_aicc_columns($row,$mastername='system_id') { $result->columns = array(); $i=0; while ($tok) { - if ($tok !='') { - $result->columns[] = $tok; - if ($tok == $mastername) { - $result->mastercol = $i; - } - $i++; - } - $tok = strtok("\",\n\r"); + if ($tok !='') { + $result->columns[] = $tok; + if ($tok == $mastername) { + $result->mastercol = $i; + } + $i++; + } + $tok = strtok("\",\n\r"); } return $result; } @@ -453,7 +453,7 @@ function scorm_get_aicc_columns($row,$mastername='system_id') { function scorm_forge_cols_regexp($columns,$remodule='(".*")?,') { $regexp = '/^'; foreach ($columns as $column) { - $regexp .= $remodule; + $regexp .= $remodule; } $regexp = substr($regexp,0,-1) . '/'; return $regexp; @@ -464,160 +464,160 @@ function scorm_parse_aicc($pkgdir,$scormid){ $ids = array(); $courses = array(); if ($handle = opendir($pkgdir)) { - while (($file = readdir($handle)) !== false) { - $ext = substr($file,strrpos($file,'.')); - $extension = strtolower(substr($ext,1)); - $id = strtolower(basename($file,$ext)); - $ids[$id]->$extension = $file; - } - closedir($handle); + while (($file = readdir($handle)) !== false) { + $ext = substr($file,strrpos($file,'.')); + $extension = strtolower(substr($ext,1)); + $id = strtolower(basename($file,$ext)); + $ids[$id]->$extension = $file; + } + closedir($handle); } foreach ($ids as $courseid => $id) { - if (isset($id->crs)) { - if (is_file($pkgdir.'/'.$id->crs)) { - $rows = file($pkgdir.'/'.$id->crs); - foreach ($rows as $row) { - if (preg_match("/^(.+)=(.+)$/",$row,$matches)) { - switch (strtolower(trim($matches[1]))) { - case 'course_id': - $courses[$courseid]->id = trim($matches[2]); - break; - case 'course_title': - $courses[$courseid]->title = trim($matches[2]); - break; - case 'version': - $courses[$courseid]->version = 'AICC_'.trim($matches[2]); - break; - } - } - } - } - } - if (isset($id->des)) { - $rows = file($pkgdir.'/'.$id->des); - $columns = scorm_get_aicc_columns($rows[0]); - $regexp = scorm_forge_cols_regexp($columns->columns); - for ($i=1;$icolumns);$j++) { - $column = $columns->columns[$j]; - $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1); - } - } - } - } - if (isset($id->au)) { - $rows = file($pkgdir.'/'.$id->au); - $columns = scorm_get_aicc_columns($rows[0]); - $regexp = scorm_forge_cols_regexp($columns->columns); - for ($i=1;$icolumns);$j++) { - $column = $columns->columns[$j]; - $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1); - } - } - } - } - if (isset($id->cst)) { - $rows = file($pkgdir.'/'.$id->cst); - $columns = scorm_get_aicc_columns($rows[0],'block'); - $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,'); - for ($i=1;$icolumns);$j++) { - if ($j != $columns->mastercol) { - $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1); - } - } - } - } - } - if (isset($id->ort)) { - $rows = file($pkgdir.'/'.$id->ort); - } - if (isset($id->pre)) { - $rows = file($pkgdir.'/'.$id->pre); - $columns = scorm_get_aicc_columns($rows[0],'structure_element'); - $regexp = scorm_forge_cols_regexp($columns->columns,'(.+),'); - for ($i=1;$ielements[$columns->mastercol+1]->prerequisites = substr(trim($matches[1-$columns->mastercol+1]),1,-1); - } - } - } - if (isset($id->cmp)) { - $rows = file($pkgdir.'/'.$id->cmp); - } + if (isset($id->crs)) { + if (is_file($pkgdir.'/'.$id->crs)) { + $rows = file($pkgdir.'/'.$id->crs); + foreach ($rows as $row) { + if (preg_match("/^(.+)=(.+)$/",$row,$matches)) { + switch (strtolower(trim($matches[1]))) { + case 'course_id': + $courses[$courseid]->id = trim($matches[2]); + break; + case 'course_title': + $courses[$courseid]->title = trim($matches[2]); + break; + case 'version': + $courses[$courseid]->version = 'AICC_'.trim($matches[2]); + break; + } + } + } + } + } + if (isset($id->des)) { + $rows = file($pkgdir.'/'.$id->des); + $columns = scorm_get_aicc_columns($rows[0]); + $regexp = scorm_forge_cols_regexp($columns->columns); + for ($i=1;$icolumns);$j++) { + $column = $columns->columns[$j]; + $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1); + } + } + } + } + if (isset($id->au)) { + $rows = file($pkgdir.'/'.$id->au); + $columns = scorm_get_aicc_columns($rows[0]); + $regexp = scorm_forge_cols_regexp($columns->columns); + for ($i=1;$icolumns);$j++) { + $column = $columns->columns[$j]; + $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1); + } + } + } + } + if (isset($id->cst)) { + $rows = file($pkgdir.'/'.$id->cst); + $columns = scorm_get_aicc_columns($rows[0],'block'); + $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,'); + for ($i=1;$icolumns);$j++) { + if ($j != $columns->mastercol) { + $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1); + } + } + } + } + } + if (isset($id->ort)) { + $rows = file($pkgdir.'/'.$id->ort); + } + if (isset($id->pre)) { + $rows = file($pkgdir.'/'.$id->pre); + $columns = scorm_get_aicc_columns($rows[0],'structure_element'); + $regexp = scorm_forge_cols_regexp($columns->columns,'(.+),'); + for ($i=1;$ielements[$columns->mastercol+1]->prerequisites = substr(trim($matches[1-$columns->mastercol+1]),1,-1); + } + } + } + if (isset($id->cmp)) { + $rows = file($pkgdir.'/'.$id->cmp); + } } //print_r($courses); $launch = 0; if (isset($courses)) { - - foreach ($courses as $course) { - unset($sco); - $sco->identifier = $course->id; - $sco->scorm = $scormid; - $sco->organization = ''; - $sco->title = $course->title; - $sco->parent = '/'; - $sco->launch = ''; - $sco->scormtype = ''; - //print_r($sco); - $id = insert_record('scorm_scoes',$sco); - if ($launch == 0) { - $launch = $id; + + foreach ($courses as $course) { + unset($sco); + $sco->identifier = $course->id; + $sco->scorm = $scormid; + $sco->organization = ''; + $sco->title = $course->title; + $sco->parent = '/'; + $sco->launch = ''; + $sco->scormtype = ''; + //print_r($sco); + $id = insert_record('scorm_scoes',$sco); + if ($launch == 0) { + $launch = $id; } - if (isset($course->elements)) { - foreach($course->elements as $element) { - unset($sco); - $sco->identifier = $element->system_id; - $sco->scorm = $scormid; - $sco->organization = $course->id; - $sco->title = $element->title; - if (strtolower($element->parent) == 'root') { - $sco->parent = '/'; - } else { - $sco->parent = $element->parent; - } - if (isset($element->file_name)) { - $sco->launch = $element->file_name; - $sco->scormtype = 'sco'; - } else { - $element->file_name = ''; - $sco->scormtype = ''; - } - if (!isset($element->prerequisites)) { - $element->prerequisites = ''; - } - $sco->prerequisites = $element->prerequisites; - if (!isset($element->max_time_allowed)) { - $element->max_time_allowed = ''; - } - $sco->maxtimeallowed = $element->max_time_allowed; - if (!isset($element->time_limit_action)) { - $element->time_limit_action = ''; - } - $sco->timelimitaction = $element->time_limit_action; - if (!isset($element->mastery_score)) { - $element->mastery_score = ''; - } - $sco->masteryscore = $element->mastery_score; - $sco->previous = 0; - $sco->next = 0; - - //print_r($sco); - $id = insert_record('scorm_scoes',$sco); + if (isset($course->elements)) { + foreach($course->elements as $element) { + unset($sco); + $sco->identifier = $element->system_id; + $sco->scorm = $scormid; + $sco->organization = $course->id; + $sco->title = $element->title; + if (strtolower($element->parent) == 'root') { + $sco->parent = '/'; + } else { + $sco->parent = $element->parent; + } + if (isset($element->file_name)) { + $sco->launch = $element->file_name; + $sco->scormtype = 'sco'; + } else { + $element->file_name = ''; + $sco->scormtype = ''; + } + if (!isset($element->prerequisites)) { + $element->prerequisites = ''; + } + $sco->prerequisites = $element->prerequisites; + if (!isset($element->max_time_allowed)) { + $element->max_time_allowed = ''; + } + $sco->maxtimeallowed = $element->max_time_allowed; + if (!isset($element->time_limit_action)) { + $element->time_limit_action = ''; + } + $sco->timelimitaction = $element->time_limit_action; + if (!isset($element->mastery_score)) { + $element->mastery_score = ''; + } + $sco->masteryscore = $element->mastery_score; + $sco->previous = 0; + $sco->next = 0; + + //print_r($sco); + $id = insert_record('scorm_scoes',$sco); - if ($launch==0) { - $launch = $id; - } - } - } - } + if ($launch==0) { + $launch = $id; + } + } + } + } } if (isset($courses[0]->version)) { - $version = $courses[0]->version; + $version = $courses[0]->version; } set_field('scorm','version',$version,'id',$scormid); return $launch; @@ -660,80 +660,80 @@ function scorm_parse_scorm($pkgdir,$file,$scormid) { delete_records('scorm_scoes_track','scormid',$scormid); if (isset($scoes[1])) { - for ($j=1; $j<=$i; $j++) { + for ($j=1; $j<=$i; $j++) { $sco->identifier = $scoes[$j]['identifier']; $sco->parent = $scoes[$j]['parent']; $sco->title = $scoes[$j]['title']; $sco->manifest = $scoes[$j]['manifest']; $sco->organization = $scoes[$j]['organization']; if (!isset($scoes[$j]['datafromlms'])) { - $scoes[$j]['datafromlms'] = ''; + $scoes[$j]['datafromlms'] = ''; } $sco->datafromlms = $scoes[$j]['datafromlms']; if (!isset($scoes[$j]['prerequisites'])) { - $scoes[$j]['prerequisites'] = ''; + $scoes[$j]['prerequisites'] = ''; } $sco->prerequisites = $scoes[$j]['prerequisites']; if (!isset($scoes[$j]['maxtimeallowed'])) { - $scoes[$j]['maxtimeallowed'] = ''; + $scoes[$j]['maxtimeallowed'] = ''; } $sco->maxtimeallowed = $scoes[$j]['maxtimeallowed']; if (!isset($scoes[$j]['timelimitaction'])) { - $scoes[$j]['timelimitaction'] = ''; + $scoes[$j]['timelimitaction'] = ''; } $sco->timelimitaction = $scoes[$j]['timelimitaction']; if (!isset($scoes[$j]['masteryscore'])) { - $scoes[$j]['masteryscore'] = ''; + $scoes[$j]['masteryscore'] = ''; } $sco->masteryscore = $scoes[$j]['masteryscore']; if (!isset($resources[($scoes[$j]['identifierref'])]['href'])) { - $resources[($scoes[$j]['identifierref'])]['href'] = ''; + $resources[($scoes[$j]['identifierref'])]['href'] = ''; } $sco->launch = $resources[($scoes[$j]['identifierref'])]['href']; if (!isset($scoes[$j]['parameters'])) { - $scoes[$j]['parameters'] = ''; + $scoes[$j]['parameters'] = ''; } $sco->parameters = $scoes[$j]['parameters']; if (!isset($resources[($scoes[$j]['identifierref'])]['scormtype'])) { - $resources[($scoes[$j]['identifierref'])]['scormtype'] = ''; + $resources[($scoes[$j]['identifierref'])]['scormtype'] = ''; } - $sco->scormtype = $resources[($scoes[$j]['identifierref'])]['scormtype']; - - if (!isset($scoes[$j]['previous'])) { - $scoes[$j]['previous'] = 0; + $sco->scormtype = $resources[($scoes[$j]['identifierref'])]['scormtype']; + + if (!isset($scoes[$j]['previous'])) { + $scoes[$j]['previous'] = 0; } - $sco->previous = $scoes[$j]['previous']; - - if (!isset($scoes[$j]['continue'])) { - $scoes[$j]['continue'] = 0; + $sco->previous = $scoes[$j]['previous']; + + if (!isset($scoes[$j]['continue'])) { + $scoes[$j]['continue'] = 0; } - $sco->next = $scoes[$j]['continue']; - - if (scorm_remove_spaces($scoes[$j]['isvisible']) != 'false') { - $id = insert_record('scorm_scoes',$sco); + $sco->next = $scoes[$j]['continue']; + + if (scorm_remove_spaces($scoes[$j]['isvisible']) != 'false') { + $id = insert_record('scorm_scoes',$sco); } - if (($launch==0) && ($defaultorg==$sco->identifier)) { - $launch = $id; + if (($launch==0) && ($defaultorg==$sco->identifier)) { + $launch = $id; } - } + } } else { - foreach ($resources as $label => $resource) { - if (!empty($resource['href'])) { - $sco->identifier = $label; - $sco->title = $label; - $sco->parent = '/'; - $sco->launch = $resource['href']; - $sco->scormtype = $resource['type']; - $id = insert_record('scorm_scoes',$sco); - - if ($launch == 0) { - $launch = $id; - } + foreach ($resources as $label => $resource) { + if (!empty($resource['href'])) { + $sco->identifier = $label; + $sco->title = $label; + $sco->parent = '/'; + $sco->launch = $resource['href']; + $sco->scormtype = $resource['type']; + $id = insert_record('scorm_scoes',$sco); + + if ($launch == 0) { + $launch = $id; + } } - } + } } set_field('scorm','version',$version,'id',$scormid); return $launch; @@ -744,43 +744,43 @@ function scorm_get_tracks($scoid,$userid) { global $CFG; if ($tracks = get_records_select('scorm_scoes_track',"userid=$userid AND scoid=$scoid",'element ASC')) { - //print_r($tracks); - $usertrack->userid = $userid; - $usertrack->scoid = $scoid; - $usertrack->score_raw = ''; - $usertrack->status = ''; - $usertrack->total_time = '00:00:00'; - $usertrack->session_time = '00:00:00'; - foreach ($tracks as $track) { - //$element = str_replace('.','_',$track->element); - $element = $track->element; - $usertrack->{$element} = $track->value; - switch ($element) { - case 'cmi.core.lesson_status': - case 'cmi.completition_status': - if ($track->value == 'not attempted') { - $track->value = 'notattempted'; - } - $usertrack->status = $track->value; - break; - case 'cmi.core.score.raw': - case 'cmi.score.raw': - $usertrack->score_raw = $track->value; - break; - case 'cmi.core.session_time': - case 'cmi.session_time': - $usertrack->session_time = $track->value; - break; - case 'cmi.core.total_time': - case 'cmi.total_time': - $usertrack->total_time = $track->value; - break; - } - } - //print_r($usertrack); - return $usertrack; + //print_r($tracks); + $usertrack->userid = $userid; + $usertrack->scoid = $scoid; + $usertrack->score_raw = ''; + $usertrack->status = ''; + $usertrack->total_time = '00:00:00'; + $usertrack->session_time = '00:00:00'; + foreach ($tracks as $track) { + //$element = str_replace('.','_',$track->element); + $element = $track->element; + $usertrack->{$element} = $track->value; + switch ($element) { + case 'cmi.core.lesson_status': + case 'cmi.completition_status': + if ($track->value == 'not attempted') { + $track->value = 'notattempted'; + } + $usertrack->status = $track->value; + break; + case 'cmi.core.score.raw': + case 'cmi.score.raw': + $usertrack->score_raw = $track->value; + break; + case 'cmi.core.session_time': + case 'cmi.session_time': + $usertrack->session_time = $track->value; + break; + case 'cmi.core.total_time': + case 'cmi.total_time': + $usertrack->total_time = $track->value; + break; + } + } + //print_r($usertrack); + return $usertrack; } else { - return false; + return false; } } @@ -830,120 +830,120 @@ function scorm_display_structure($scorm,$liststyle,$currentorg='',$scoid='',$mod global $USER; $strexpand = get_string('expcoll','scorm'); - + echo "
    "; $incomplete = false; $organizationsql = ''; if (empty($currentorg)) { - // + // } else { - $organizationsql = "AND organization='$currentorg'"; + $organizationsql = "AND organization='$currentorg'"; } if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){ - $level=0; - $sublist=1; - $previd = 0; - $nextid = 0; - $parents[$level]='/'; - foreach ($scoes as $sco) { - if ($parents[$level]!=$sco->parent) { - if ($level>0 && $parents[$level-1]==$sco->parent) { - echo "\t\t
\n"; - $level--; - } else { - $i = $level; - $closelist = ''; - while (($i > 0) && ($parents[$level] != $sco->parent)) { - $closelist .= "\t\t\n"; - $i--; - } - if (($i == 0) && ($sco->parent != $currentorg)) { - echo "\t\t
    • \n"; - $level++; - } else { - echo $closelist; - $level = $i; - } - $parents[$level]=$sco->parent; - } - } - echo "\t\t
    • "; - $nextsco = next($scoes); - if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) { - $sublist++; - echo ''.$strexpand.''; - } else { - echo ''; - } - - if ($sco->launch) { - $startbold = ''; - $endbold = ''; - $score = ''; - if (empty($scoid) && ($mode != 'normal')) { - $scoid = $sco->id; - } - if ($usertrack=scorm_get_tracks($sco->id,$USER->id)) { - if ( $usertrack->status == '') { - $usertrack->status = 'notattempted'; - } - $strstatus = get_string($usertrack->status,'scorm'); - echo "$strstatus"; - if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) { - $incomplete = true; - if ($play && empty($scoid)) { - $scoid = $sco->id; - } - } - if ($usertrack->score_raw != '') { - $score = '('.get_string('score','scorm').': '.$usertrack->score_raw.')'; - } - } else { - if ($play && empty($scoid)) { - $scoid = $sco->id; - } - if ($sco->scormtype == 'sco') { - echo ''.get_string('notattempted','scorm').''; - $incomplete = true; - } else { - echo ''.get_string('asset','scorm').''; - } - } + $level=0; + $sublist=1; + $previd = 0; + $nextid = 0; + $parents[$level]='/'; + foreach ($scoes as $sco) { + if ($parents[$level]!=$sco->parent) { + if ($level>0 && $parents[$level-1]==$sco->parent) { + echo "\t\t
  • \n"; + $level--; + } else { + $i = $level; + $closelist = ''; + while (($i > 0) && ($parents[$level] != $sco->parent)) { + $closelist .= "\t\t\n"; + $i--; + } + if (($i == 0) && ($sco->parent != $currentorg)) { + echo "\t\t
    • \n"; + $level++; + } else { + echo $closelist; + $level = $i; + } + $parents[$level]=$sco->parent; + } + } + echo "\t\t
    • "; + $nextsco = next($scoes); + if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) { + $sublist++; + echo ''.$strexpand.''; + } else { + echo ''; + } + + if ($sco->launch) { + $startbold = ''; + $endbold = ''; + $score = ''; + if (empty($scoid) && ($mode != 'normal')) { + $scoid = $sco->id; + } + if ($usertrack=scorm_get_tracks($sco->id,$USER->id)) { + if ( $usertrack->status == '') { + $usertrack->status = 'notattempted'; + } + $strstatus = get_string($usertrack->status,'scorm'); + echo "$strstatus"; + if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) { + $incomplete = true; + if ($play && empty($scoid)) { + $scoid = $sco->id; + } + } + if ($usertrack->score_raw != '') { + $score = '('.get_string('score','scorm').': '.$usertrack->score_raw.')'; + } + } else { + if ($play && empty($scoid)) { + $scoid = $sco->id; + } + if ($sco->scormtype == 'sco') { + echo ''.get_string('notattempted','scorm').''; + $incomplete = true; + } else { + echo ''.get_string('asset','scorm').''; + } + } - if ($sco->id == $scoid) { - $startbold = ''; - $endbold = ''; - if ($nextsco !== false) { - $nextid = $nextsco->id; - } else { - $nextid = 0; - } - $shownext = $sco->next; - $showprev = $sco->previous; - } - if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1)) { - $previd = $sco->id; - } - - echo " $startbold$sco->title $score$endbold
    • \n"; - } else { - echo " $sco->title\n"; - } - } - for ($i=0;$i<$level;$i++) { - echo "\t\t
  • \n"; - } + if ($sco->id == $scoid) { + $startbold = ''; + $endbold = ''; + if ($nextsco !== false) { + $nextid = $nextsco->id; + } else { + $nextid = 0; + } + $shownext = $sco->next; + $showprev = $sco->previous; + } + if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1)) { + $previd = $sco->id; + } + + echo " $startbold$sco->title $score$endbold\n"; + } else { + echo " $sco->title\n"; + } + } + for ($i=0;$i<$level;$i++) { + echo "\t\t\n"; + } } echo "\t\n"; if ($play) { $result->id = $scoid; $result->prev = $previd; $result->next = $nextid; - $result->showprev = $showprev; - $result->shownext = $shownext; - return $result; + $result->showprev = $showprev; + $result->shownext = $shownext; + return $result; } else { - return $incomplete; + return $incomplete; } } ?> diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php index 21696da39cb..43d0b973560 100755 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -8,28 +8,28 @@ optional_variable($mode); // lesson mode if ($id) { - if (! $cm = get_record("course_modules", "id", $id)) { - error("Course Module ID was incorrect"); - } + if (! $cm = get_record("course_modules", "id", $id)) { + error("Course Module ID was incorrect"); + } - if (! $course = get_record("course", "id", $cm->course)) { - error("Course is misconfigured"); - } + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } - if (! $scorm = get_record("scorm", "id", $cm->instance)) { - error("Course module is incorrect"); - } + if (! $scorm = get_record("scorm", "id", $cm->instance)) { + error("Course module is incorrect"); + } } else { - if (! $scorm = get_record("scorm", "id", $a)) { - error("Course module is incorrect"); - } - if (! $course = get_record("course", "id", $scorm->course)) { - error("Course is misconfigured"); - } - if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { - error("Course Module ID was incorrect"); - } + if (! $scorm = get_record("scorm", "id", $a)) { + error("Course module is incorrect"); + } + if (! $course = get_record("course", "id", $scorm->course)) { + error("Course is misconfigured"); + } + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { + error("Course Module ID was incorrect"); + } } require_login($course->id, false, $cm); @@ -39,34 +39,34 @@ // // Direct sco request // - if ($sco = get_record("scorm_scoes","id",$scoid)) { - if ($sco->launch == '') { - // Search for the next launchable sco - if ($scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' AND id>".$sco->id,"id ASC")) { - $sco = current($scoes); - } - } - } + if ($sco = get_record("scorm_scoes","id",$scoid)) { + if ($sco->launch == '') { + // Search for the next launchable sco + if ($scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' AND id>".$sco->id,"id ASC")) { + $sco = current($scoes); + } + } + } } else { // // Search for first incomplete sco // if ( $scoes_track = get_records_select("scorm_scoes_track","userid=".$USER->id." AND element='cmi.core.lesson_status' AND scormid=".$scorm->id,"scoid ASC") ) { $sco_track = current($scoes_track); - while ((($sco_track->value == "completed") || ($sco_track->value == "passed") || ($sco_track->value == "failed")) && ($mode == "normal")) { - $sco_track = next($scoes_track); - } - $sco = get_record("scorm_scoes","id",$sco_track->scoid); - } - + while ((($sco_track->value == "completed") || ($sco_track->value == "passed") || ($sco_track->value == "failed")) && ($mode == "normal")) { + $sco_track = next($scoes_track); + } + $sco = get_record("scorm_scoes","id",$sco_track->scoid); + } + } // // If no sco was found get the first of SCORM package // if (!isset($sco)) { - $scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>''","id ASC"); - $sco = current($scoes); + $scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>''","id ASC"); + $sco = current($scoes); } // @@ -75,35 +75,35 @@ $connector = ''; $version = substr($scorm->version,0,4); if (!empty($sco->parameters) || ($version == 'AICC')) { - if (stripos($sco->launch,'?') !== false) { - $connector = '&'; - } else { + if (stripos($sco->launch,'?') !== false) { + $connector = '&'; + } else { $connector = '?'; } } if (scorm_external_link($sco->launch)) { - if ($version == 'AICC') { - if (!empty($sco->parameters)) { - $sco->parameters = '&'. $sco->parameters; - } - $result = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters; - } else { - $result = $sco->launch.$connector.$sco->parameters; - } + if ($version == 'AICC') { + if (!empty($sco->parameters)) { + $sco->parameters = '&'. $sco->parameters; + } + $result = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters; + } else { + $result = $sco->launch.$connector.$sco->parameters; + } } else { - if ($CFG->slasharguments) { - $result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/moddata/scorm/'.$scorm->id.'/'.$sco->launch.$connector.$sco->parameters; - } else { - $result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/moddata/scorm/'.$scorm->id.'/'.$sco->launch.$connector.$sco->parameters; - } + if ($CFG->slasharguments) { + $result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/moddata/scorm/'.$scorm->id.'/'.$sco->launch.$connector.$sco->parameters; + } else { + $result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/moddata/scorm/'.$scorm->id.'/'.$sco->launch.$connector.$sco->parameters; + } } ?> - LoadSCO - + LoadSCO + -   +   diff --git a/mod/scorm/mod.html b/mod/scorm/mod.html index e307a0cd29e..50d42c9054c 100755 --- a/mod/scorm/mod.html +++ b/mod/scorm/mod.html @@ -1,16 +1,16 @@ dirroot/mod/scorm/lib.php"); if (empty($form->name)) { - $form->name = ""; + $form->name = ""; } if (empty($form->reference)) { - $form->reference = ""; + $form->reference = ""; } if (empty($form->summary)) { - $form->summary = ""; + $form->summary = ""; } if (empty($form->launch)) { - $form->launch = ""; + $form->launch = ""; } if (empty($form->auto)) { $form->auto = ""; @@ -55,100 +55,100 @@ var myRequest = NewHttpReq(); result = DoRequest(myRequest,"wwwroot) ?>/mod/scorm/validate.php","id=course) ?>&reference="+filename+""); //alert(result); - results = result.split('\n'); - result = ''; - errorlogs = ''; - datadir = ''; - for (i=0;i' != '') { - return confirm(''); - } - } - return true; - } else { - result = ': '+ result + '\n'; - if (errorlogs != '') { - result.concat(':\n'+errorlogs); - } - alert(result); - return false; - } + results = result.split('\n'); + result = ''; + errorlogs = ''; + datadir = ''; + for (i=0;i' != '') { + return confirm(''); + } + } + return true; + } else { + result = ': '+ result + '\n'; + if (errorlogs != '') { + result.concat(':\n'+errorlogs); + } + alert(result); + return false; + } } function checkmethod (grademethod,maxgrade) { - if (grademethod.options[grademethod.selectedIndex].value == 0) { - maxgrade.disabled=true; - } else { - maxgrade.disabled=false; - } + if (grademethod.options[grademethod.selectedIndex].value == 0) { + maxgrade.disabled=true; + } else { + maxgrade.disabled=false; + } }
    - - - - + + + + - - + - + - - - - - + + + + + + - + - - + + + - - + + + - - - + + + - - + +
    : - " /> -
    : + " /> +
    :
    - - +
    :
    + + -
    + summary); ?> -
    - : - - reference\" alt=\"$strfilename\" /> "; - button_to_popup_window ("/files/index.php?id=$course->id&choose=form.reference", - "coursefiles", $strchooseafile, 500, 750, $strchooseafile); - helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true); - ?> -
    + : + + reference\" alt=\"$strfilename\" /> "; + button_to_popup_window ("/files/index.php?id=$course->id&choose=form.reference", + "coursefiles", $strchooseafile, 500, 750, $strchooseafile); + helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true); + ?> +
    : @@ -165,13 +165,13 @@ for ($i=100; $i>=1; $i--) { $grades[$i] = $i; } - $disabled = $form->grademethod=='0'; + $disabled = $form->grademethod=='0'; choose_from_menu($grades, 'maxgrade', "$form->maxgrade", '','','0',false,$disabled); helpbutton('maxgrade', get_string('maximumgrade'), 'scorm'); ?>
    : auto,''); helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true); ?> -
    : browsemode, ''); helpbutton("browsemode", get_string("browsemode", "scorm"), "scorm", true); ?> -
    : - + + -
    : - + + -
    @@ -223,7 +223,7 @@
    - - + +
    diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php index f7f109b3f05..e23396aaf49 100755 --- a/mod/scorm/playscorm.php +++ b/mod/scorm/playscorm.php @@ -71,8 +71,8 @@ $scoidstring = '&scoid='.$scoid; } if (!empty($_POST['currentorg'])) { - $currentorg = $_POST['currentorg']; - $currentorgstring = '¤torg='.$currentorg; + $currentorg = $_POST['currentorg']; + $currentorgstring = '¤torg='.$currentorg; } $strexpand = get_string('expcoll','scorm'); @@ -85,33 +85,33 @@ //$bodyscripts = "onunload='SCOFinish();'"; $bodyscripts = ''; print_header($pagetitle, "$course->fullname", - "$navigation ".format_string($scorm->name,true)."", - '', '', true, update_module_button($cm->id, $course->id, $strscorm),'',false,$bodyscripts); + "$navigation ".format_string($scorm->name,true)."", + '', '', true, update_module_button($cm->id, $course->id, $strscorm),'',false,$bodyscripts); ?>

    summary) ?>

    - - - - - - + +
    -
    - -
    + + + + + + - -
    +
    + +
    id,$sco->id)) { - if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) { - $mode = 'review'; - } - } + if ($trackdata = scorm_get_tracks($USER->id,$sco->id)) { + if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) { + $mode = 'review'; + } + } } add_to_log($course->id, 'scorm', 'view', "playscorm.php?id=$cm->id&scoid=$sco->id", "$scorm->id"); $scoidstring = '&scoid='.$sco->id; @@ -119,18 +119,18 @@ $SESSION->scorm_scoid = $sco->id; ?> -
    -
    - - - - -
    - -
    -
    +
    +
    + + + + +
    + +
    +
    @@ -153,25 +153,25 @@ } } - function popup(win,image) { - win = window.open("loadSCO.php?id=id.$scoidstring.$modestring ?>","","width=width ?>,height=height ?>,scrollbars=1"); + function popup(win,image) { + win = window.open("loadSCO.php?id=id.$scoidstring.$modestring ?>","","width=width ?>,height=height ?>,scrollbars=1"); image.src = "pix/popdown.gif"; - return win; - } + return win; + } - function prevSCO() { - playSCO(prev ?>); - } + function prevSCO() { + playSCO(prev ?>); + } - function nextSCO() { - playSCO(next ?>); - } + function nextSCO() { + playSCO(next ?>); + } function expandCollide(which,list) { var nn=document.ids?true:false - var w3c=document.getElementById?true:false - var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all."; - var mid=w3c?").style":".style"; + var w3c=document.getElementById?true:false + var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all."; + var mid=w3c?").style":".style"; if (eval(beg+list+mid+".display") != "none") { which.src = "pix/plus.gif"; diff --git a/mod/scorm/report.php b/mod/scorm/report.php index 46d9c7355a0..10ef7d81a7f 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -34,7 +34,7 @@ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { error("Course Module ID was incorrect"); } - + } require_login($course->id, false, $cm); @@ -58,22 +58,22 @@ $strscorm = get_string("modulename", "scorm"); $strreport = get_string("report", "scorm"); $strname = get_string('name'); - if (!empty($id)) { + if (!empty($id)) { print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", "$navigation id\">$strscorms -> id\">".format_string($scorm->name,true)." -> $strreport", "", "", true); - } else { + } else { print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname", "$navigation id\">$strscorms -> id\">".format_string($scorm->name,true)." - -> id\">$strreport -> $sco->title", + -> id\">$strreport -> $sco->title", "", "", true); - } + } print_heading(format_string($scorm->name)); } if (!empty($id)) { - if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) { + if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) { if ($scousers=get_records_select("scorm_scoes_track", "scormid='$scorm->id' GROUP BY userid,scormid", "", "userid,scormid")) { $table->head = array(' ', $strname); $table->align = array('center', 'left'); @@ -81,88 +81,88 @@ $table->width = '100%'; $table->size = array(10, '*'); foreach ($scoes as $sco) { - if ($sco->launch!='') { - $table->head[]=scorm_string_round($sco->title); - $table->align[] = 'center'; - $table->wrap[] = 'nowrap'; - $table->size[] = '*'; - } + if ($sco->launch!='') { + $table->head[]=scorm_string_round($sco->title); + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; + $table->size[] = '*'; + } } - foreach ($scousers as $scouser) { - if ($userdata = scorm_get_user_data($scouser->userid)) { - $row = ''; - $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); - $row[] = "wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". - "$userdata->firstname $userdata->lastname"; - foreach ($scoes as $sco) { - if ($sco->launch!='') { - $anchorstart = ''; - $anchorend = ''; - $scoreview = ''; - if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) { - if ($trackdata->score_raw != '') { - $scoreview = '
    '.get_string('score','scorm').': '.$trackdata->score_raw; - } - if ($trackdata->status == '') { - $trackdata->status = 'notattempted'; - } else { - $anchorstart = ''; - $anchorend = ''; - } - } else { - $trackdata->status = 'notattempted'; - $trackdata->total_time = ''; - } - $strstatus = get_string($trackdata->status,'scorm'); - $row[] = $anchorstart.''.$strstatus.' '.$trackdata->total_time.$scoreview.$anchorend; - } - } - $table->data[] = $row; - } - } - print_table($table); + foreach ($scousers as $scouser) { + if ($userdata = scorm_get_user_data($scouser->userid)) { + $row = ''; + $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); + $row[] = "wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">". + "$userdata->firstname $userdata->lastname"; + foreach ($scoes as $sco) { + if ($sco->launch!='') { + $anchorstart = ''; + $anchorend = ''; + $scoreview = ''; + if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) { + if ($trackdata->score_raw != '') { + $scoreview = '
    '.get_string('score','scorm').': '.$trackdata->score_raw; + } + if ($trackdata->status == '') { + $trackdata->status = 'notattempted'; + } else { + $anchorstart = ''; + $anchorend = ''; + } + } else { + $trackdata->status = 'notattempted'; + $trackdata->total_time = ''; + } + $strstatus = get_string($trackdata->status,'scorm'); + $row[] = $anchorstart.''.$strstatus.' '.$trackdata->total_time.$scoreview.$anchorend; + } + } + $table->data[] = $row; + } + } + print_table($table); } else { notice('No users to report'); - } - } + } + } } else { - if (!empty($user)) { - if ($userdata = scorm_get_user_data($user)) { - print_simple_box_start('center'); + if (!empty($user)) { + if ($userdata = scorm_get_user_data($user)) { + print_simple_box_start('center'); print_heading(format_string($sco->title)); - echo '
    '."\n"; - print_user_picture($user, $course->id, $userdata->picture, false, false); - echo "wwwroot/user/view.php?id=$user&course=$course->id\">". - "$userdata->firstname $userdata->lastname
    "; - $scoreview = ''; - if ($trackdata = scorm_get_tracks($sco->id,$user)) { - if ($trackdata->score_raw != '') { - $scoreview = get_string('score','scorm').': '.$trackdata->score_raw; - } - if ($trackdata->status == '') { - $trackdata->status = 'notattempted'; - } - } else { - $trackdata->status = 'notattempted'; - $trackdata->total_time = ''; - } - $strstatus = get_string($trackdata->status,'scorm'); - echo ''.$strstatus.' '.$trackdata->total_time.'
    '.$scoreview.'
    '; - echo '
    '."\n"; - //print_r($trackdata); - foreach($trackdata as $element => $value) { - if (substr($element,0,3) == 'cmi') { - echo $element.' => '.$value.'
    '; - } - } - print_simple_box_end(); - } - } else { - error('Missing script parameter'); - } + echo '
    '."\n"; + print_user_picture($user, $course->id, $userdata->picture, false, false); + echo "wwwroot/user/view.php?id=$user&course=$course->id\">". + "$userdata->firstname $userdata->lastname
    "; + $scoreview = ''; + if ($trackdata = scorm_get_tracks($sco->id,$user)) { + if ($trackdata->score_raw != '') { + $scoreview = get_string('score','scorm').': '.$trackdata->score_raw; + } + if ($trackdata->status == '') { + $trackdata->status = 'notattempted'; + } + } else { + $trackdata->status = 'notattempted'; + $trackdata->total_time = ''; + } + $strstatus = get_string($trackdata->status,'scorm'); + echo ''.$strstatus.' '.$trackdata->total_time.'
    '.$scoreview.'
    '; + echo '
    '."\n"; + //print_r($trackdata); + foreach($trackdata as $element => $value) { + if (substr($element,0,3) == 'cmi') { + echo $element.' => '.$value.'
    '; + } + } + print_simple_box_end(); + } + } else { + error('Missing script parameter'); + } } if (empty($noheader)) { print_footer($course); diff --git a/mod/scorm/request.js b/mod/scorm/request.js index 9001b0f6d5f..bcc66bc8c2c 100644 --- a/mod/scorm/request.js +++ b/mod/scorm/request.js @@ -4,18 +4,18 @@ function NewHttpReq() { httpReq = new XMLHttpRequest(); } else { try { - httpReq = new ActiveXObject("Msxml2.XMLHTTP.4.0"); + httpReq = new ActiveXObject("Msxml2.XMLHTTP.4.0"); } catch (e) { - try { - httpReq = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (ee) { - try { - httpReq = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (eee) { - httpReq = false; - } - } - } + try { + httpReq = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (ee) { + try { + httpReq = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (eee) { + httpReq = false; + } + } + } } return httpReq; } diff --git a/mod/scorm/restorelib.php b/mod/scorm/restorelib.php index a0f0547d583..5e3a937b3e0 100755 --- a/mod/scorm/restorelib.php +++ b/mod/scorm/restorelib.php @@ -95,7 +95,7 @@ for($i = 0; $i < sizeof($scoes); $i++) { $sub_info = $scoes[$i]; - //We'll need this later!! + //We'll need this later!! $oldid = backup_todb($sub_info['#']['ID']['0']['#']); //Now, build the scorm_scoes record structure diff --git a/mod/scorm/validate.php b/mod/scorm/validate.php index 5f945948445..37b42e5db74 100755 --- a/mod/scorm/validate.php +++ b/mod/scorm/validate.php @@ -10,61 +10,61 @@ if (confirm_sesskey()) { $courseid = $_GET["id"]; $launch = 0; if (isset($_GET["instance"])) { - $scormid = $_GET["instance"]; - if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) { + $scormid = $_GET["instance"]; + if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) { $fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r"); $fstat = fstat($fp); fclose($fp); if ($scorm = get_record("scorm","id",$scormid)) { - $launch = $scorm->launch; + $launch = $scorm->launch; if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) { // This is a new package - $launch = 0; + $launch = 0; } else { // Old package already validated - $validation->result = 'found'; - if (strpos($scorm->version,'AICC') !== false) { - $validation->pkgtype = 'AICC'; - } else { - $validation->pkgtype = 'SCORM'; - } - } + $validation->result = 'found'; + if (strpos($scorm->version,'AICC') !== false) { + $validation->pkgtype = 'AICC'; } else { - $validation->result = 'badinstance'; - $launch = -1; - } + $validation->pkgtype = 'SCORM'; + } + } + } else { + $validation->result = 'badinstance'; + $launch = -1; + } } else { - $validation->result = 'badreference'; - $launch = -1; - } + $validation->result = 'badreference'; + $launch = -1; + } } //$launch = 0; if ($launch == 0) { // // Package must be validated // - + // Create a temporary directory to unzip package and validate package $tempdir = ''; $scormdir = ''; - if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) { - if ($tempdir = scorm_datadir($scormdir)) { - copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference)); - $ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.'))); - if (($ext == '.zip') || ($ext == '.pif')) { - unzip_file($tempdir."/".basename($reference), $tempdir, false); - $validation = scorm_validate($tempdir); - } else { - $validation->result = "packagefile"; - } - } else { - $validation->result = "packagedir"; - } - } else { - $validation->result = "datadir"; - } - if (($validation->result != "regular") && ($validation->result != "found")) { - $validation->result = get_string($validation->result,'scorm'); + if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) { + if ($tempdir = scorm_datadir($scormdir)) { + copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference)); + $ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.'))); + if (($ext == '.zip') || ($ext == '.pif')) { + unzip_file($tempdir."/".basename($reference), $tempdir, false); + $validation = scorm_validate($tempdir); + } else { + $validation->result = "packagefile"; + } + } else { + $validation->result = "packagedir"; + } + } else { + $validation->result = "datadir"; + } + if (($validation->result != "regular") && ($validation->result != "found")) { + $validation->result = get_string($validation->result,'scorm'); if (is_dir($tempdir)) { // Delete files and temporary directory scorm_delete_files($tempdir); @@ -82,19 +82,19 @@ if (confirm_sesskey()) { echo 'result=' . $validation->result . "\n"; echo 'launch=' . $launch . "\n"; if (isset($validation->pkgtype)) { - echo 'pkgtype=' . $validation->pkgtype . "\n"; + echo 'pkgtype=' . $validation->pkgtype . "\n"; } if (isset($datadir)) { - echo 'datadir=' . $datadir . "\n"; + echo 'datadir=' . $datadir . "\n"; } if (isset($validation->errors[1])) { - echo 'errorlogs='."\n"; - foreach($validation->errors as $error) { - echo get_string($error->type,"scorm",$error->data) . "\n"; - } + echo 'errorlogs='."\n"; + foreach($validation->errors as $error) { + echo get_string($error->type,"scorm",$error->data) . "\n"; + } } /*if ($validation->pkgtype == 'AICC') { - scorm_parse_aicc("$CFG->dataroot/$courseid/$CFG->moddata/scorm$datadir",$scormid); + scorm_parse_aicc("$CFG->dataroot/$courseid/$CFG->moddata/scorm$datadir",$scormid); }*/ } else { echo 'result=' . get_string('badrequest','scorm') . "\n"; diff --git a/mod/scorm/validatordomxml.php b/mod/scorm/validatordomxml.php index f9f075866f7..58d4567791c 100755 --- a/mod/scorm/validatordomxml.php +++ b/mod/scorm/validatordomxml.php @@ -27,115 +27,115 @@ function is_message($str) function is_cond_val($st) { - return($st == "satisfied" | $st == "objectiveStatusKnown" | $st == "objectiveMeasureKnown" | - $st == "objectiveMeasureGreaterThan" | $st == "objectiveMeasureLessThan" | - $st == "completed" | $st =="activityProgressKnown" | $st == "attempted" | - $st == "attemptLimitExceeded" | $st == "timeLimitExceeded" | $st == "always" | - $st == "outsideAvailableTimeRange"); + return($st == "satisfied" | $st == "objectiveStatusKnown" | $st == "objectiveMeasureKnown" | + $st == "objectiveMeasureGreaterThan" | $st == "objectiveMeasureLessThan" | + $st == "completed" | $st =="activityProgressKnown" | $st == "attempted" | + $st == "attemptLimitExceeded" | $st == "timeLimitExceeded" | $st == "always" | + $st == "outsideAvailableTimeRange"); } function is_action1($str1) { - return($str1 == "skip" | $str1 == "disabled" | $str1 == "hiddenFromChoice" | $str1 == "stopForwardTraversal"); + return($str1 == "skip" | $str1 == "disabled" | $str1 == "hiddenFromChoice" | $str1 == "stopForwardTraversal"); } function is_action2($str2) { - return($str2 == "exitParent" | $str2 == "exitAll" | $str2 == "retry" | $str2 == "retryAll" | - $str2 == "continue" | $str2 == "previous"); + return($str2 == "exitParent" | $str2 == "exitAll" | $str2 == "retry" | $str2 == "retryAll" | + $str2 == "continue" | $str2 == "previous"); } function is_rcond_val($st1) { - return($st1 == "satisfied" | $st1 == "objectiveStatusKnown" | $st1 == "objectiveMeasureKnown" | - $st1 == "completed" | $st1 =="activityProgressKnown" | $st1 == "attempted" | - $st1 == "attemptLimitExceeded" | $st1 == "timeLimitExceeded" | $st1 == "outsideAvailableTimeRange"); + return($st1 == "satisfied" | $st1 == "objectiveStatusKnown" | $st1 == "objectiveMeasureKnown" | + $st1 == "completed" | $st1 =="activityProgressKnown" | $st1 == "attempted" | + $st1 == "attemptLimitExceeded" | $st1 == "timeLimitExceeded" | $st1 == "outsideAvailableTimeRange"); } function is_rolAc_val($str3) { - return($str3 == "satisfied" | $str3 == "notSatisfied" | $str3 == "completed" | $str3 == "incomplete"); + return($str3 == "satisfied" | $str3 == "notSatisfied" | $str3 == "completed" | $str3 == "incomplete"); } function is_randT_attr($str4) { - return($str4 == "never" | $str4 == "once" | $str4 == "onEachNewAttempt"); + return($str4 == "never" | $str4 == "once" | $str4 == "onEachNewAttempt"); } function is_rolCo_val($str5) { - return($str5 == "always" | $str5 == "ifAttempted" | $str5 == "ifNotSkipped" | $str5 == "ifNotSuspended"); + return($str5 == "always" | $str5 == "ifAttempted" | $str5 == "ifNotSkipped" | $str5 == "ifNotSuspended"); } function is_hch_cont($str6) { - return($str6 == "previous" | $str6 == "continue" | $str6 == "exit" | $str6 == "abandon"); + return($str6 == "previous" | $str6 == "continue" | $str6 == "exit" | $str6 == "abandon"); } /* Funzione che testa l'elemento root dell'albero DOM generato */ function testRoot($DomNode) { - global $errors; - global $cont_err; - $error = NULL; - - if(($DomNode->node_type() == "1")&&($DomNode->tagname() == "manifest")) - { - if(!$DomNode->has_attributes()) - { - $error->type = "no_attributes"; - $error->data->tag = "manifest"; - array_push($errors, $error); - $cont_err++; - } - $attr_array = $DomNode->attributes(); - $attr_n = $attr_array[0]->node_name(); - if($DomNode->has_attribute("identifier")) - { - if((strcmp("identifier", $attr_n)!=0)||($attr_array[0]->node_value() == "")) - { - $error->type = "attr_error"; + global $errors; + global $cont_err; + $error = NULL; + + if(($DomNode->node_type() == "1")&&($DomNode->tagname() == "manifest")) + { + if(!$DomNode->has_attributes()) + { + $error->type = "no_attributes"; + $error->data->tag = "manifest"; + array_push($errors, $error); + $cont_err++; + } + $attr_array = $DomNode->attributes(); + $attr_n = $attr_array[0]->node_name(); + if($DomNode->has_attribute("identifier")) + { + if((strcmp("identifier", $attr_n)!=0)||($attr_array[0]->node_value() == "")) + { + $error->type = "attr_error"; $error->data->tag = "manifest"; - $error->data->attr = $attr_n; - array_push($errors, $error); - $cont_err++; - } - } else { - $error->type = "missing_attribute"; - $error->data->tag = "manifest"; - $error->data->attr = 'identifier'; - array_push($errors, $error); - $cont_err++; - } - - if($DomNode->has_attribute("version")) - { - $version = $attr_array[1]->node_value(); - if(!eregi("[1-9]\.[0-9]", $version)) - { - $error->type = "attr_error"; + $error->data->attr = $attr_n; + array_push($errors, $error); + $cont_err++; + } + } else { + $error->type = "missing_attribute"; + $error->data->tag = "manifest"; + $error->data->attr = 'identifier'; + array_push($errors, $error); + $cont_err++; + } + + if($DomNode->has_attribute("version")) + { + $version = $attr_array[1]->node_value(); + if(!eregi("[1-9]\.[0-9]", $version)) + { + $error->type = "attr_error"; $error->data->tag = "manifest"; - $error->data->attr = 'version'; - array_push($errors, $error); - $cont_err++; - } - } else { - $error->type = "missing_attribute"; - $error->data->tag = "manifest"; - $error->data->attr = 'version'; - array_push($errors, $error); - $cont_err++; - } - if(count($errors) > 0) + $error->data->attr = 'version'; + array_push($errors, $error); + $cont_err++; + } + } else { + $error->type = "missing_attribute"; + $error->data->tag = "manifest"; + $error->data->attr = 'version'; + array_push($errors, $error); + $cont_err++; + } + if(count($errors) > 0) { return false; } else { return true; - } - } - return false; + } + } + return false; } /* funzione che scorre l'albero DOM e valida il documento*/ @@ -154,93 +154,93 @@ function testNode($DomNode) if($figlio = $DomNode->first_child()) { while($figlio) - { - if($figlio->node_type() == "1") - { - //valore booleano che viene restituito dalla funzione se e' tutto corretto - - $nome_figlio = $figlio->node_name(); - $padre = $figlio->parent_node(); - $pp = $padre->parent_node(); - - if($nome_figlio == "metadata") - { - if($figlio->has_attributes()) + { + if($figlio->node_type() == "1") + { + //valore booleano che viene restituito dalla funzione se e' tutto corretto + + $nome_figlio = $figlio->node_name(); + $padre = $figlio->parent_node(); + $pp = $padre->parent_node(); + + if($nome_figlio == "metadata") + { + if($figlio->has_attributes()) { - $error->type = "too_many_attributes"; - $error->data->tag = "metadata"; - array_push($errors, $error); - $cont_err++; + $error->type = "too_many_attributes"; + $error->data->tag = "metadata"; + array_push($errors, $error); + $cont_err++; } - + $mdata_children = $figlio->child_nodes(); //array dei figli // Il metodo count conta il numero di elementi dell'array e ritorna il numero $tot_children = count($mdata_children); - if($padre->node_name() == "manifest") - { - //Si controlla se il tag metadata ha i figli e - //che devono essere SEMPRE presenti all'interno del manifest. - $test_sc = $tot_children; + if($padre->node_name() == "manifest") + { + //Si controlla se il tag metadata ha i figli e + //che devono essere SEMPRE presenti all'interno del manifest. + $test_sc = $tot_children; $test_scv = $tot_children; - for($i = 0; $i < $tot_children; $i++) - { - $cur_child = $mdata_children[$i]; - if($cur_child->node_name()!="schema") - { - $test_sc--; - } - if($cur_child->node_name() != "schemaversion") - { - $test_scv--; - } else { - $schema_version = $cur_child->node_value(); - } - } - - if(!eregi("(CAM[[:blank:]])?[1]\.[3]", $schema_version)) + for($i = 0; $i < $tot_children; $i++) + { + $cur_child = $mdata_children[$i]; + if($cur_child->node_name()!="schema") + { + $test_sc--; + } + if($cur_child->node_name() != "schemaversion") + { + $test_scv--; + } else { + $schema_version = $cur_child->node_value(); + } + } + + if(!eregi("(CAM[[:blank:]])?[1]\.[3]", $schema_version)) { if($figlio->has_child_nodes()) { - $error->type = "too_many_children"; + $error->type = "too_many_children"; $error->data->tag = "metadata"; array_push($errors, $error); } } else { if(!$figlio->has_child_nodes()) { - $error->type = "no_children"; + $error->type = "no_children"; $error->data->tag = "metadata"; array_push($errors, $error); } if($test_sc <= 0) { - $error->type = "missing_tag"; - $error->data->tag = "schema"; - array_push($errors, $error); - $cont_err++; + $error->type = "missing_tag"; + $error->data->tag = "schema"; + array_push($errors, $error); + $cont_err++; } - if($test_scv <= 0) - { - $error->type = "missing_tag"; + if($test_scv <= 0) + { + $error->type = "missing_tag"; $error->data->tag = "schemaversion"; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - } + } - //METADATA puo'comparire anche come figlio di altri nodi + //METADATA puo'comparire anche come figlio di altri nodi - if($padre->node_name() != "manifest") - { - $t_sc = $tot_children; + if($padre->node_name() != "manifest") + { + $t_sc = $tot_children; $t_scv = $tot_children; $new_t_sc = 0; $new_t_scv = 0; - for($i = 0; $i < $tot_children; $i++) + for($i = 0; $i < $tot_children; $i++) { $cc = $mdata_children[$i]; @@ -256,529 +256,529 @@ function testNode($DomNode) }//fine FOR - if(eregi("(CAM[[:blank:]])?[1]\.[3]", $schema_version)) - { - if($new_t_sc < $t_sc) + if(eregi("(CAM[[:blank:]])?[1]\.[3]", $schema_version)) + { + if($new_t_sc < $t_sc) { $error->type = "too_many_children"; $error->data->tag = "metadata"; array_push($errors, $error); //echo "WARNING, se il tag metadata non e' figlio di manifest non deve avere schema // come figlio
    "; - //echo "Probabilmente la versione e' antecedente alla 1.3
    "; - } - if($new_t_scv < $t_scv) + //echo "Probabilmente la versione e' antecedente alla 1.3
    "; + } + if($new_t_scv < $t_scv) { $error->type = "too_many_children"; $error->data->tag = "metadata"; array_push($errors, $error); //echo "WARNING, se il tag metadata non e' figlio di manifest, non deve avere schemaversion // come figlio
    "; - //echo "Probabilmente la versione e' antecedente alla 1.3
    "; + //echo "Probabilmente la versione e' antecedente alla 1.3
    "; } } - } - // echo "SCANSIONE TAG METADATA TERMINATA, OK \n"; - }// FINE IF METADATA - - if($nome_figlio == "schema") - { - if($padre->node_name() != "metadata") + } + // echo "SCANSIONE TAG METADATA TERMINATA, OK \n"; + }// FINE IF METADATA + + if($nome_figlio == "schema") + { + if($padre->node_name() != "metadata") { - $error->type = "position_error"; - $error->data->tag = "schema"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - //echo "ERROR, schema puo'comparire solo come figlio di metadata"; - $cont_err++; - } - if(!$figlio->has_child_nodes()) - { - $error->type = "no_children"; - $error->data->tag = "schema"; - array_push($errors, $error); - $cont_err++; - } - $sc = $figlio->first_child(); + $error->type = "position_error"; + $error->data->tag = "schema"; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + //echo "ERROR, schema puo'comparire solo come figlio di metadata"; + $cont_err++; + } + if(!$figlio->has_child_nodes()) + { + $error->type = "no_children"; + $error->data->tag = "schema"; + array_push($errors, $error); + $cont_err++; + } + $sc = $figlio->first_child(); if(($sc->node_type() == 3)&&(strcmp($sc->node_value(), "ADL SCORM")!=0)) { - $error->type = "tag_error"; - $error->data->tag = "schema"; - $error->data->value = $sc->node_value(); - array_push($errors, $error); - $cont_err++; + $error->type = "tag_error"; + $error->data->tag = "schema"; + $error->data->value = $sc->node_value(); + array_push($errors, $error); + $cont_err++; } - - } + + } - if($nome_figlio == "schemaversion") - { - if($padre->node_name() != "metadata") - { - $error->type = "position_error"; + if($nome_figlio == "schemaversion") + { + if($padre->node_name() != "metadata") + { + $error->type = "position_error"; $error->data->tag = "schemaversion"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - if(!$figlio->has_child_nodes()) + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + if(!$figlio->has_child_nodes()) { - $error->type = "no_children"; + $error->type = "no_children"; $error->data->tag = "schema"; - array_push($errors, $error); - $cont_err++; + array_push($errors, $error); + $cont_err++; } - $svc = $figlio->first_child(); - - $version_value = $svc->node_value(); + $svc = $figlio->first_child(); + + $version_value = $svc->node_value(); if(($svc->node_type() == 3)&&(!eregi("(CAM[[:blank:]])?[1]\.[0-3]",$svc->node_value()))) - { - $version_value = $svc->node_value(); - if(eregi("[1]\.[0-3]", $version_value)) - { - echo "Versione=",$version_value; - } else { - $error->type = "tag_error"; - $error->data->tag = "schemaversion"; - $error->data->value = $version_value; - array_push($errors, $error); - } + { + $version_value = $svc->node_value(); + if(eregi("[1]\.[0-3]", $version_value)) + { + echo "Versione=",$version_value; + } else { + $error->type = "tag_error"; + $error->data->tag = "schemaversion"; + $error->data->value = $version_value; + array_push($errors, $error); + } } - - } + + } - if($nome_figlio == "location") - { - if(strcmp("metadata", $padre->node_name())!=0) + if($nome_figlio == "location") + { + if(strcmp("metadata", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = "location"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; } - if(!$figlio->has_child_nodes()) + if(!$figlio->has_child_nodes()) { - $error->type = "no_children"; + $error->type = "no_children"; $error->data->tag = "location"; - array_push($errors, $error); - $cont_err++; + array_push($errors, $error); + $cont_err++; } - else - { + else + { $loc = $figlio->first_child(); if(($loc->node_type() == 3)&&(!eregi("[[:print:]]\.[a-z]",$loc->node_value()))) { - $error->type = "tag_error"; + $error->type = "tag_error"; $error->data->tag = "location"; - $error->data->value = $loc->node_value(); - array_push($errors, $error); - $cont_err++; + $error->data->value = $loc->node_value(); + array_push($errors, $error); + $cont_err++; } - } - //echo "
    SCANSIONE DI LOCATION TERMINATA, OK \n"; - } + } + //echo "
    SCANSIONE DI LOCATION TERMINATA, OK \n"; + } - if($nome_figlio == "organizations") - { - if($padre->node_name() != "manifest") - { - $error->type = "position_error"; + if($nome_figlio == "organizations") + { + if($padre->node_name() != "manifest") + { + $error->type = "position_error"; $error->data->tag = "organizations"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - if(!eregi("(CAM[[:blank:]])?[1]\.[3]", $version_value)) - { - if($figlio->has_attribute("default")) - { - $orgs_attr_old = $figlio->attributes(); - $defv_old = $orgs_attr_old[0]->node_value(); - if(!eregi("[[:graph:]]", $defv_old)) - { - $error->type = "attr_error"; - $error->data->tag = "organizations"; - $error->data->attr = "default"; - array_push($errors, $error); - $cont_err++; - } - } - } else { - if((!$figlio->has_attributes())||(!$figlio->has_attribute("default"))) - { - $error->type = "missing_attribute"; - $error->data->tag = "organizations"; - $error->data->attr = "default"; - array_push($errors, $error); - $cont_err++; - } - $orgs_attr = $figlio->attributes(); - if($orgs_attr[0]->node_value() != "") - { - $def_v = $orgs_attr[0]->node_value(); - array_push($def_org_array, $def_v); - } + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + if(!eregi("(CAM[[:blank:]])?[1]\.[3]", $version_value)) + { + if($figlio->has_attribute("default")) + { + $orgs_attr_old = $figlio->attributes(); + $defv_old = $orgs_attr_old[0]->node_value(); + if(!eregi("[[:graph:]]", $defv_old)) + { + $error->type = "attr_error"; + $error->data->tag = "organizations"; + $error->data->attr = "default"; + array_push($errors, $error); + $cont_err++; + } + } + } else { + if((!$figlio->has_attributes())||(!$figlio->has_attribute("default"))) + { + $error->type = "missing_attribute"; + $error->data->tag = "organizations"; + $error->data->attr = "default"; + array_push($errors, $error); + $cont_err++; + } + $orgs_attr = $figlio->attributes(); + if($orgs_attr[0]->node_value() != "") + { + $def_v = $orgs_attr[0]->node_value(); + array_push($def_org_array, $def_v); + } - if(!$figlio->has_child_nodes()) - { - $error->type = "no_children"; + if(!$figlio->has_child_nodes()) + { + $error->type = "no_children"; $error->data->tag = "organizations"; - array_push($errors, $error); - $cont_err++; - } + array_push($errors, $error); + $cont_err++; + } - $orgs_children = $figlio->child_nodes(); + $orgs_children = $figlio->child_nodes(); $cont_orgs = count($orgs_children); for($k=0; $k < $cont_orgs; $k++) { $co = $orgs_children[$k]; - $test1 = $cont_orgs; - if(($co->node_type() != 1)&&($co->node_name() != "organization")) - { - $test1--; - } - } - - if($test1 <= 0) + $test1 = $cont_orgs; + if(($co->node_type() != 1)&&($co->node_name() != "organization")) + { + $test1--; + } + } + + if($test1 <= 0) { - $error->type = "missing_tag"; - $error->data->tag = "organizations"; - array_push($errors, $error); - $cont_err++; + $error->type = "missing_tag"; + $error->data->tag = "organizations"; + array_push($errors, $error); + $cont_err++; } } - - //echo "SCANSIONE TAG ORGANIZATIONS TERMINATA, OK \n"; - }//FINE IF ORGANIZATIONS + + //echo "SCANSIONE TAG ORGANIZATIONS TERMINATA, OK \n"; + }//FINE IF ORGANIZATIONS - if($nome_figlio == "organization") - { - if($padre->node_name() != "organizations") - { - $error->type = "position_error"; + if($nome_figlio == "organization") + { + if($padre->node_name() != "organizations") + { + $error->type = "position_error"; $error->data->tag = "organization"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - - if(!$figlio->has_attributes()) + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + + if(!$figlio->has_attributes()) { - $error->type = "no_attributes"; - $error->data->tag = "organization"; - array_push($errors, $error); - $cont_err++; + $error->type = "no_attributes"; + $error->data->tag = "organization"; + array_push($errors, $error); + $cont_err++; } $org_attr = $figlio->attributes(); - $cont_org = count($org_attr); - if($cont_org > 3) - { - $error->type = "too_many_attributes"; - $error->data->tag = "organization"; - array_push($errors, $error); - $cont_err++; - } + $cont_org = count($org_attr); + if($cont_org > 3) + { + $error->type = "too_many_attributes"; + $error->data->tag = "organization"; + array_push($errors, $error); + $cont_err++; + } $org_id = $org_attr[0]->node_name(); $org_val = $org_attr[0]->node_value(); if(($org_id != "identifier")||(!eregi("[[:graph:]]", $org_val))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = "organization"; - $error->data->attr = $org_id; - array_push($errors, $error); - $cont_err++; + $error->data->attr = $org_id; + array_push($errors, $error); + $cont_err++; } - else { + else { array_push($id_org_array, $org_val); - } - - if($figlio->has_attribute("structure")) + } + + if($figlio->has_attribute("structure")) { if($org_attr[1]->node_value() == "") - { - $error->type = "tag_error"; - $error->data->tag = "organization"; - array_push($errors, $error); - $cont_err++; - } + { + $error->type = "tag_error"; + $error->data->tag = "organization"; + array_push($errors, $error); + $cont_err++; + } } - if($figlio->has_attribute("adlseq:objectivesGlobalToSystem")) - { - $ot_n = $org_attr[2]->node_name(); - $ot_val = $org_attr[2]->node_value(); - if(eregi("^$", $ot_val)) - { - $error->type = "attrError"; - $error->data->tag = "organization"; - $error->data->attr = $ot_n; - array_push($errors, $error); - $cont_err++; - } - if(!((strcmp("true", $ot_val)==0)||(strcmp("false", $ot_val)==0))) - { - $error->type = "attr_error"; + if($figlio->has_attribute("adlseq:objectivesGlobalToSystem")) + { + $ot_n = $org_attr[2]->node_name(); + $ot_val = $org_attr[2]->node_value(); + if(eregi("^$", $ot_val)) + { + $error->type = "attrError"; + $error->data->tag = "organization"; + $error->data->attr = $ot_n; + array_push($errors, $error); + $cont_err++; + } + if(!((strcmp("true", $ot_val)==0)||(strcmp("false", $ot_val)==0))) + { + $error->type = "attr_error"; $error->data->tag = "organization"; $error->data->attr = $ot_n; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } if(!$figlio->has_child_nodes()) { - $error->type = "no_children"; + $error->type = "no_children"; $error->data->tag = "organization"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - $org_children = $figlio->child_nodes(); - $org_cont = count($org_children); - for($j=0; $j < $org_cont; $j++) - { - $of = $org_children[$j]->node_name(); - $test2 = $org_cont; - if($of != "title") - { - $test2--; - } - } - if($test2 <= 0) + $org_children = $figlio->child_nodes(); + $org_cont = count($org_children); + for($j=0; $j < $org_cont; $j++) + { + $of = $org_children[$j]->node_name(); + $test2 = $org_cont; + if($of != "title") + { + $test2--; + } + } + if($test2 <= 0) { - $error->type = "missing_tag"; + $error->type = "missing_tag"; $error->data->tag = "title"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - //echo "SCANSIONE TAG ORGANIZATION TERMINATA, OK \n"; - }//FINE IF ORGANIZATION - - if($nome_figlio == "item") - { - if(!((strcmp("organization", $padre->node_name())==0)|| - (strcmp("title", $padre->node_name())==0)|| - (strcmp("item", $padre->node_name())==0))) - { - $error->type = "position_error"; + //echo "SCANSIONE TAG ORGANIZATION TERMINATA, OK \n"; + }//FINE IF ORGANIZATION + + if($nome_figlio == "item") + { + if(!((strcmp("organization", $padre->node_name())==0)|| + (strcmp("title", $padre->node_name())==0)|| + (strcmp("item", $padre->node_name())==0))) + { + $error->type = "position_error"; $error->data->tag = "item"; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if(!$figlio->has_attributes()) - { - $error->type = "no_attributes"; + $cont_err++; + } + if(!$figlio->has_attributes()) + { + $error->type = "no_attributes"; $error->data->tag = "item"; array_push($errors, $error); - $cont_err++; - } - $item_attr = $figlio->attributes(); - $cont_attr2 = count($item_attr); - for($i=0; $i < $cont_attr2; $i++) - { - $ia = $item_attr[$i]; - if(!$figlio->has_attribute("identifier")) - { - echo "ERROR, manca l'attributo ID"; - $cont_err++; - } - elseif($ia->node_name()=="identifier") - { - $item_id = $ia->node_name(); + $cont_err++; + } + $item_attr = $figlio->attributes(); + $cont_attr2 = count($item_attr); + for($i=0; $i < $cont_attr2; $i++) + { + $ia = $item_attr[$i]; + if(!$figlio->has_attribute("identifier")) + { + echo "ERROR, manca l'attributo ID"; + $cont_err++; + } + elseif($ia->node_name()=="identifier") + { + $item_id = $ia->node_name(); $item_id_val = $ia->node_value(); - if($item_id_val == "") - { - $error->type = "attr_error"; + if($item_id_val == "") + { + $error->type = "attr_error"; $error->data->tag = "item"; $error->data->attr = $item_id; array_push($errors, $error); - $cont_err++; - } - } - - if(($figlio->has_attribute("identifierref"))&&($ia->node_name()=="identifierref")) - { - $id_ref_val = $ia->node_value(); - if(eregi("[[:graph:]]", $id_ref_val)) - { - array_push($item_idref_array, $id_ref_val); - } + $cont_err++; + } + } + + if(($figlio->has_attribute("identifierref"))&&($ia->node_name()=="identifierref")) + { + $id_ref_val = $ia->node_value(); + if(eregi("[[:graph:]]", $id_ref_val)) + { + array_push($item_idref_array, $id_ref_val); + } else - { - $error->type = "attr_error"; + { + $error->type = "attr_error"; $error->data->tag = "item"; - $error->data->attr = "identifierref"; + $error->data->attr = "identifierref"; array_push($errors, $error); - $cont_err++; - } + $cont_err++; + } } - if(($figlio->has_attribute("isvisible"))&&($ia->node_name()=="isvisible")) - { - $isv_n = $ia->node_name(); - $isv_val = $ia->node_value(); - if(!((strcmp("true", $isv_val)==0)||(strcmp("false", $isv_val)==0))) - { - $error->type = "attr_error"; + if(($figlio->has_attribute("isvisible"))&&($ia->node_name()=="isvisible")) + { + $isv_n = $ia->node_name(); + $isv_val = $ia->node_value(); + if(!((strcmp("true", $isv_val)==0)||(strcmp("false", $isv_val)==0))) + { + $error->type = "attr_error"; $error->data->tag = "item"; $error->data->attr = $isv_n; array_push($errors, $error); - $cont_err++; - } - } - - if(($figlio->has_attribute("parameters"))&&($ia->node_name()=="parameters")) - { - $par_n = $ia->node_name(); - $par_val = $ia->node_value(); - if(($par_val == "")||($par_val == " ")) - { - $error->type = "attr_error"; + $cont_err++; + } + } + + if(($figlio->has_attribute("parameters"))&&($ia->node_name()=="parameters")) + { + $par_n = $ia->node_name(); + $par_val = $ia->node_value(); + if(($par_val == "")||($par_val == " ")) + { + $error->type = "attr_error"; $error->data->tag = "item"; $error->data->attr = $par_n; array_push($errors, $error); - $cont_err++; - } - } - }//FINE FOR + $cont_err++; + } + } + }//FINE FOR - if(!$figlio->has_child_nodes()) - { - $error->type = "no_children"; + if(!$figlio->has_child_nodes()) + { + $error->type = "no_children"; $error->data->tag = "item"; array_push($errors, $error); - $cont_err++; - } + $cont_err++; + } - $item_children = $figlio->child_nodes(); - $cont_ic = count($item_children); - for($c=0; $c < $cont_ic; $c++) - { - $ic_n = $item_children[$c]; - $test3 = $cont_ic; - if($ic_n->node_name() != "title") - { - $test3--; - } - } - if($test3 <= 0) + $item_children = $figlio->child_nodes(); + $cont_ic = count($item_children); + for($c=0; $c < $cont_ic; $c++) + { + $ic_n = $item_children[$c]; + $test3 = $cont_ic; + if($ic_n->node_name() != "title") + { + $test3--; + } + } + if($test3 <= 0) { - $error->type = "missing_tag"; + $error->type = "missing_tag"; $error->data->tag = "title"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - }//FINE IF ITEM + }//FINE IF ITEM - if($nome_figlio == "title") - { - if($figlio->get_content() == "") - { - $error->type = "tag_error"; + if($nome_figlio == "title") + { + if($figlio->get_content() == "") + { + $error->type = "tag_error"; $error->data->tag = "title"; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($nome_figlio == "timeLimitAction") - { - if($padre->node_name() != "item") - { - $error->type = "position_error"; - $error->data->tag = "timeLimitAction"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - if($pp->node_name() != "item") - { - $error->type = "position_error"; - $error->data->tag = "timeLimitAction"; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - if(($figlio->get_content() == "")||(!is_message($figlio->get_content()))) - { - $error->type = "tag_error"; - $error->data->tag = "timeLimitAction"; - $error->data->value = $figlio->get_content(); - array_push($errors, $error); - $cont_err++; - } - } - - if($nome_figlio == "dataFromLMS") - { - if($padre->node_name() != "item") + if($nome_figlio == "timeLimitAction") + { + if($padre->node_name() != "item") + { + $error->type = "position_error"; + $error->data->tag = "timeLimitAction"; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + if($pp->node_name() != "item") + { + $error->type = "position_error"; + $error->data->tag = "timeLimitAction"; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + if(($figlio->get_content() == "")||(!is_message($figlio->get_content()))) + { + $error->type = "tag_error"; + $error->data->tag = "timeLimitAction"; + $error->data->value = $figlio->get_content(); + array_push($errors, $error); + $cont_err++; + } + } + + if($nome_figlio == "dataFromLMS") + { + if($padre->node_name() != "item") { - $error->type = "position_error"; - $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; + $error->type = "position_error"; + $error->data->tag = $nome_figlio; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; } if($pp->node_name() != "item") { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; } - } + } - //Il tag prerequisites e' presente solo nelle versioni precedenti alla 1.3 + //Il tag prerequisites e' presente solo nelle versioni precedenti alla 1.3 - if(($nome_figlio == "prerequisites")&&(eregi("(CAM[[:blank:]])?[1]\.[0-2]", $version_value))) - { - if(strcmp("item", $padre->node_name())!=0) - { - $error->type = "position_error"; - $error->data->tag = "$nome_figlio"; - $error->data->parent = $padre->node_name(); - array_push($errors); - $cont_err++; - } - if(!$figlio->has_attributes()) - { - $error->type = "no_attributes"; - $error->data->tag = $nome_figlio; - array_push($errors, $error); - $cont_err++; - } - if(!$figlio->has_attribute("type")) - { - $error->type = "missing_attribute"; - $error->data->tag = $nome_figlio; - $error->data->attr = "type"; - array_push($errors, $error); - $cont_err++; - } else { - $pre_attr = $figlio->attributes(); - $pre_attr_n = $pre_attr[0]->node_name(); - $pre_attr_v = $pre_attr[0]->node_value(); - if((strcmp("type", $pre_attr_n)==0)&&(strcmp("aicc_script", $pre_attr_v)!=0)) - { - $error->type = "attr_error"; - $error->data->tag = $nome_figlio; - $error->data->attr = $pre_attr_n; - array_push($errors, $error); - $cont_err++; - } - } - } + if(($nome_figlio == "prerequisites")&&(eregi("(CAM[[:blank:]])?[1]\.[0-2]", $version_value))) + { + if(strcmp("item", $padre->node_name())!=0) + { + $error->type = "position_error"; + $error->data->tag = "$nome_figlio"; + $error->data->parent = $padre->node_name(); + array_push($errors); + $cont_err++; + } + if(!$figlio->has_attributes()) + { + $error->type = "no_attributes"; + $error->data->tag = $nome_figlio; + array_push($errors, $error); + $cont_err++; + } + if(!$figlio->has_attribute("type")) + { + $error->type = "missing_attribute"; + $error->data->tag = $nome_figlio; + $error->data->attr = "type"; + array_push($errors, $error); + $cont_err++; + } else { + $pre_attr = $figlio->attributes(); + $pre_attr_n = $pre_attr[0]->node_name(); + $pre_attr_v = $pre_attr[0]->node_value(); + if((strcmp("type", $pre_attr_n)==0)&&(strcmp("aicc_script", $pre_attr_v)!=0)) + { + $error->type = "attr_error"; + $error->data->tag = $nome_figlio; + $error->data->attr = $pre_attr_n; + array_push($errors, $error); + $cont_err++; + } + } + } - //Il tag maxtimeallowed e' presente solo nelle versioni precedenti alla 1.3 + //Il tag maxtimeallowed e' presente solo nelle versioni precedenti alla 1.3 - if(($nome_figlio == "maxtimeallowed")&&(eregi("(CAM[[:blank:]])?[1]\.[0-2]", $version_value))) - { - if(strcmp("item", $padre->node_name())!=0) + if(($nome_figlio == "maxtimeallowed")&&(eregi("(CAM[[:blank:]])?[1]\.[0-2]", $version_value))) + { + if(strcmp("item", $padre->node_name())!=0) { $error->type = "position_error"; $error->data->tag = "$nome_figlio"; @@ -786,25 +786,25 @@ function testNode($DomNode) array_push($errors); $cont_err++; } - if(!$figlio->has_child_nodes()) + if(!$figlio->has_child_nodes()) { $error->type = "no_children"; $error->data->tag = $nome_figlio; array_push($errors, $error); $cont_err++; } else { - $mta_child = $figlio->first_child(); - if(!eregi("([0-9]{2}):([0-9]{2}):([0-9]{2})", $mta_child->get_content())) - { - $error->type = "tag_error"; + $mta_child = $figlio->first_child(); + if(!eregi("([0-9]{2}):([0-9]{2}):([0-9]{2})", $mta_child->get_content())) + { + $error->type = "tag_error"; $error->data->tag = $nome_figlio; array_push($errors, $error); $cont_err++; - } - } - } + } + } + } - //Il tag masteryscore e' presente solo nelle versioni precedenti alla 1.3 + //Il tag masteryscore e' presente solo nelle versioni precedenti alla 1.3 if(($nome_figlio == "masteryscore")&&(eregi("(CAM[[:blank:]])?[1]\.[0-2]", $version_value))) { @@ -833,1248 +833,1248 @@ function testNode($DomNode) } } } - - if($nome_figlio == "resources") - { - if(strcmp("manifest", $padre->node_name())!=0) - { - $error->type = "position_error"; + + if($nome_figlio == "resources") + { + if(strcmp("manifest", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($nome_figlio == "resource") - { - if(strcmp("resources", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "resource") + { + if(strcmp("resources", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if(!$figlio->has_attributes()) + $cont_err++; + } + if(!$figlio->has_attributes()) { - $error->type = "no_attributes"; + $error->type = "no_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; + $cont_err++; } $res_attr = $figlio->attributes(); $cont_res = count($res_attr); - if($cont_res > 6) - { - $error->type = "too_many_attributes"; + if($cont_res > 6) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_res; $i++) - { - $ra_n = $res_attr[$i]->node_name(); - $ra_v = $res_attr[$i]->node_value(); - if(!$figlio->has_attribute("identifier")) - { - $error->type = "missing_attribute"; + $cont_err++; + } + for($i=0; $i < $cont_res; $i++) + { + $ra_n = $res_attr[$i]->node_name(); + $ra_v = $res_attr[$i]->node_value(); + if(!$figlio->has_attribute("identifier")) + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->data->attr = "identifier"; + $error->data->attr = "identifier"; array_push($errors, $error); - $cont_err++; - } - elseif($ra_n == "identifier") - { - if(eregi("[[:graph:]]", $ra_v)) - { - array_push($idres_array, $ra_v); - } else { - $error->type = "attr_error"; + $cont_err++; + } + elseif($ra_n == "identifier") + { + if(eregi("[[:graph:]]", $ra_v)) + { + array_push($idres_array, $ra_v); + } else { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $ra_n; + $error->data->attr = $ra_n; array_push($errors, $error); - } - } + } + } - if(!$figlio->has_attribute("type")) - { - $error->type = "missing_attribute"; + if(!$figlio->has_attribute("type")) + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->tag->attr = "type"; + $error->tag->attr = "type"; array_push($errors, $error); - $cont_err++; - } - elseif($ra_n == "type") + $cont_err++; + } + elseif($ra_n == "type") { if(strcmp("webcontent", $ra_v)!=0) - { - $error->type = "attr_error"; + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = "type"; + $error->data->attr = "type"; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if(($figlio->has_attribute("href"))&&(strcmp("href", $ra_n)==0)) - { - if(!eregi("[[:graph:]]", $ra_v)) - { - $error->type = "attr_error"; + if(($figlio->has_attribute("href"))&&(strcmp("href", $ra_n)==0)) + { + if(!eregi("[[:graph:]]", $ra_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = "href"; + $error->data->attr = "href"; array_push($errors, $error); - $cont_err++; - } - } - - // if (xml:base) - - if(($figlio->has_attribute("scormType"))||($figlio->has_attribute("scormtype"))) - { - if((strcmp("scormType", $ra_n)==0)||(strcmp("scormtype", $ra_n)==0)) - { - if(!((strcmp("sco", $ra_v)==0)||(strcmp("asset", $ra_v)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + } + + // if (xml:base) + + if(($figlio->has_attribute("scormType"))||($figlio->has_attribute("scormtype"))) + { + if((strcmp("scormType", $ra_n)==0)||(strcmp("scormtype", $ra_n)==0)) + { + if(!((strcmp("sco", $ra_v)==0)||(strcmp("asset", $ra_v)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $ra_n; + $error->data->attr = $ra_n; array_push($errors, $error); - $cont_err++; - } - } - } + $cont_err++; + } + } + } else - { - $error->type = "missing_attribute"; + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->data->attr = "scormType"; + $error->data->attr = "scormType"; array_push($errors, $error); - $cont_err++; - - } + $cont_err++; + + } - if(($figlio->has_attribute("persistState"))&&(strcmp("persistState", $ra_n)==0)) - { - if(!eregi("[0-1]", $ra_v)) - { - $error->type = "attr_error"; + if(($figlio->has_attribute("persistState"))&&(strcmp("persistState", $ra_n)==0)) + { + if(!eregi("[0-1]", $ra_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $ra_n; + $error->data->attr = $ra_n; array_push($errors, $error); - $cont_err++; - } - } - } - - } + $cont_err++; + } + } + } + + } - if($nome_figlio == "file") - { - if(!$figlio->has_attributes()) - { - $error->type = "no_attributes"; + if($nome_figlio == "file") + { + if(!$figlio->has_attributes()) + { + $error->type = "no_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - - $file_attr = $figlio->attributes(); - if(($figlio->has_attribute("href"))&&($file_attr[0]->node_name() == "href")) - { - if(!eregi("[[:print:]]\.[a-z]", $file_attr[0]->node_value())) + $cont_err++; + } + + $file_attr = $figlio->attributes(); + if(($figlio->has_attribute("href"))&&($file_attr[0]->node_name() == "href")) + { + if(!eregi("[[:print:]]\.[a-z]", $file_attr[0]->node_value())) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = "href"; + $error->data->attr = "href"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - //else echo "SCANSIONE TAG FILE TERMINATA, OK \n"; - } - else - { - $error->type = "missing_attribute"; + //else echo "SCANSIONE TAG FILE TERMINATA, OK \n"; + } + else + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->data->attr = "href"; + $error->data->attr = "href"; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($nome_figlio == "dependency") - { - if(strcmp("resource", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "dependency") + { + if(strcmp("resource", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if(!$figlio->has_attributes()) - { - $error->type = "no_attributes"; + $cont_err++; + } + if(!$figlio->has_attributes()) + { + $error->type = "no_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - $dep_attr = $figlio->attributes(); - if(($figlio->has_attribute("identifierref"))&&($dep_attr[0]->node_name() == "identifierref")) - { - // Per valutare il valore di dependency uso l'espressione regolare [[:graph:]] - // che rappresenta tutti i caratteri ASCII stampabili, escluso lo spazio. + $cont_err++; + } + $dep_attr = $figlio->attributes(); + if(($figlio->has_attribute("identifierref"))&&($dep_attr[0]->node_name() == "identifierref")) + { + // Per valutare il valore di dependency uso l'espressione regolare [[:graph:]] + // che rappresenta tutti i caratteri ASCII stampabili, escluso lo spazio. - if(!eregi("[[:graph:]]", $dep_attr[0]->node_value())) - { - $error->type = "attr_error"; + if(!eregi("[[:graph:]]", $dep_attr[0]->node_value())) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = "identifierref"; + $error->data->attr = "identifierref"; array_push($errors, $error); - $cont_err++; - } - //else echo "SCANSIONE TAG DEPENDENCY TERMINATA \n"; - } else { - $error->type = "missing_attribute"; + $cont_err++; + } + //else echo "SCANSIONE TAG DEPENDENCY TERMINATA \n"; + } else { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->data->attr = "identifierref"; + $error->data->attr = "identifierref"; array_push($errors, $error); - } - } + } + } - if(eregi("(CAM[[:blank:]])?[1]\.[3]", $version_value)) - { - if($nome_figlio == "sequencing") - { - if(!((strcmp("item", $padre->node_name())==0)||(strcmp("organization", $padre->node_name())==0))) - { - $error->type = "position_error"; + if(eregi("(CAM[[:blank:]])?[1]\.[3]", $version_value)) + { + if($nome_figlio == "sequencing") + { + if(!((strcmp("item", $padre->node_name())==0)||(strcmp("organization", $padre->node_name())==0))) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - - $seq_attr = $figlio->attributes(); - $cont_seq = count($seq_attr); - if($cont_seq > 2) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + + $seq_attr = $figlio->attributes(); + $cont_seq = count($seq_attr); + if($cont_seq > 2) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_seq; $i++) - { - $seq_a = $seq_attr[$i]; - if(($figlio->has_attribute("ID"))&&($seq_a->node_name() == "ID")) - { - if(!eregi("[[:graph:]]", $seq_a->node_value())) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_seq; $i++) + { + $seq_a = $seq_attr[$i]; + if(($figlio->has_attribute("ID"))&&($seq_a->node_name() == "ID")) + { + if(!eregi("[[:graph:]]", $seq_a->node_value())) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = "ID"; + $error->data->attr = "ID"; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if(($figlio->has_attribute("IDRef"))&&($seq_a->node_name() == "IDRef")) - { - if(!eregi("[[:graph:]]", $seq_a->node_value())) + if(($figlio->has_attribute("IDRef"))&&($seq_a->node_name() == "IDRef")) + { + if(!eregi("[[:graph:]]", $seq_a->node_value())) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = "IDRef"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - } - } + } + } + } - if($nome_figlio == "controlMode") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "controlMode") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - - $ctrlM_attr = $figlio->attributes(); - $cont_ctrlM = count($ctrlM_attr); - if($cont_ctrlM > 6) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + + $ctrlM_attr = $figlio->attributes(); + $cont_ctrlM = count($ctrlM_attr); + if($cont_ctrlM > 6) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - - for($i=0; $i < $cont_ctrlM; $i++) - { - $cM_name = $ctrlM_attr[$i]->node_name(); - $cM_val = $ctrlM_attr[$i]->node_value(); - if(($figlio->has_attribute("choice"))&&($cM_name == "choice")) - { - if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + + for($i=0; $i < $cont_ctrlM; $i++) + { + $cM_name = $ctrlM_attr[$i]->node_name(); + $cM_val = $ctrlM_attr[$i]->node_value(); + if(($figlio->has_attribute("choice"))&&($cM_name == "choice")) + { + if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $cM_name; array_push($errors, $error); - $cont_err++; - } - //else "OK CHOICE"; - } - - if(($figlio->has_attribute("choiceExit"))&&($cM_name == "choiceExit")) + $cont_err++; + } + //else "OK CHOICE"; + } + + if(($figlio->has_attribute("choiceExit"))&&($cM_name == "choiceExit")) { if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $cM_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - - if(($figlio->has_attribute("flow"))&&($cM_name == "flow")) + + if(($figlio->has_attribute("flow"))&&($cM_name == "flow")) { if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $cM_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if(($figlio->has_attribute("forwardOnly"))&&($cM_name == "forwardOnly")) + if(($figlio->has_attribute("forwardOnly"))&&($cM_name == "forwardOnly")) { if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $cM_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if(($figlio->has_attribute("01"))&&($cM_name == "01")) + if(($figlio->has_attribute("01"))&&($cM_name == "01")) { if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $cM_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if(($figlio->has_attribute("02"))&&($cM_name == "02")) + if(($figlio->has_attribute("02"))&&($cM_name == "02")) { if(!((strcmp("true", $cM_val)==0)||(strcmp("false", $cM_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $cM_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - }// END FOR - - } - - if($nome_figlio == "sequencingRules") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; + }// END FOR + + } + + if($nome_figlio == "sequencingRules") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - } - - if($nome_figlio == "preConditionRule") + $cont_err++; + } + } + + if($nome_figlio == "preConditionRule") { if(strcmp("sequencingRules", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - $preCo_children = $figlio->child_nodes(); - + $preCo_children = $figlio->child_nodes(); + } - if($nome_figlio == "postConditionRule") + if($nome_figlio == "postConditionRule") { if(strcmp("sequencingRules", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - + } - if($nome_figlio == "exitConditionRule") + if($nome_figlio == "exitConditionRule") { if(strcmp("sequencingRules", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - + } - if($nome_figlio == "ruleConditions") - { - - if(!((strcmp("preConditionRule", $padre->node_name())==0) - ||(strcmp("postConditionRule", $padre->node_name())==0) - ||(strcmp("exitConditionRule", $padre->node_name())==0))) + if($nome_figlio == "ruleConditions") + { + + if(!((strcmp("preConditionRule", $padre->node_name())==0) + ||(strcmp("postConditionRule", $padre->node_name())==0) + ||(strcmp("exitConditionRule", $padre->node_name())==0))) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - - if($figlio->has_attributes()) - { - $rCs_attr = $figlio->attributes(); - if($rCs_attr[0]->node_name()=="conditionCombination") - { - if(!((strcmp("all", $rCs[0]->node_value())==0)||(strcmp("any", $rCs[0]->node_value())==0))) - { - $error->type = "attr_error"; + + if($figlio->has_attributes()) + { + $rCs_attr = $figlio->attributes(); + if($rCs_attr[0]->node_name()=="conditionCombination") + { + if(!((strcmp("all", $rCs[0]->node_value())==0)||(strcmp("any", $rCs[0]->node_value())==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = "conditionCombination"; + $error->data->attr = "conditionCombination"; array_push($errors, $error); - $cont_err++; - } - } - } - //echo "SCANSIONE TAG RULESCONDITIONS TERMINATA"; - } + $cont_err++; + } + } + } + //echo "SCANSIONE TAG RULESCONDITIONS TERMINATA"; + } - if($nome_figlio == "ruleCondition") - { - if(strcmp("ruleConditions", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "ruleCondition") + { + if(strcmp("ruleConditions", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } + $cont_err++; + } - if($figlio->has_attributes()) - { - $rC_attr = $figlio->attributes(); - $cont_rC = count($rC_attr); - if($cont_rC > 4) - { - $error->type = "too_many_attributes"; + if($figlio->has_attributes()) + { + $rC_attr = $figlio->attributes(); + $cont_rC = count($rC_attr); + if($cont_rC > 4) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_rC; $i++) - { - $rCa_name = $rC_attr[$i]->node_name(); - $rCa_val = $rC_attr[$i]->node_value(); - if($rCa_name == "referencedObjective") - { - if(!eregi("[[:graph:]]", $rCa_val)) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_rC; $i++) + { + $rCa_name = $rC_attr[$i]->node_name(); + $rCa_val = $rC_attr[$i]->node_value(); + if($rCa_name == "referencedObjective") + { + if(!eregi("[[:graph:]]", $rCa_val)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $rCa_name; + $error->data->attr = $rCa_name; array_push($errors, $error); - $cont_err++; - } - } - - if($rCa_name == "measureThreshold") - { - settype($rCa_val, "float"); - if(($rCa_val < -1.0000)||($rCa_val > 1.0000)) - { - $error->type = "attr_error"; + $cont_err++; + } + } + + if($rCa_name == "measureThreshold") + { + settype($rCa_val, "float"); + if(($rCa_val < -1.0000)||($rCa_val > 1.0000)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $rCa_name; + $error->data->attr = $rCa_name; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($rCa_name == "operator") - { - if((!eregi("not", $rCa_val))||(!eregi("noOp", $rCa_val))) - { - $error->type = "attr_error"; + if($rCa_name == "operator") + { + if((!eregi("not", $rCa_val))||(!eregi("noOp", $rCa_val))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rCa_name; array_push($errors, $error); - $cont_err++; - } - } - - if($rCa_name == "condition") - { - if(!is_cond_val($rCa_val)) - { - $error->type = "attr_error"; + $cont_err++; + } + } + + if($rCa_name == "condition") + { + if(!is_cond_val($rCa_val)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rCa_name; array_push($errors, $error); - $cont_err++; - } - } - }// END FOR - } - } + $cont_err++; + } + } + }// END FOR + } + } - if($nome_figlio == "ruleAction") - { - if($padre->node_name() == "preConditionRule") - { - if(($figlio->has_attributes())&&($figlio->has_attribute("action"))) - { - $rAc_attr1 = $figlio->attributes(); - if($rAc_attr1[0]->node_name() != "action") - { - $error->type = "missing_attribute"; + if($nome_figlio == "ruleAction") + { + if($padre->node_name() == "preConditionRule") + { + if(($figlio->has_attributes())&&($figlio->has_attribute("action"))) + { + $rAc_attr1 = $figlio->attributes(); + if($rAc_attr1[0]->node_name() != "action") + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; - } - elseif(!is_action1($rAc_attr1[0]->node_value())) - { - $error->type = "attr_error"; + $cont_err++; + } + elseif(!is_action1($rAc_attr1[0]->node_value())) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; - } - - } - else - { - $error->type = "missing_attribute"; + $cont_err++; + } + + } + else + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; - } - } - - elseif($padre->node_name() == "postConditionRule") + $cont_err++; + } + } + + elseif($padre->node_name() == "postConditionRule") { if(($figlio->has_attributes())&&($figlio->has_attribute("action"))) { $rAc_attr2 = $figlio->attributes(); if($rAc_attr2[0]->node_name() != "action") { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } elseif(!is_action2($rAc_attr2[0]->node_value())) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - + } else { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - - elseif($padre->node_name() == "exitConditionRule") + + elseif($padre->node_name() == "exitConditionRule") { if(($figlio->has_attributes())&&($figlio->has_attribute("action"))) { $rAc_attr3 = $figlio->attributes(); if($rAc_attr3[0]->node_name() != "action") { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } elseif($rAc_attr3[0]->node_value() != "exit") { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } } else { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - else - { - $error->type = "position_error"; + else + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($nome_figlio == "limitConditions") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "limitConditions") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) - { - $lAc_attr = $figlio->attributes(); - $cont_lAc = count($lAc_attr); - if($cont_lAc > 2) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + if($figlio->has_attributes()) + { + $lAc_attr = $figlio->attributes(); + $cont_lAc = count($lAc_attr); + if($cont_lAc > 2) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_lAc; $i++) - { - $lAc_name = $lAc_attr[$i]->node_name(); - $lAc_val = $lAc_attr[$i]->node_value(); - if(($figlio->has_attribute("attemptLimit"))&&($lAc_name == "attemptLimit")) - { - settype($lAc_val, "int"); - if($lAc_val < 0) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_lAc; $i++) + { + $lAc_name = $lAc_attr[$i]->node_name(); + $lAc_val = $lAc_attr[$i]->node_value(); + if(($figlio->has_attribute("attemptLimit"))&&($lAc_name == "attemptLimit")) + { + settype($lAc_val, "int"); + if($lAc_val < 0) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $lAc_name; + $error->data->attr = $lAc_name; array_push($errors, $error); - $cont_err++; - } - } - if($lAc_name == "attemptAbsoluteDurationLimit") - { - if(!eregi("[P][[:digit:]][Y][0-9][M][0-9][D][0-9][H][0-60][M][0-60][S]", $lAc_val)) + $cont_err++; + } + } + if($lAc_name == "attemptAbsoluteDurationLimit") + { + if(!eregi("[P][[:digit:]][Y][0-9][M][0-9][D][0-9][H][0-60][M][0-60][S]", $lAc_val)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $lAc_val; + $error->data->attr = $lAc_val; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - } - } - } - - if($nome_figlio == "auxiliaryResources") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; + } + } + } + } + + if($nome_figlio == "auxiliaryResources") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - - } + $cont_err++; + } + + } - if($nome_figlio == "auxiliaryResource") - { - if(strcmp("auxiliaryResources", $padre->node_name())!=0) + if($nome_figlio == "auxiliaryResource") + { + if(strcmp("auxiliaryResources", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - if($figlio->has_attributes()) - { - $aux_attr = $figlio->attributes(); - $cont_aux = count($aux_attr); - if($cont_aux != 2) - { - $error->type = "too_many_attributes"; + if($figlio->has_attributes()) + { + $aux_attr = $figlio->attributes(); + $cont_aux = count($aux_attr); + if($cont_aux != 2) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_aux; $i++) - { - $aux_n = $aux_attr[$i]->node_name(); - $aux_v = $aux_attr[$i]->node_value(); - if((strcmp("auxiliaryResourceID", $aux_n)!=0)&&(strcmp("purpose", $aux_n)!=0)) - { - $error->type = "missing_attribute"; + $cont_err++; + } + for($i=0; $i < $cont_aux; $i++) + { + $aux_n = $aux_attr[$i]->node_name(); + $aux_v = $aux_attr[$i]->node_value(); + if((strcmp("auxiliaryResourceID", $aux_n)!=0)&&(strcmp("purpose", $aux_n)!=0)) + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->data->attr = $aux_n; + $error->data->attr = $aux_n; array_push($errors, $error); - $cont_err++; - } - elseif($aux_n == "auxiliaryResourceID") - { - if(!eregi("[[:graph:]]", $aux_v)) - { - $error->type = "attr_error"; + $cont_err++; + } + elseif($aux_n == "auxiliaryResourceID") + { + if(!eregi("[[:graph:]]", $aux_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $aux_n; array_push($errors, $error); - $cont_err++; - } - } - elseif($aux_n == "purpose") - { - if(!eregi("[[:graph:]]", $aux_v)) + $cont_err++; + } + } + elseif($aux_n == "purpose") + { + if(!eregi("[[:graph:]]", $aux_v)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $aux_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - } - }//echo "SCANSIONE TAG AUXILIARYRESOURCE TERMINATA"; - } - - if($nome_figlio == "rollupRules") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; + } + } + }//echo "SCANSIONE TAG AUXILIARYRESOURCE TERMINATA"; + } + + if($nome_figlio == "rollupRules") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) - { - $rules_attr = $figlio->attributes(); - $cont_rules = count($rules_attr); - if($cont_rules > 3) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + if($figlio->has_attributes()) + { + $rules_attr = $figlio->attributes(); + $cont_rules = count($rules_attr); + if($cont_rules > 3) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_rules; $i++) - { - $rules_nome = $rules_attr[$i]->node_name(); - $rules_val = $rules_attr[$i]->node_value(); - if($rules_nome == "rollupObjectiveSatisfied") - { - if(!((strcmp("true", $rules_val)==0)||(strcmp("false", $rules_val)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_rules; $i++) + { + $rules_nome = $rules_attr[$i]->node_name(); + $rules_val = $rules_attr[$i]->node_value(); + if($rules_nome == "rollupObjectiveSatisfied") + { + if(!((strcmp("true", $rules_val)==0)||(strcmp("false", $rules_val)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $rules_nome; - array_push($errors, $error); - //echo "ERROR, rollupObjectiveSatisfied puo'assumere solo valori booleani"; - $cont_err++; - } - } - if($rules_nome == "rollupProgressCompletion") - { - if(!((strcmp("true", $rules_val)==0)||(strcmp("false", $rules_val)==0))) + $error->data->attr = $rules_nome; + array_push($errors, $error); + //echo "ERROR, rollupObjectiveSatisfied puo'assumere solo valori booleani"; + $cont_err++; + } + } + if($rules_nome == "rollupProgressCompletion") + { + if(!((strcmp("true", $rules_val)==0)||(strcmp("false", $rules_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rules_nome; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - if($rules_nome == "objectiveMeasureWeight") - { - settype($rules_val, "float"); - if(($rules_val < 0.0000)||($rules_val > 1.0000)) - { - $error->type = "attr_error"; + } + if($rules_nome == "objectiveMeasureWeight") + { + settype($rules_val, "float"); + if(($rules_val < 0.0000)||($rules_val > 1.0000)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rules_nome; array_push($errors, $error); - $cont_err++; - } - } - }//END FOR - }//echo "SCANSIONE TAG ROLLUPRULES TERMINATA"; - }// END ROLLUPRULES + $cont_err++; + } + } + }//END FOR + }//echo "SCANSIONE TAG ROLLUPRULES TERMINATA"; + }// END ROLLUPRULES - if($nome_figlio == "rollupRule") - { - if(strcmp("rollupRules", $padre->node_name())!= 0) - { - $error->type = "position_error"; + if($nome_figlio == "rollupRule") + { + if(strcmp("rollupRules", $padre->node_name())!= 0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) - { - $rule_attr = $figlio->attributes(); - $cont_rule = count($rule_attr); - if($cont_rule > 3) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + if($figlio->has_attributes()) + { + $rule_attr = $figlio->attributes(); + $cont_rule = count($rule_attr); + if($cont_rule > 3) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_rule; $i++) - { - $rule_name = $rule_attr[$i]->node_name(); - $rule_val = $rule_attr[$i]->node_value(); - if($rule_name == "childActivitySet") - { - if(!((strcmp("all", $rule_val)==0)||(strcmp("any", $rule_val)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_rule; $i++) + { + $rule_name = $rule_attr[$i]->node_name(); + $rule_val = $rule_attr[$i]->node_value(); + if($rule_name == "childActivitySet") + { + if(!((strcmp("all", $rule_val)==0)||(strcmp("any", $rule_val)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rule_nome; array_push($errors, $error); - $cont_err++; - } - } - if($rule_name == "minimumCount") - { - settype($rule_val, "int"); - if($rule_val < 0) - { - $error->type = "attr_error"; + $cont_err++; + } + } + if($rule_name == "minimumCount") + { + settype($rule_val, "int"); + if($rule_val < 0) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rule_nome; array_push($errors, $error); - $cont_err++; - } - } - if($rule_name == "minimumPercent") + $cont_err++; + } + } + if($rule_name == "minimumPercent") { - settype($rule_val, "float"); + settype($rule_val, "float"); if(($rule_val < 0.0000)||($rule_val > 1.0000)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rules_nome; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - } - }//echo "SCANSIONE TAG ROLLUPRULE TERMINATA"; - } + } + }//echo "SCANSIONE TAG ROLLUPRULE TERMINATA"; + } - if($nome_figlio == "rollupConditions") - { - if(strcmp("rollupRule", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "rollupConditions") + { + if(strcmp("rollupRule", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if(($figlio->has_attributes())&&($figlio->has_attribute("conditionCombination"))) - { - $rCo_attr = $figlio->attributes(); - $rCo_name = $rCo_attr[0]->node_name(); - $rCo_val = $rCo_attr[0]->node_val(); + $cont_err++; + } + if(($figlio->has_attributes())&&($figlio->has_attribute("conditionCombination"))) + { + $rCo_attr = $figlio->attributes(); + $rCo_name = $rCo_attr[0]->node_name(); + $rCo_val = $rCo_attr[0]->node_val(); if($rCo_name != "conditionCombination") { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = $rCo_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } elseif(!((strcmp("all", $rCo_val)==0)||(strcmp("any", $rCo_val)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rCo_name; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - //echo "SCANSIONE TAG ROLLUPCONDITIONS TERMINATA"; - } - - if($nome_figlio == "rollupCondition") - { - if(strcmp("rollupConditions", $padre->node_name())!=0) - { - $error->type = "position_error"; + } + //echo "SCANSIONE TAG ROLLUPCONDITIONS TERMINATA"; + } + + if($nome_figlio == "rollupCondition") + { + if(strcmp("rollupConditions", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) - { - $rCond_attr = $figlio->attributes(); - $cont_rCond = count($rCond_attr); - if($cont_rCond > 2) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + if($figlio->has_attributes()) + { + $rCond_attr = $figlio->attributes(); + $cont_rCond = count($rCond_attr); + if($cont_rCond > 2) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_rCond; $i++) - { - $rCond_n = $rCond_attr[$i]->node_name(); - $rCond_v = $rCond_attr[$i]->node_value(); - if($rCond_n == "operator") - { - if(!((strcmp("not", $rCond_v)==0)||(strcmp("noOp", $rCond_v)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_rCond; $i++) + { + $rCond_n = $rCond_attr[$i]->node_name(); + $rCond_v = $rCond_attr[$i]->node_value(); + if($rCond_n == "operator") + { + if(!((strcmp("not", $rCond_v)==0)||(strcmp("noOp", $rCond_v)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rCond_n; array_push($errors, $error); - $cont_err++; - } - } - elseif($rCond_n == "condition") - { - if(!is_rcond_val($rCond_v)) - { - $error->type = "attr_error"; + $cont_err++; + } + } + elseif($rCond_n == "condition") + { + if(!is_rcond_val($rCond_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rCond_n; array_push($errors, $error); - $cont_err++; - } - } - else - { - $error->type = "missing_attribute"; + $cont_err++; + } + } + else + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "condition"; array_push($errors, $error); - $cont_err++; - } - } - } - else - { - $error->type = "no_attributes"; + $cont_err++; + } + } + } + else + { + $error->type = "no_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - } - - if($nome_figlio == "rollupAction") - { - if(strcmp("rollupRule", $padre->node_name())!=0) - { - $error->type = "position_error"; + $cont_err++; + } + } + + if($nome_figlio == "rollupAction") + { + if(strcmp("rollupRule", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if(($figlio->has_attributes())&&($figlio->has_attribute("action"))) + $cont_err++; + } + if(($figlio->has_attributes())&&($figlio->has_attribute("action"))) { $roAc_attr = $figlio->attributes(); if($roAc_attr[0]->node_name() != "action") { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } elseif(!is_rolAc_val($roAc_attr[0]->node_value())) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } } else { - $error->type = "missing_attribute"; + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "action"; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } + } - if($nome_figlio == "objectives") + if($nome_figlio == "objectives") { if(strcmp("sequencing", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } } - - if($nome_figlio == "primaryObjective") - { - if(strcmp("objectives", $padre->node_name())!=0) + + if($nome_figlio == "primaryObjective") + { + if(strcmp("objectives", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - if($figlio->has_attributes()) - { - $prObj_attr = $figlio->attributes(); - $cont_prObj = count($prObj_attr); - if($cont_prObj > 2) - { - $error->type = "too_many_attributes"; + if($figlio->has_attributes()) + { + $prObj_attr = $figlio->attributes(); + $cont_prObj = count($prObj_attr); + if($cont_prObj > 2) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_prObj; $i++) - { - $pro_n = $prObj_attr[$i]->node_name(); - $pro_v = $prObj_attr[$i]->node_value(); - if($pro_n == "satisfiedByMeasure") - { - if(!((strcmp("true", $pro_v)==0)||(strcmp("false", $pro_v)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_prObj; $i++) + { + $pro_n = $prObj_attr[$i]->node_name(); + $pro_v = $prObj_attr[$i]->node_value(); + if($pro_n == "satisfiedByMeasure") + { + if(!((strcmp("true", $pro_v)==0)||(strcmp("false", $pro_v)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $pro_n; + $error->data->attr = $pro_n; array_push($errors, $error); - $cont_err++; - } - } - if($pro_n == "objectiveID") - { - if(!eregi("[[:graph:]]", $pro_v)) - { - $error->type = "attr_error"; + $cont_err++; + } + } + if($pro_n == "objectiveID") + { + if(!eregi("[[:graph:]]", $pro_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $pro_n; array_push($errors, $error); - $cont_err++; - } - } - } - } - } - - if($nome_figlio == "minNormalizedMeasure") - { - $fn = $padre->node_name(); + $cont_err++; + } + } + } + } + } + + if($nome_figlio == "minNormalizedMeasure") + { + $fn = $padre->node_name(); if(!((strcmp("primaryObjective", $fn)==0)||(strcmp("objective", $fn)==0))) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - if($figlio->has_child_nodes()) - { - $figlio1 = $figlio->first_child(); - if($figlio1->node_type() != 3) - { - $error->type = "not_corr_type"; + if($figlio->has_child_nodes()) + { + $figlio1 = $figlio->first_child(); + if($figlio1->node_type() != 3) + { + $error->type = "not_corr_type"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - settype($figlio1->get_content(), "float"); - if(($figlio1->get_content() < 0.0)||($figlio1->get_content() > 1.0)) - { - $error->type = "tag_error"; + $cont_err++; + } + settype($figlio1->get_content(), "float"); + if(($figlio1->get_content() < 0.0)||($figlio1->get_content() > 1.0)) + { + $error->type = "tag_error"; $error->data->tag = $nome_figlio; $error->data->value = $figlio1->get_content(); array_push($errors, $error); - $cont_err++; - } - } - else - { - $error->type = "tag_error"; + $cont_err++; + } + } + else + { + $error->type = "tag_error"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($nome_figlio == "mapInfo") - { - $pn = $padre->node_name(); + if($nome_figlio == "mapInfo") + { + $pn = $padre->node_name(); if(!((strcmp("primaryObjective", $pn)==0)||(strcmp("objective", $pn)==0))) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } - if($figlio->has_attributes()) - { - $map_attr = $figlio->attributes(); - $cont_map = count($map_attr); - if($cont_map > 5) - { - $error->type = "too_many_attributes"; + if($figlio->has_attributes()) + { + $map_attr = $figlio->attributes(); + $cont_map = count($map_attr); + if($cont_map > 5) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - if(!$figlio->has_attribute("targetObjectiveID")) - { - $error->type = "missing_attribute"; + $cont_err++; + } + if(!$figlio->has_attribute("targetObjectiveID")) + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; - $error->data->attr = "targetObjectiveID"; + $error->data->attr = "targetObjectiveID"; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_map; $i++) - { - $map_n = $map_attr[$i]->node_name(); - $map_v = $map_attr[$i]->node_value(); - if($map_n == "targetObjectiveID") - { - if(!eregi("[[:graph:]]", $map_v)) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_map; $i++) + { + $map_n = $map_attr[$i]->node_name(); + $map_v = $map_attr[$i]->node_value(); + if($map_n == "targetObjectiveID") + { + if(!eregi("[[:graph:]]", $map_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = "targetObjectiveID"; array_push($errors, $error); - $cont_err++; - } - } - if($map_n == "readSatisfiedStatus") - { - if(!((strcmp("true", $map_v)==0)||(strcmp("false", $map_v)==0))) + $cont_err++; + } + } + if($map_n == "readSatisfiedStatus") + { + if(!((strcmp("true", $map_v)==0)||(strcmp("false", $map_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $map_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - if($map_n == "readNormalizedMeasure") - { + } + if($map_n == "readNormalizedMeasure") + { if(!((strcmp("true", $map_v)==0)||(strcmp("false", $map_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $map_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if($map_n == "writeSatisfiedStatus") - { + if($map_n == "writeSatisfiedStatus") + { if(!((strcmp("true", $map_v)==0)||(strcmp("false", $map_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $map_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if($map_n == "writeNormalizedMeasure") - { - if(!((strcmp("true", $map_v)==0)||(strcmp("false", $map_v)==0))) + if($map_n == "writeNormalizedMeasure") + { + if(!((strcmp("true", $map_v)==0)||(strcmp("false", $map_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $map_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - }// END FOR - } + } + }// END FOR + } else - { - $error->type = "missing_attribute"; + { + $error->type = "missing_attribute"; $error->data->tag = $nome_figlio; $error->data->attr = "targetObjectiveID"; array_push($errors, $error); - $cont_err++; - } - - } - - if($nome_figlio == "objective") + $cont_err++; + } + + } + + if($nome_figlio == "objective") { if(strcmp("objectives", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; + $cont_err++; } if($figlio->has_attributes()) { @@ -2082,10 +2082,10 @@ function testNode($DomNode) $cont_obj = count($obj_attr); if($cont_obj > 2) { - $error->type = "too_many_attributes"; + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; + $cont_err++; } for($i=0; $i < $cont_obj; $i++) { @@ -2095,184 +2095,184 @@ function testNode($DomNode) { if(!((strcmp("true", $ob_v)==0)||(strcmp("false", $ob_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; - $error->data->attr = $ob_n; + $error->data->attr = $ob_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } if($ob_n == "objectiveID") { if(!eregi("[[:graph:]]", $ob_v)) - { - $error->type = "attr_error"; + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $ob_n; array_push($errors, $error); - $cont_err++; - } + $cont_err++; + } } } } } - - if($nome_figlio == "randomizationControls") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; + + if($nome_figlio == "randomizationControls") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) - { - $rand_attr = $figlio->attributes(); - $cont_rand = count($rand_attr); - if($cont_rand > 4) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + if($figlio->has_attributes()) + { + $rand_attr = $figlio->attributes(); + $cont_rand = count($rand_attr); + if($cont_rand > 4) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_rand; $i++) - { - $rAt_n = $rand_attr[$i]->node_name(); - $rAt_v = $rand_attr[$i]->node_value(); - if($rAt_n == "randomizationTiming") - { - if(!is_randT_attr($rAt_v)) - { - $error->type = "attr_error"; + $cont_err++; + } + for($i=0; $i < $cont_rand; $i++) + { + $rAt_n = $rand_attr[$i]->node_name(); + $rAt_v = $rand_attr[$i]->node_value(); + if($rAt_n == "randomizationTiming") + { + if(!is_randT_attr($rAt_v)) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rAt_n; array_push($errors, $error); - $cont_err++; - } - } - if($rAt_n == "selectCount") - { - setttype($rAt_v, "int"); - if($rAt_v < 0) - { - $error->type = "attr_error"; + $cont_err++; + } + } + if($rAt_n == "selectCount") + { + setttype($rAt_v, "int"); + if($rAt_v < 0) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rAt_n; array_push($errors, $error); - $cont_err++; - } - } - if($rAt_n == "reorderChildren") - { - if(!((strcmp("true", $rAt_v)==0)||(strcmp("false", $rAt_v)==0))) - { - $error->type = "attr_error"; + $cont_err++; + } + } + if($rAt_n == "reorderChildren") + { + if(!((strcmp("true", $rAt_v)==0)||(strcmp("false", $rAt_v)==0))) + { + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rAt_n; array_push($errors, $error); - $cont_err++; - } - } - if($rAt_v == "selectionTiming") - { - if(!is_randT_attr($rAt_v)) + $cont_err++; + } + } + if($rAt_v == "selectionTiming") + { + if(!is_randT_attr($rAt_v)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rAt_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - } - }//echo "SCANSIONE TAG RANDOMIZATION CONTROLS TERMINATA"; - } - - if($nome_figlio == "deliveryControls") - { - if(strcmp("sequencing", $padre->node-name())!=0) - { - $error->type = "position_error"; - $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) - { - $delv_attr = $figlio->attributes(); - $cont_delv = count($delv_attr); - if($cont_delv > 3) - { - $error->type = "too_many_attributes"; - $error->data->tag = $nome_figlio; - array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_delv; $i++) - { - $delv_n = $delv_attr[$i]->node_name(); - $delv_v + $delv_attr[$i]->node_value(); - if($delv_n == "tracked") - { - if(!((strcmp("true", $delv_v)==0)||(strcmp("false", $delv_v)==0))) + } + } + }//echo "SCANSIONE TAG RANDOMIZATION CONTROLS TERMINATA"; + } + + if($nome_figlio == "deliveryControls") + { + if(strcmp("sequencing", $padre->node-name())!=0) + { + $error->type = "position_error"; + $error->data->tag = $nome_figlio; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + if($figlio->has_attributes()) + { + $delv_attr = $figlio->attributes(); + $cont_delv = count($delv_attr); + if($cont_delv > 3) + { + $error->type = "too_many_attributes"; + $error->data->tag = $nome_figlio; + array_push($errors, $error); + $cont_err++; + } + for($i=0; $i < $cont_delv; $i++) + { + $delv_n = $delv_attr[$i]->node_name(); + $delv_v + $delv_attr[$i]->node_value(); + if($delv_n == "tracked") + { + if(!((strcmp("true", $delv_v)==0)||(strcmp("false", $delv_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $delv_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - if($delv_n == "completionSetByContent") - { - if(!((strcmp("true", $delv_v)==0)||(strcmp("false", $delv_v)==0))) + } + if($delv_n == "completionSetByContent") + { + if(!((strcmp("true", $delv_v)==0)||(strcmp("false", $delv_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $delv_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - if($delv_n == "objectiveSetByContent") - { - if(!((strcmp("true", $delv_v)==0)||(strcmp("false", $delv_v)==0))) + } + if($delv_n == "objectiveSetByContent") + { + if(!((strcmp("true", $delv_v)==0)||(strcmp("false", $delv_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $delv_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } - } - } - }//echo "SCANSIONE TAG DELIVERYCONTROLS COMPLETATA"; - } - - if($nome_figlio == "constrainedChoiceConsiderations") - { - if(strcmp("sequencing", $padre->node_name())!=0) - { - $error->type = "position_error"; - $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - if($figlio->has_attributes()) + } + } + }//echo "SCANSIONE TAG DELIVERYCONTROLS COMPLETATA"; + } + + if($nome_figlio == "constrainedChoiceConsiderations") + { + if(strcmp("sequencing", $padre->node_name())!=0) + { + $error->type = "position_error"; + $error->data->tag = $nome_figlio; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + if($figlio->has_attributes()) { $ccc_attr = $figlio->attributes(); $cont_ccc = count($ccc_attr); if($cont_ccc > 2) { - $error->type = "too_many_attributes"; - $error->data->tag = $nome_figlio; - array_push($errors, $error); - $cont_err++; + $error->type = "too_many_attributes"; + $error->data->tag = $nome_figlio; + array_push($errors, $error); + $cont_err++; } for($i=0; $i < $cont_ccc; $i++) { @@ -2282,48 +2282,48 @@ function testNode($DomNode) { if(!((strcmp("true", $ccc_v)==0)||(strcmp("false", $ccc_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $ccc_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } if($ccc_n == "constrainChoice") { if(!((strcmp("true", $ccc_v)==0)||(strcmp("false", $ccc_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $ccc_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - } + } } - } + } - if($nome_figlio == "rollupConsiderations") - { - if(strcmp("sequencing", $padre->node_name())!=0) + if($nome_figlio == "rollupConsiderations") + { + if(strcmp("sequencing", $padre->node_name())!=0) { - $error->type = "position_error"; - $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; + $error->type = "position_error"; + $error->data->tag = $nome_figlio; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; } - if($figlio->has_attributes()) + if($figlio->has_attributes()) { $rolCo_attr = $figlio->attributes(); $cont_rolCo = count($rolCo_attr); if($cont_rolCo > 5) { - $error->type = "too_many_attributes"; + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; + $cont_err++; } for($i=0; $i < $cont_rolCo; $i++) { @@ -2333,134 +2333,134 @@ function testNode($DomNode) { if(!((strcmp("true", $rolCo_v)==0)||(strcmp("false", $rolCo_v)==0))) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rolCo_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } if($rolCo_n == "requiredForSatisfied") { if(!is_rolCo_val($rolCo_v)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rolCo_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if($rolCo_n == "requiredForNotSatisfied") + if($rolCo_n == "requiredForNotSatisfied") { if(!is_rolCo_val($rolCo_v)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rolCo_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if($rolCo_n == "requiredForCompleted") + if($rolCo_n == "requiredForCompleted") { if(!is_rolCo_val($rolCo_v)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rolCo_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } - if($rolCo_n == "requiredForIncomplete") + if($rolCo_n == "requiredForIncomplete") { if(!is_rolCo_val($rolCo_v)) { - $error->type = "attr_error"; + $error->type = "attr_error"; $error->data->tag = $nome_figlio; $error->data->attr = $rolCo_n; array_push($errors, $error); - $cont_err++; + $cont_err++; } } } - } - } - - if($nome_figlio == "presentation") - { - if(strcmp("item", $padre->node_name())!=0) - { - $error->type = "position_error"; - $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); - array_push($errors, $error); - $cont_err++; - } - } + } + } + + if($nome_figlio == "presentation") + { + if(strcmp("item", $padre->node_name())!=0) + { + $error->type = "position_error"; + $error->data->tag = $nome_figlio; + $error->data->parent = $padre->node_name(); + array_push($errors, $error); + $cont_err++; + } + } - if($nome_figlio == "navigationInterface") - { - if(strcmp("presentation", $padre->node_name())!=0) + if($nome_figlio == "navigationInterface") + { + if(strcmp("presentation", $padre->node_name())!=0) { - $error->type = "position_error"; + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - } + $cont_err++; + } + } - if($nome_figlio == "hideLMSUI") - { - if(strcmp("navigationInterface", $padre->node_name())!=0) - { - $error->type = "position_error"; + if($nome_figlio == "hideLMSUI") + { + if(strcmp("navigationInterface", $padre->node_name())!=0) + { + $error->type = "position_error"; $error->data->tag = $nome_figlio; - $error->data->parent = $padre->node_name(); + $error->data->parent = $padre->node_name(); array_push($errors, $error); - $cont_err++; - } - if($figlio->has_child_nodes()) - { - $hide_children = $figlio->child_nodes(); - $cont_hide = count($hide_children); - if($cont_hide > 4) - { - $error->type = "too_many_attributes"; + $cont_err++; + } + if($figlio->has_child_nodes()) + { + $hide_children = $figlio->child_nodes(); + $cont_hide = count($hide_children); + if($cont_hide > 4) + { + $error->type = "too_many_attributes"; $error->data->tag = $nome_figlio; array_push($errors, $error); - $cont_err++; - } - for($i=0; $i < $cont_hide; $i++) - { - $hch_t = $hide_children[$i]->node_type(); - $hch_cont = $hide_children[$i]->get_content(); - if(($hch_t == 3)&&(is_hch_cont($hch_cont))) - { - //echo "OK, SCANSIONE TAG HIDELMSUI TERMINATA"; - } - else - { - $error->type = "tag_error"; + $cont_err++; + } + for($i=0; $i < $cont_hide; $i++) + { + $hch_t = $hide_children[$i]->node_type(); + $hch_cont = $hide_children[$i]->get_content(); + if(($hch_t == 3)&&(is_hch_cont($hch_cont))) + { + //echo "OK, SCANSIONE TAG HIDELMSUI TERMINATA"; + } + else + { + $error->type = "tag_error"; $error->data->tag = $nome_figlio; - $error->data->value = $hch_cont; + $error->data->value = $hch_cont; array_push($errors, $error); - $cont_err++; - } - } - } - } - } + $cont_err++; + } + } + } + } + } - }// END IF FIGLIO - if($figlio->has_child_nodes()) - { - testNode($figlio); //Ricorsione sui nodi figli - } - $figlio = $figlio->next_sibling(); - } + }// END IF FIGLIO + if($figlio->has_child_nodes()) + { + testNode($figlio); //Ricorsione sui nodi figli + } + $figlio = $figlio->next_sibling(); + } } if(count($errors) > 0) diff --git a/mod/scorm/view.php b/mod/scorm/view.php index bd198490b55..2b89a4a1e41 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -37,12 +37,12 @@ require_login($course->id, false, $cm); if (isset($SESSION->scorm_scoid)) { - unset($SESSION->scorm_scoid); + unset($SESSION->scorm_scoid); } $strscorms = get_string("modulenameplural", "scorm"); $strscorm = get_string("modulename", "scorm"); - + if ($course->category) { $navigation = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname -> framename}\" href=\"index.php?id=$course->id\">$strscorms ->"; @@ -59,81 +59,81 @@ // if (!$cm->visible and !isteacher($course->id)) { print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), "", "", true, - update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); + update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); notice(get_string("activityiscurrentlyhidden")); } else { - print_header($pagetitle, "$course->fullname","$navigation framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."", - "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); + print_header($pagetitle, "$course->fullname","$navigation framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."", + "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); - if (isteacher($course->id)) { - if ($trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c')) { - echo ""; + if (isteacher($course->id)) { + if ($trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c')) { + echo ""; } else { - echo "
    ".get_string("noreports","scorm")."
    "; + echo "
    ".get_string("noreports","scorm")."
    "; } - } - // Print the main part of the page + } + // Print the main part of the page - print_heading(format_string($scorm->name)); + print_heading(format_string($scorm->name)); - print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro'); + print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro'); - if (isguest()) { + if (isguest()) { print_heading(get_string("guestsno", "scorm")); print_footer($course); exit; - } + } echo "
    "; $liststyle = "style=\"list-style-type:none;\""; print_simple_box_start("center"); - echo "\n"; - echo " \n"; - $organization = $scorm->launch; - if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) { - if (count($orgs) > 1) { - if (isset($_POST['organization'])) { - $organization = $_POST['organization']; - } - echo "\n"; - } - } - $orgidentifier = ''; - if ($org = get_record('scorm_scoes','id',$organization)) { - if (($org->organization == '') && ($org->launch == '')) { - $orgidentifier = $org->identifier; - } else { - $orgidentifier = $org->organization; - } - } - echo " \n"; - echo "
    ".get_string("coursestruct","scorm")."
    ".get_string('organizations','scorm').": \n"; - choose_from_menu($orgs, 'organization', "$organization", '','submit()'); - echo "
    \n"; - $incomplete = scorm_display_structure($scorm,'scormlist',$orgidentifier); - echo "
    \n"; - print_simple_box_end(); - echo "
    id\">\n"; - echo "\n\n\n\n\n\n
    "; - if ($scorm->browsemode == 1) { - print_string("mode","scorm"); - echo ": \n"; - if ($incomplete === true) { - echo "\n"; - } else { - echo "\n"; - } - } else { - if ($incomplete === true) { - echo ''."\n"; - } else { - echo ''."\n"; - } - } - echo "
    "; - echo ' - - '; - echo "\n
    \n

    "; + echo "\n"; + echo " \n"; + $organization = $scorm->launch; + if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) { + if (count($orgs) > 1) { + if (isset($_POST['organization'])) { + $organization = $_POST['organization']; + } + echo "\n"; + } + } + $orgidentifier = ''; + if ($org = get_record('scorm_scoes','id',$organization)) { + if (($org->organization == '') && ($org->launch == '')) { + $orgidentifier = $org->identifier; + } else { + $orgidentifier = $org->organization; + } + } + echo " \n"; + echo "
    ".get_string("coursestruct","scorm")."
    ".get_string('organizations','scorm').": \n"; + choose_from_menu($orgs, 'organization', "$organization", '','submit()'); + echo "
    \n"; + $incomplete = scorm_display_structure($scorm,'scormlist',$orgidentifier); + echo "
    \n"; + print_simple_box_end(); + echo "
    id\">\n"; + echo "\n\n\n\n\n\n
    "; + if ($scorm->browsemode == 1) { + print_string("mode","scorm"); + echo ": \n"; + if ($incomplete === true) { + echo "\n"; + } else { + echo "\n"; + } + } else { + if ($incomplete === true) { + echo ''."\n"; + } else { + echo ''."\n"; + } + } + echo "
    "; + echo ' + + '; + echo "\n
    \n

    "; ?>