Tabs are out.
authorstronk7 <stronk7>
Mon, 16 May 2005 23:41:58 +0000 (23:41 +0000)
committerstronk7 <stronk7>
Mon, 16 May 2005 23:41:58 +0000 (23:41 +0000)
Please don't use tabs in source code. Set your editor to 4 cc per tab.!

16 files changed:
mod/scorm/api.php
mod/scorm/config.html
mod/scorm/datamodel.php
mod/scorm/datamodels/scorm1_3.js.php
mod/scorm/db/mysql.php
mod/scorm/db/postgres7.php
mod/scorm/lib.php
mod/scorm/loadSCO.php
mod/scorm/mod.html
mod/scorm/playscorm.php
mod/scorm/report.php
mod/scorm/request.js
mod/scorm/restorelib.php
mod/scorm/validate.php
mod/scorm/validatordomxml.php
mod/scorm/view.php

index 16bcf2b..c7e8467 100644 (file)
     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;
     }
 ?>
 
index 29a9fa3..ee860c7 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
     if (empty($CFG->scorm_frameheight)) {
-       $CFG->scorm_frameheight = 600;
+        $CFG->scorm_frameheight = 600;
     }
    if (empty($CFG->scorm_framewidth)) {
         $CFG->scorm_structurewidth = 800;
@@ -33,7 +33,7 @@
 <tr valign="top">
     <td align="right">scorm_framewidth:</td>
     <td>
-       <input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="3" />
+        <input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="3" />
     </td>
     <td>
     <?php print_string("framewidth", "scorm") ?>
@@ -42,7 +42,7 @@
 <tr valign="top">
     <td align="right">scorm_frameheight:</td>
     <td>
-       <input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="4" />
+        <input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="4" />
     </td>
     <td>
     <?php print_string("frameheight", "scorm") ?>
@@ -50,7 +50,7 @@
 </tr>
 <tr>
     <td colspan="3" align="center">
-       <input type="submit" value="<?php print_string("savechanges") ?>" />
+        <input type="submit" value="<?php print_string("savechanges") ?>" />
     </td>
 </tr>
 </table>
index b9c4abb..1de1652 100755 (executable)
     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";
+        }
     }
 ?>
 
index a9fc68c..0252c30 100644 (file)
@@ -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':'<?php echo $user->username ?>', 'mod':'r', 'writeerror':'403'},
-       'cmi.core.student_name':{'defaultvalue':'<?php echo $user->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':'<?php echo $user->username ?>', 'mod':'r', 'writeerror':'403'},
+        'cmi.core.student_name':{'defaultvalue':'<?php echo $user->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();
index 923c67a..9884451 100755 (executable)
@@ -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);
+           }
+        }
+
+        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')");
+        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) {
index 80a7650..ffee4f6 100755 (executable)
@@ -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);
+           }
+        }
+
+        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')");
+        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) {
index 3485353..e0abff0 100755 (executable)
@@ -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;$i<count($rows);$i++) {
-               if (preg_match($regexp,$rows[$i],$matches)) {
-                   for ($j=0;$j<count($columns->columns);$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;$i<count($rows);$i++) {
-               if (preg_match($regexp,$rows[$i],$matches)) {
-                   for ($j=0;$j<count($columns->columns);$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;$i<count($rows);$i++) {
-               if (preg_match($regexp,$rows[$i],$matches)) {
-                   for ($j=0;$j<count($columns->columns);$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;$i<count($rows);$i++) {
-               if (preg_match($regexp,$rows[$i],$matches)) {
-                   $courses[$courseid]->elements[$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;$i<count($rows);$i++) {
+                if (preg_match($regexp,$rows[$i],$matches)) {
+                    for ($j=0;$j<count($columns->columns);$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;$i<count($rows);$i++) {
+        if (preg_match($regexp,$rows[$i],$matches)) {
+            for ($j=0;$j<count($columns->columns);$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;$i<count($rows);$i++) {
+        if (preg_match($regexp,$rows[$i],$matches)) {
+            for ($j=0;$j<count($columns->columns);$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;$i<count($rows);$i++) {
+        if (preg_match($regexp,$rows[$i],$matches)) {
+            $courses[$courseid]->elements[$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 ($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 ($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 "<ul id='0' class='$liststyle'>";
     $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</ul></li>\n";
-                   $level--;
-               } else {
-                   $i = $level;
-                   $closelist = '';
-                   while (($i > 0) && ($parents[$level] != $sco->parent)) {
-                       $closelist .= "\t\t</ul></li>\n";
-                       $i--;
-                   }
-                   if (($i == 0) && ($sco->parent != $currentorg)) {
-                       echo "\t\t<li><ul id='$sublist' class='$liststyle'>\n";
-                       $level++;
-                   } else {
-                       echo $closelist;
-                       $level = $i;
-                   }
-                   $parents[$level]=$sco->parent;
-               }
-           }
-           echo "\t\t<li>";
-           $nextsco = next($scoes);
-           if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
-               $sublist++;
-               echo '<a href="#" onClick="expandCollide(img'.$sublist.','.$sublist.');"><img id="img'.$sublist.'" src="pix/minus.gif" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
-           } else {
-               echo '<img src="pix/spacer.gif" />';
-           }
-           
-           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 "<img src='pix/".$usertrack->status.".gif' alt='$strstatus' title='$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').':&nbsp;'.$usertrack->score_raw.')';
-                   }
-               } else {
-                   if ($play && empty($scoid)) {
-                       $scoid = $sco->id;
-                   }
-                   if ($sco->scormtype == 'sco') {
-                       echo '<img src="pix/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
-                       $incomplete = true;
-                   } else {
-                       echo '<img src="pix/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
-                   }
-               }
-
-               if ($sco->id == $scoid) {
-                   $startbold = '<b>';
-                   $endbold = '</b>';
-                   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 "&nbsp;$startbold<a href='javascript:playSCO(".$sco->id.");'>$sco->title</a> $score$endbold</li>\n";
-           } else {
-               echo "&nbsp;$sco->title</li>\n";
-           }
-       }
-       for ($i=0;$i<$level;$i++) {
-           echo "\t\t</ul></li>\n";
-       }
+        $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</ul></li>\n";
+                $level--;
+            } else {
+                $i = $level;
+                $closelist = '';
+                while (($i > 0) && ($parents[$level] != $sco->parent)) {
+                 $closelist .= "\t\t</ul></li>\n";
+                 $i--;
+             }
+             if (($i == 0) && ($sco->parent != $currentorg)) {
+                 echo "\t\t<li><ul id='$sublist' class='$liststyle'>\n";
+                    $level++;
+                } else {
+                    echo $closelist;
+                    $level = $i;
+                }
+                $parents[$level]=$sco->parent;
+            }
+            }
+            echo "\t\t<li>";
+            $nextsco = next($scoes);
+            if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
+            $sublist++;
+            echo '<a href="#" onClick="expandCollide(img'.$sublist.','.$sublist.');"><img id="img'.$sublist.'" src="pix/minus.gif" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
+            } else {
+            echo '<img src="pix/spacer.gif" />';
+            }
+            
+            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 "<img src='pix/".$usertrack->status.".gif' alt='$strstatus' title='$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').':&nbsp;'.$usertrack->score_raw.')';
+            }
+            } else {
+                if ($play && empty($scoid)) {
+                    $scoid = $sco->id;
+                    }
+                if ($sco->scormtype == 'sco') {
+                echo '<img src="pix/notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
+                $incomplete = true;
+                } else {
+                echo '<img src="pix/asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
+                }
+            }
+
+            if ($sco->id == $scoid) {
+                $startbold = '<b>';
+                $endbold = '</b>';
+                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 "&nbsp;$startbold<a href='javascript:playSCO(".$sco->id.");'>$sco->title</a> $score$endbold</li>\n";
+            } else {
+        echo "&nbsp;$sco->title</li>\n";
+        }
+    }
+    for ($i=0;$i<$level;$i++) {
+        echo "\t\t</ul></li>\n";
+    }
     }
     echo "\t</ul>\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;
     }
 }
 ?>
index 21696da..43d0b97 100755 (executable)
@@ -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);
     //
     // 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);
     }
 
     //
     $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;
+        }
     }
 ?>
 <html>
     <head>
-       <title>LoadSCO</title>
-       <meta http-equiv="refresh" content="1;URL=<?php echo $result ?>" />
+        <title>LoadSCO</title>
+        <meta http-equiv="refresh" content="1;URL=<?php echo $result ?>" />
     </head>
     <body>
-       &nbsp;
+        &nbsp;
     </body>
 </html>
index e307a0c..50d42c9 100755 (executable)
@@ -1,16 +1,16 @@
 <?php
     require_once("$CFG->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 = "";
         var myRequest = NewHttpReq();
        result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
        //alert(result);
-       results = result.split('\n');
-       result = '';
-       errorlogs = '';
-       datadir = '';
-       for (i=0;i<results.length;i++) {
-           element = results[i].split('=');
-           //alert(element);
-           switch(element[0]) {
-               case 'result':
-                  result = element[1];
-               break;
-               case 'launch':
-                  launch = element[1];
-               break;
-               case 'datadir':
-                  datadir = element[1];
-               break;
-               case 'pkgtype':
-                  pkgtype = element[1];    
-               break;
-               case 'errorlogs':
-                   i++;
-                   do {
-                       errorlogs.concat(results[i]+'\n');
-                       i++;
-                   } while (i<results.lenght());
-                       
-               break;
-           }
-       }
-       if ((result == "found") || (result == "regular")) {
-           theform.datadir.value = datadir;
-           theform.pkgtype.value = pkgtype;
-           theform.launch.value = launch;
-           if (launch == 0) {
-               if ('<?php echo $scormid ?>' != '') {
-                   return confirm('<?php print_string('trackingloose','scorm') ?>');
-               }
-           }
-           return true;
-       } else {
-           result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
-           if (errorlogs != '') {
-               result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
-           }
-           alert(result);
-           return false;
-       }
+        results = result.split('\n');
+        result = '';
+        errorlogs = '';
+        datadir = '';
+        for (i=0;i<results.length;i++) {
+            element = results[i].split('=');
+            //alert(element);
+            switch(element[0]) {
+               case 'result':
+                  result = element[1];
+               break;
+               case 'launch':
+                  launch = element[1];
+               break;
+               case 'datadir':
+                  datadir = element[1];
+               break;
+               case 'pkgtype':
+                  pkgtype = element[1];    
+               break;
+               case 'errorlogs':
+                   i++;
+                   do {
+                       errorlogs.concat(results[i]+'\n');
+                       i++;
+                   } while (i<results.lenght());
+                       
+               break;
+            }
+        }
+        if ((result == "found") || (result == "regular")) {
+            theform.datadir.value = datadir;
+            theform.pkgtype.value = pkgtype;
+            theform.launch.value = launch;
+            if (launch == 0) {
+                if ('<?php echo $scormid ?>' != '') {
+                    return confirm('<?php print_string('trackingloose','scorm') ?>');
+                }
+            }
+            return true;
+        } else {
+            result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
+            if (errorlogs != '') {
+               result.concat('<?php print_string('errorlogs','scorm') ?>:\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;
+        }
     }
 </script>
 
 <form name="form" method="post" action="mod.php" onsubmit="return validate_scorm(document.form,document.form.reference.value);">
     <table cellpadding="5">
-       <tr valign="top">
-           <td align="right"><b><?php print_string("name") ?>:</b></td>
-           <td>
-               <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
-           </td>
-       </tr>
+        <tr valign="top">
+            <td align="right"><b><?php print_string("name") ?>:</b></td>
+            <td>
+                <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
+            </td>
+        </tr>
 <?php 
     $strfilename = get_string("coursepacket", "scorm");
     $strchooseafile = get_string("chooseapacket", "scorm");
 ?>
-       <tr valign="top">
-           <td align="right"><b><?php print_string("summary") ?>:</b><br />
-               <font size="1">
-               <?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
+        <tr valign="top">
+            <td align="right"><b><?php print_string("summary") ?>:</b><br />
+               <font size="1">
+               <?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
                </font>
-           </td>
-           <td>
+            </td>
+            <td>
         <?php print_textarea($usehtmleditor, 10, 50, 680, 400, "summary", $form->summary); ?>
-           </td>
-       </tr>
-       <tr valign="top">
-           <td align="right" nowrap="nowrap">
-               <b><?php echo $strfilename?>:</b>
-           </td>
-           <td>
-               <?php
-                   echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
-                   button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference", 
-                                           "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
-                   helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
-               ?>
-           </td>
-       </tr>
+            </td>
+        </tr>
+        <tr valign="top">
+            <td align="right" nowrap="nowrap">
+               <b><?php echo $strfilename?>:</b>
+            </td>
+            <td>
+               <?php
+                   echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
+                   button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference", 
+                                           "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
+                   helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
+               ?>
+            </td>
+        </tr>
         <tr valign="top">
             <td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
             <td>
                 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');
             ?>
             </td>
         </tr>    
-       <tr>
+        <tr>
             <td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
             <td>
             <?php
                 choose_from_menu ($options, "auto", $form->auto,'');
                 helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
             ?>
-           </td>
-       </tr>
-       <tr>
+            </td>
+        </tr>
+        <tr>
             <td align="right"><b><?php print_string("enablebrowse","scorm") ?>:</b></td>
             <td>
             <?php
                 choose_from_menu ($options, "browsemode", $form->browsemode, '');
                 helpbutton("browsemode", get_string("browsemode", "scorm"), "scorm", true);
             ?>
-           </td>
-       </tr>
-       <tr valign="top">
+            </td>
+        </tr>
+        <tr valign="top">
             <td align="right"><b><?php print_string("width","scorm") ?>:</b></td>
-           <td>
-               <input type="text" name="width" value="<?php echo $form->width ?>" size="4" />
+            <td>
+               <input type="text" name="width" value="<?php echo $form->width ?>" size="4" />
                 <?php helpbutton("width", get_string("width", "scorm"), "scorm", true); ?>
-           </td>
-       </tr>
-       <tr valign="top">
+            </td>
+        </tr>
+        <tr valign="top">
             <td align="right"><b><?php print_string("height","scorm") ?>:</b></td>
-           <td>
-               <input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
+            <td>
+               <input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
                 <?php helpbutton("height", get_string("height", "scorm"), "scorm", true); ?>
-           </td>
-       </tr>
+            </td>
+        </tr>
     </table>
     <input type="hidden" name="datadir"        value="<?php p($form->datadir) ?>" />
     <input type="hidden" name="pkgtype"        value="<?php p($form->pkgtype) ?>" />
     <input type="hidden" name="instance"       value="<?php p($form->instance) ?>" />
     <input type="hidden" name="mode"           value="<?php p($form->mode) ?>" />
     <center>
-       <input type="submit" value="<?php print_string('savechanges') ?>" />
-       <input type="button" name="cancel" value="<?php print_string('cancel') ?>" onclick="document.location='view.php?id=<?php echo $form->course ?>'" />
+        <input type="submit" value="<?php print_string('savechanges') ?>" />
+        <input type="button" name="cancel" value="<?php print_string('cancel') ?>" onclick="document.location='view.php?id=<?php echo $form->course ?>'" />
     </center>
 </form>
index f7f109b..e23396a 100755 (executable)
@@ -71,8 +71,8 @@
         $scoidstring = '&scoid='.$scoid;
     }
     if (!empty($_POST['currentorg'])) {
-       $currentorg = $_POST['currentorg'];
-       $currentorgstring = '&currentorg='.$currentorg;
+    $currentorg = $_POST['currentorg'];
+    $currentorgstring = '&currentorg='.$currentorg;
     }
     
     $strexpand = get_string('expcoll','scorm');
     //$bodyscripts = "onunload='SCOFinish();'";
     $bodyscripts = '';
     print_header($pagetitle, "$course->fullname",
-       "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
-       '', '', true, update_module_button($cm->id, $course->id, $strscorm),'',false,$bodyscripts);
+    "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
+    '', '', true, update_module_button($cm->id, $course->id, $strscorm),'',false,$bodyscripts);
 ?>
     
     <table width="100%">
     <tr><td valign="top">
        <p><?php echo format_text($scorm->summary) ?></p>
        <p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : '&nbsp;'; ?></p>
-       <table class='generalbox' cellpadding='5' cellspacing='0'>
-           <tr>
-               <th>
-                   <div style='float: left;'><?php print_string('coursestruct','scorm') ?></div>
-                   <!--<div style='float:right;'>
-                       <a href='#' onClick='popup(main,popupimg);'><img id='popupimg' src="pix/popup.gif" alt="<?php echo $strpopup ?>" title="<?php echo $strpopup ?>"/></a>
-                   </div> -->
-               </th>
-           </tr>
-           <!-- <tr><td width="<?php echo $CFG->scorm_structurewidth ?>%">  -->
-           <tr><td width="<?php echo $CFG->scorm_structurewidth ?>%">  
+    <table class='generalbox' cellpadding='5' cellspacing='0'>
+        <tr>
+            <th>
+                <div style='float: left;'><?php print_string('coursestruct','scorm') ?></div>
+                   <!--<div style='float:right;'>
+                       <a href='#' onClick='popup(main,popupimg);'><img id='popupimg' src="pix/popup.gif" alt="<?php echo $strpopup ?>" title="<?php echo $strpopup ?>"/></a>
+                   </div> -->
+               </th>
+        </tr>
+        <!-- <tr><td width="<?php echo $CFG->scorm_structurewidth ?>%">  -->
+        <tr><td width="<?php echo $CFG->scorm_structurewidth ?>%">  
 <?php
     $sco = scorm_display_structure($scorm,'scormlist',$currentorg,$scoid,$mode,true);
     if ($mode == 'normal') {
-       if ($trackdata = scorm_get_tracks($USER->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;
 
     $SESSION->scorm_scoid = $sco->id;
 ?>
-           </td></tr>
-           <tr><td align="center">
-               <form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
-                   <input name="scoid" type="hidden" />
-                   <input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
-                   <input name="mode" type="hidden" value="<?php echo $mode ?>" />
-                   <input name="prev" type="<?php if (($sco->prev == 0) || ($sco->showprev == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="prevSCO();" />
-                   <input name="next" type="<?php if (($sco->next == 0) || ($sco->shownext == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('next','scorm') ?>" onClick="nextSCO();" /><br />
-                   <input name="exit" type="button" value="<?php print_string('exit','scorm') ?>" onClick="playSCO(0)" />
-               </form>
-           </td></tr>
-       </table>
+        </td></tr>
+        <tr><td align="center">
+       <form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
+           <input name="scoid" type="hidden" />
+           <input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
+           <input name="mode" type="hidden" value="<?php echo $mode ?>" />
+           <input name="prev" type="<?php if (($sco->prev == 0) || ($sco->showprev == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="prevSCO();" />
+           <input name="next" type="<?php if (($sco->next == 0) || ($sco->shownext == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('next','scorm') ?>" onClick="nextSCO();" /><br />
+           <input name="exit" type="button" value="<?php print_string('exit','scorm') ?>" onClick="playSCO(0)" />
+       </form>
+        </td></tr>
+    </table>
     </td>
     <td valign="top" width="<?php print $scorm->width ?>"> 
        <iframe  name="main" width="100%" height="<?php echo $scorm->height ?>" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></iframe>
             }
         }
 
-       function popup(win,image) {
-           win = window.open("loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>","","width=<?php echo $scorm->width ?>,height=<?php echo $scorm->height ?>,scrollbars=1");
+    function popup(win,image) {
+        win = window.open("loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>","","width=<?php echo $scorm->width ?>,height=<?php echo $scorm->height ?>,scrollbars=1");
            image.src = "pix/popdown.gif";
-           return win;
-       }
+        return win;
+    }
 
-       function prevSCO() {
-           playSCO(<?php echo $sco->prev ?>);
-       }
+    function prevSCO() {
+        playSCO(<?php echo $sco->prev ?>);
+    }
 
-       function nextSCO() {
-           playSCO(<?php echo $sco->next ?>);
-       }
+    function nextSCO() {
+        playSCO(<?php echo $sco->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";
index 46d9c73..10ef7d8 100755 (executable)
@@ -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);
         $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 <a href=\"index.php?id=$course->id\">$strscorms</a>
                       -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
                      "", "", true);
-       } else {
+    } else {
             print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
                      "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
                       -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
-                     -> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
+             -> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $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('&nbsp;', $strname);
                $table->align = array('center', 'left');
                $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[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
-                            "$userdata->firstname $userdata->lastname</a>";
-                       foreach ($scoes as $sco) {
-                           if ($sco->launch!='') {
-                               $anchorstart = '';
-                               $anchorend = '';
-                               $scoreview = '';
-                               if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
-                                   if ($trackdata->score_raw != '') {
-                                       $scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
-                                   }
-                                   if ($trackdata->status == '') {
-                                       $trackdata->status = 'notattempted';
-                                   } else {
-                                       $anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.get_string('details','scorm').'">';
-                                       $anchorend = '</a>';
-                                   }
-                               } else {
-                                   $trackdata->status = 'notattempted';
-                                   $trackdata->total_time = '';
-                               }
-                               $strstatus = get_string($trackdata->status,'scorm');
-                               $row[] = $anchorstart.'<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
-                                       $strstatus.'">&nbsp;'.$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[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$scouser->userid&course=$course->id\">".
+                    "$userdata->firstname $userdata->lastname</a>";
+               foreach ($scoes as $sco) {
+                   if ($sco->launch!='') {
+                       $anchorstart = '';
+                       $anchorend = '';
+                       $scoreview = '';
+                       if ($trackdata = scorm_get_tracks($sco->id,$scouser->userid)) {
+                           if ($trackdata->score_raw != '') {
+                               $scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
+                           }
+                           if ($trackdata->status == '') {
+                               $trackdata->status = 'notattempted';
+                           } else {
+                               $anchorstart = '<a href="report.php?b='.$sco->id.'&user='.$scouser->userid.'" title="'.get_string('details','scorm').'">';
+                               $anchorend = '</a>';
+                           }
+                       } else {
+                           $trackdata->status = 'notattempted';
+                           $trackdata->total_time = '';
+                       }
+                       $strstatus = get_string($trackdata->status,'scorm');
+                       $row[] = $anchorstart.'<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
+                               $strstatus.'">&nbsp;'.$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 '<div align="center">'."\n";
-               print_user_picture($user, $course->id, $userdata->picture, false, false);
-               echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
-                    "$userdata->firstname $userdata->lastname</a><br />";
-               $scoreview = '';
-               if ($trackdata = scorm_get_tracks($sco->id,$user)) {
-                   if ($trackdata->score_raw != '') {
-                       $scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
-                   }
-                   if ($trackdata->status == '') {
-                       $trackdata->status = 'notattempted';
-                   }
-               } else {
-                   $trackdata->status = 'notattempted';
-                   $trackdata->total_time = '';
-               }
-               $strstatus = get_string($trackdata->status,'scorm');
-               echo '<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
-                       $strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
-               echo '</div>'."\n";
-               //print_r($trackdata);
-               foreach($trackdata as $element => $value) {
-                   if (substr($element,0,3) == 'cmi') {
-                       echo $element.' => '.$value.'<br />';
-                   }
-               }
-               print_simple_box_end();
-           }
-       } else {
-           error('Missing script parameter');
-       }
+       echo '<div align="center">'."\n";
+       print_user_picture($user, $course->id, $userdata->picture, false, false);
+       echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
+            "$userdata->firstname $userdata->lastname</a><br />";
+       $scoreview = '';
+       if ($trackdata = scorm_get_tracks($sco->id,$user)) {
+           if ($trackdata->score_raw != '') {
+               $scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
+           }
+           if ($trackdata->status == '') {
+               $trackdata->status = 'notattempted';
+           }
+       } else {
+           $trackdata->status = 'notattempted';
+           $trackdata->total_time = '';
+       }
+       $strstatus = get_string($trackdata->status,'scorm');
+       echo '<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
+               $strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br />';
+       echo '</div>'."\n";
+       //print_r($trackdata);
+       foreach($trackdata as $element => $value) {
+           if (substr($element,0,3) == 'cmi') {
+               echo $element.' => '.$value.'<br />';
+           }
+       }
+       print_simple_box_end();
+        }
+    } else {
+        error('Missing script parameter');
+    }
     }
     if (empty($noheader)) {
         print_footer($course);
index 9001b0f..bcc66bc 100644 (file)
@@ -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;
 }
index a0f0547..5e3a937 100755 (executable)
@@ -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
index 5f94594..37b42e5 100755 (executable)
@@ -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"; 
index f9f0758..58d4567 100755 (executable)
@@ -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 <schema> e <schemaversion>
-                               //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 <schema> e <schemaversion>
+                       //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 <br />";
-                                //echo "Probabilmente la versione e' antecedente alla 1.3 <br />";
-                               }
-                               if($new_t_scv < $t_scv)
+                        //echo "Probabilmente la versione e' antecedente alla 1.3 <br />";
+                       }
+                       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 <br />";
-                                 //echo "Probabilmente la versione e' antecedente alla 1.3 <br />";
+                         //echo "Probabilmente la versione e' antecedente alla 1.3 <br />";
                                 }
                             }
-                         }     
-                        // 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 "<br /> SCANSIONE DI LOCATION TERMINATA, OK \n";
-                       }
-
-                       if($nome_figlio == "organizations")
-                       {
-                               if($padre->node_name() != "manifest")
-                               {
-                                 $error->type = "position_error";
+                 }          
+                 //echo "<br /> SCANSIONE DI LOCATION TERMINATA, OK \n";
+               }
+
+               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
-
-                       if($nome_figlio == "organization")
-                       {
-                               if($padre->node_name() != "organizations")
-                               {
-                                 $error->type = "position_error";
+    
+                       //echo "SCANSIONE TAG ORGANIZATIONS TERMINATA, OK \n";
+               }//FINE IF ORGANIZATIONS
+
+               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
-
-                               if(!$figlio->has_child_nodes())
-                               {                               
-                                 $error->type = "no_children";
+                               $cont_err++;
+                           }
+                         }
+                       }//FINE FOR
+
+                       if(!$figlio->has_child_nodes())
+                       {                               
+                         $error->type = "no_children";
                                   $error->data->tag = "item";
                                   array_push($errors, $error);
-                                 $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)
+                         $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)
                                 {
-                                 $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++;
-                         }
-                       }
-
-                       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")
+                       $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")
                           {
-                           $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
-
-                       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
-
-                       if(($nome_figlio == "maxtimeallowed")&&(eregi("(CAM[[:blank:]])?[1]\.[0-2]", $version_value)))
-                       {
-                         if(strcmp("item", $padre->node_name())!=0)
+               }
+
+               //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++;
+                       }
+                   }             
+               }
+
+               //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)
                           {
                                 $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++;
-                         }
-                       }
-
-                       if($nome_figlio == "resource")
-                       {
-                         if(strcmp("resources", $padre->node_name())!=0)
-                         {
-                           $error->type = "position_error";
+                       $cont_err++;
+                 }
+               }
+
+               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++;
-                             }
-                           }
-
-                           if(($figlio->has_attribute("href"))&&(strcmp("href", $ra_n)==0))
-                           {
-                               if(!eregi("[[:graph:]]", $ra_v))
-                               {
-                                 $error->type = "attr_error";
+                       $cont_err++;
+                     }
+                   }
+
+                   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++;
-                               
-                           }
-
-                           if(($figlio->has_attribute("persistState"))&&(strcmp("persistState", $ra_n)==0))
-                           {
-                               if(!eregi("[0-1]", $ra_v))
-                               {
-                                 $error->type = "attr_error";
+                       $cont_err++;
+                       
+                   }
+
+                   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++;
-                               }
-                           }
-                         }
-                         
-                       }
-
-                       if($nome_figlio == "file")
-                       {
-                         if(!$figlio->has_attributes())
-                         {
-                           $error->type = "no_attributes";
+                         $cont_err++;
+                       }
+                   }
+                 }
+                 
+               }
+
+               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++;
-                         }
-                       }
-
-                       if($nome_figlio == "dependency")
-                       {                       
-                         if(strcmp("resource", $padre->node_name())!=0)
-                         {
-                           $error->type = "position_error";
+                   $cont_err++;
+                 }
+               }
+
+               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.
-
-                           if(!eregi("[[:graph:]]", $dep_attr[0]->node_value()))
-                           {
-                               $error->type = "attr_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.
+
+                   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";
-                       }
-
-                       if($nome_figlio == "ruleCondition")
-                       {
-                         if(strcmp("ruleConditions", $padre->node_name())!=0)
-                         {
-                           $error->type = "position_error";
+                       $cont_err++;
+                     }
+                   }   
+                 }
+                 //echo "SCANSIONE TAG RULESCONDITIONS TERMINATA";
+               }
+
+               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++;
-                         }
-
-                         if($figlio->has_attributes())
-                         {
-                           $rC_attr = $figlio->attributes();
-                           $cont_rC = count($rC_attr);
-                           if($cont_rC > 4)
-                           {
-                               $error->type = "too_many_attributes";
+                   $cont_err++;
+                 }
+
+                 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++;
-                                 }
-                               }       
-
-                               if($rCa_name == "operator")                             
-                               {
-                                 if((!eregi("not", $rCa_val))||(!eregi("noOp", $rCa_val)))
-                                 {
-                                   $error->type = "attr_error";
+                           $cont_err++;
+                         }
+                       }       
+
+                       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
-                         }
-                       }
-
-                       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";
+                           $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";
                                   $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()))
                                 {
-