Added user activity support
authorbobopinna <bobopinna>
Mon, 23 May 2005 06:56:10 +0000 (06:56 +0000)
committerbobopinna <bobopinna>
Mon, 23 May 2005 06:56:10 +0000 (06:56 +0000)
General TAB cleaning
SCO-LMS communication systeme changed to POST method
Several bug fix

17 files changed:
mod/scorm/README.txt
mod/scorm/aicc.php
mod/scorm/api.php
mod/scorm/backuplib.php
mod/scorm/config.html
mod/scorm/datamodel.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/styles.php [new file with mode: 0644]
mod/scorm/validate.php
mod/scorm/version.php
mod/scorm/view.php

index d8eb8cf..2b00c78 100644 (file)
@@ -1,17 +1,20 @@
 SCORM Module by Roberto "Bobo" Pinna
 
-This module is a SCORM player that import SCORM packages in .zip or .pif format 
+This module is a SCORM player that import SCORM packages in .zip or .pif format
 (they are the same thing).
 At this time the SCORM module import packages in SCORM1.2, SCORM1.3 (aka SCORM2004) and AICC.
-It plays SCORM1.2 and AICC packages.
+It plays SCORM1.2 and launch AICC packages.
+
+Moodle SCORM Module is SCORM Version 1.2 Run-Time Environment Conformant -
+Minimum with All Optional Data Model Elements (LMS-RTE3)
 
 THIS MODULE IS JAVA FREE.
 
 ================================================================
 
 Still in development (you can see this as a road map):
+- LMS store for all datamodels for AICC;
 - support for playing SCORM 1.3;
-- LMS store for all datamodels;
 - navigation/sequencing (prerequisites, objective,etc...);
 - SCORM packages validation (I disabled the old one);
 
@@ -27,7 +30,7 @@ mod.html <-- onsubmit --> validate.php (-- include --> validatordomxml.php)
  submit  load
    ||      \
    ||       \
-   \/    request.js 
+   \/     request.js
 view.php
 
 ----------------------------------------------------------------
@@ -42,7 +45,7 @@ view.php
    ||
    \/
 playscorm.php -- load --> request.js
-   ||                     api.php -- include --> datamodels/((SCORM1_2.js.php &| SCORM1_3.js.php) || AICC.js.php)
+   ||                     api.php -- include --> datamodels/(SCORM1_2.js.php || SCORM1_3.js.php || AICC.js.php)
    ||                       /\
  iframe                     ||
  "main"<-----             XMLHTTP
@@ -53,8 +56,8 @@ playscorm.php -- load --> request.js
 loadSCO.php |
     |       |
     |       |
-    --------- 
-    reload itself 
+    ---------
+    reload itself
     to the right sco
 
 
index b752948..46ed0f6 100755 (executable)
     require_login($course->id, false, $cm);
     
     if (isset($_POST['command']) && confirm_sesskey($_POST['session_id'])) {
-       $command = strtolower($_POST['command']);
-       
-       if (isset($SESSION->scorm_scoid)) {
-           $scoid = $SESSION->scorm_scoid;
-       } else {
-           error('Invalid script call');
-       }
-       $mode = 'normal';
-       if (isset($SESSION->scorm_mode)) {
-           $mode = $SESSION->scorm_mode;
-       }
-       $status = $SESSION->scorm_status;
-       if ($sco = get_record('scorm_scoes','id',$scoid)) {
-           if (!$scorm = get_record('scorm','id',$sco->scorm)) {
-               error('Invalid script call');
-           }
-       } else {
-           error('Invalid script call');
-       }
-       if ($scorm = get_record('scorm','id',$sco->scorm)) {
-       switch $command {
-          case 'getparam':
-               if ($status == 'Not Initialized') {
-                   $SESSION->scorm_status = 'Running';
-                   $status = 'Running';
-               }
-               if ($status != 'Running') {
-                   echo "error = 101\nerror_text = Terminated\n";
-               } else {
-                    if ($usertrack=scorm_get_tracks($scoid,$USER->id)) {
-                       $userdata = $usertrack;
-                   } else {
-                       $userdata->status = '';
-                       $userdata->scorre_raw = '';
-                   }
-                   $userdata->student_id = $USER->username;
-                   $userdata->student_name = $USER->lastname .', '. $USER->firstname;
-                   $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;
-                       if (!empty($sco->masteryscore)) {
-                           $userdata->credit = 'credit';
-                       } else {
-                           $userdata->credit = 'no-credit';
-                       }    
-                   } else {
-                       error('Sco not found');
-                   }
-                   echo "error = 0\nerror_text = Successful\naicc_data=\n";
-                   echo "[Core]\n";
-                   echo 'Student_ID = '.$userdata->student_id."\n";
-                   echo 'Student_Name = '.$userdata->student_name."\n";
-                   echo 'Lesson_Location = '.isset($userdata->{'cmi.core.lesson_location'})?$userdata->{'cmi.core.lesson_location'}:''."\n";
-                   echo 'Credit = '.$userdata->credit."\n";
-                   echo 'Lesson_Status = '.isset($userdata->{'cmi.core.lesson_status'})?$userdata->{'cmi.core.lesson_status'}:''."\n";
-                   echo 'Score = '.isset($userdata->{'cmi.core.score.raw'})?$userdata->{'cmi.core.score.raw'}:''."\n";
-                   echo 'Time = '.isset($userdata->{'cmi.core.total_time'})?$userdata->{'cmi.core.total_time'}:'00:00:00'."\n";
-                   echo "[Core_Lesson]\n".isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:''."\n";
-                   echo "[Core_Vendor]\n".$userdata->datafromlms."\n";
-               }
-          break;
-          case 'putparam':
-               if ($status == 'Running') {
-                   print_r($_POST['aicc_data']);
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
-          case 'putcomments':
-               if ($status == 'Running') {
-                   print_r($_POST['aicc_data']);
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
-          case 'putinteractions':
-               if ($status == 'Running') {
-                   print_r($_POST['aicc_data']);
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
-          case 'putobjectives':
-               if ($status == 'Running') {
-                   print_r($_POST['aicc_data']);
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
-          case 'putpath':
-               if ($status == 'Running') {
-                   print_r($_POST['aicc_data']);
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
-          case 'putperformance':
-               if ($status == 'Running') {
-                   print_r($_POST['aicc_data']);
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
-          case 'exitau':
-               if ($status == 'Running') {
-                   $SESSION->scorm_status = 'Terminated';                  
-                   echo "error = 0\nerror_text = Successful\n";
-               }
-          break;
+        $command = strtolower($_POST['command']);
+       
+        if (isset($SESSION->scorm_scoid)) {
+            $scoid = $SESSION->scorm_scoid;
+        } else {
+            error('Invalid script call');
+        }
+        $mode = 'normal';
+        if (isset($SESSION->scorm_mode)) {
+            $mode = $SESSION->scorm_mode;
+        }
+        $status = $SESSION->scorm_status;
+        if ($sco = get_record('scorm_scoes','id',$scoid)) {
+            if (!$scorm = get_record('scorm','id',$sco->scorm)) {
+                error('Invalid script call');
+            }
+        } else {
+            error('Invalid script call');
+        }
+        if ($scorm = get_record('scorm','id',$sco->scorm)) {
+        switch $command {
+            case 'getparam':
+                if ($status == 'Not Initialized') {
+                    $SESSION->scorm_status = 'Running';
+                    $status = 'Running';
+                }
+                if ($status != 'Running') {
+                    echo "error = 101\nerror_text = Terminated\n";
+                } else {
+                    if ($usertrack=scorm_get_tracks($scoid,$USER->id)) {
+                        $userdata = $usertrack;
+                    } else {
+                        $userdata->status = '';
+                        $userdata->scorre_raw = '';
+                    }
+                    $userdata->student_id = $USER->username;
+                    $userdata->student_name = $USER->lastname .', '. $USER->firstname;
+                    $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;
+                        if (!empty($sco->masteryscore)) {
+                            $userdata->credit = 'credit';
+                        } else {
+                            $userdata->credit = 'no-credit';
+                        }    
+                        echo "error = 0\nerror_text = Successful\naicc_data=\n";
+                        echo "[Core]\n";
+                        echo 'Student_ID = '.$userdata->student_id."\n";
+                        echo 'Student_Name = '.$userdata->student_name."\n";
+                        echo 'Lesson_Location = '.isset($userdata->{'cmi.core.lesson_location'})?$userdata->{'cmi.core.lesson_location'}:''."\n";
+                        echo 'Credit = '.$userdata->credit."\n";
+                        echo 'Lesson_Status = '.isset($userdata->{'cmi.core.lesson_status'})?$userdata->{'cmi.core.lesson_status'}:''."\n";
+                        echo 'Score = '.isset($userdata->{'cmi.core.score.raw'})?$userdata->{'cmi.core.score.raw'}:''."\n";
+                        echo 'Time = '.isset($userdata->{'cmi.core.total_time'})?$userdata->{'cmi.core.total_time'}:'00:00:00'."\n";
+                        echo "[Core_Lesson]\n".isset($userdata->{'cmi.suspend_data'})?$userdata->{'cmi.suspend_data'}:''."\n";
+                        echo "[Core_Vendor]\n".$userdata->datafromlms."\n";
+                    } else {
+                        error('Sco not found');
+                    }
+                }
+            break;
+            case 'putparam':
+                if ($status == 'Running') {
+                    print_r($_POST['aicc_data']);
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+            case 'putcomments':
+                if ($status == 'Running') {
+                    print_r($_POST['aicc_data']);
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+            case 'putinteractions':
+                if ($status == 'Running') {
+                    print_r($_POST['aicc_data']);
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+            case 'putobjectives':
+                if ($status == 'Running') {
+                    print_r($_POST['aicc_data']);
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+            case 'putpath':
+                if ($status == 'Running') {
+                    print_r($_POST['aicc_data']);
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+            case 'putperformance':
+                if ($status == 'Running') {
+                    print_r($_POST['aicc_data']);
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+            case 'exitau':
+                if ($status == 'Running') {
+                    $SESSION->scorm_status = 'Terminated';                  
+                    echo "error = 0\nerror_text = Successful\n";
+                }
+            break;
+        }
     }
 ?>
 
index 2bac0ec..020f077 100644 (file)
@@ -48,9 +48,9 @@
         $userdata->mode = $mode;
     }
     if ($userdata->mode == 'normal') {
-       $userdata->credit = 'credit';
+        $userdata->credit = 'credit';
     } else {
-       $userdata->credit = 'no-credit';
+        $userdata->credit = 'no-credit';
     }    
     if ($sco = get_record('scorm_scoes','id',$scoid)) {
         $userdata->datafromlms = $sco->datafromlms;
     switch ($scorm->version) {
         case 'SCORM_1.2':
             include_once ('datamodels/scorm1_2.js.php');
-            break;
+        break;
         case 'SCORM_1.3':
-           include_once ('datamodels/scorm1_3.js.php');
-            break;
+            include_once ('datamodels/scorm1_3.js.php');
+        break;
         case 'AICC':
-           include_once ('datamodels/aicc.js.php');
-            break;
+            include_once ('datamodels/aicc.js.php');
+        break;
         default:
             include_once ('datamodels/scorm1_2.js.php');
-            break;
+        break;
     }
 ?>
 
index 1fe615b..2b2da29 100755 (executable)
@@ -6,16 +6,16 @@
     //
     //                      scorm                                      
     //                   (CL,pk->id)---------------------
-    //                        |                                |
-    //                        |                                |
-    //                        |                                |
-    //                   scorm_scoes                   |       
-    //             (UL,pk->id, fk->scorm)              |
-    //                        |                                |
-    //                        |                                |
-    //                        |                                |
-    //                scorm_scoes_track                        |
-    //  (UL,k->id, fk->scormid, fk->scoid, k->element)---      
+    //                        |                         |
+    //                        |                         |
+    //                        |                         |
+    //                   scorm_scoes                    |
+    //             (UL,pk->id, fk->scorm)               |
+    //                        |                         |
+    //                        |                         |
+    //                        |                         |
+    //                scorm_scoes_track                 |
+    //  (UL,k->id, fk->scormid, fk->scoid, k->element)---
     //
     // Meaning: pk->primary key field of the table
     //          fk->foreign key to link with parent
@@ -50,6 +50,8 @@
                 fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
                 fwrite ($bf,full_tag("BROWSEMODE",4,false,$scorm->browsemode));
                 fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
+                fwrite ($bf,full_tag("WIDTH",4,false,$scorm->width));
+                fwrite ($bf,full_tag("HEIGHT",4,false,$scorm->height));
                 fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
                 $status = backup_scorm_scoes($bf,$preferences,$scorm->id);
  
index ee860c7..e7789ea 100755 (executable)
@@ -2,7 +2,7 @@
     if (empty($CFG->scorm_frameheight)) {
         $CFG->scorm_frameheight = 600;
     }
-   if (empty($CFG->scorm_framewidth)) {
+    if (empty($CFG->scorm_framewidth)) {
         $CFG->scorm_structurewidth = 800;
     }
 ?>
@@ -36,7 +36,7 @@
         <input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="3" />
     </td>
     <td>
-    <?php print_string("framewidth", "scorm") ?>
+        <?php print_string("framewidth", "scorm") ?>
     </td>
 </tr>
 <tr valign="top">
@@ -45,7 +45,7 @@
         <input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="4" />
     </td>
     <td>
-    <?php print_string("frameheight", "scorm") ?>
+        <?php print_string("frameheight", "scorm") ?>
     </td>
 </tr>
 <tr>
index 1de1652..e691cb7 100755 (executable)
@@ -9,15 +9,12 @@
         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 (! $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 (confirm_sesskey() && (isset($SESSION->scorm_scoid))) {
         $scoid = $SESSION->scorm_scoid;
         $result = true;
-        foreach ($_GET as $element => $value) {
+        foreach ($_POST 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;
+                   $track->timemodified = time();
                     $result = update_record('scorm_scoes_track',$track) && $result;
                 } else {
                     $track->userid = $USER->id;
@@ -48,9 +46,9 @@
                     $track->scoid = $scoid;
                     $track->element = $element;
                     $track->value = $value;
+                   $track->timemodified = time();
                     $result = insert_record('scorm_scoes_track',$track) && $result;
                 }
-                //print_r($track);
             }
         }
         if ($result) {
index 642042a..e97a5e6 100755 (executable)
@@ -7,21 +7,21 @@ define('VALUESCOES', '0');
 define('VALUEHIGHEST', '1');
 define('VALUEAVERAGE', '2');
 define('VALUESUM', '3');
-$SCORM_GRADE_METHOD = array (VALUESCOES => get_string('gradescoes', 'scorm'), 
+$SCORM_GRADE_METHOD = array (VALUESCOES => get_string('gradescoes', 'scorm'),
                              VALUEHIGHEST => get_string('gradehighest', 'scorm'),
                              VALUEAVERAGE => get_string('gradeaverage', 'scorm'),
                              VALUESUM => get_string('gradesum', 'scorm'));
 
-if (!isset($CFG->scorm_validate)) {
-    $scormvalidate = 'none';
-    if (extension_loaded('domxml') && version_compare(phpversion(),'5.0.0','<')) {
-        $scormvalidate = 'domxml';
-    }
-    if (version_compare(phpversion(),'5.0.0','>=')) {
-        $scormvalidate = 'php5';
-    }
-    set_config('scorm_validate', $scormvalidate);
-}
+//if (!isset($CFG->scorm_validate)) {
+//    $scormvalidate = 'none';
+//    if (extension_loaded('domxml') && version_compare(phpversion(),'5.0.0','<')) {
+//        $scormvalidate = 'domxml';
+//    }
+//    if (version_compare(phpversion(),'5.0.0','>=')) {
+//        $scormvalidate = 'php5';
+//    }
+//    set_config('scorm_validate', $scormvalidate);
+//}
 
 if (!isset($CFG->scorm_frameheight)) {
     set_config('scorm_frameheight','600');
@@ -32,48 +32,48 @@ if (!isset($CFG->scorm_framewidth)) {
 }
 
 function scorm_add_instance($scorm) {
-/// Given an object containing all the necessary data, 
-/// (defined by the form in mod.html) this function 
-/// will create a new instance and return the id number 
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
+/// will create a new instance and return the id number
 /// of the new instance.
 
     $scorm->timemodified = time();
 
     # May have to add extra stuff in here #
     global $CFG;
-    
+
     $id = insert_record('scorm', $scorm);
-    
+
     //
     // Rename temp scorm dir to scorm id
     //
-    
+
     $scormdir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
     rename($scormdir.$scorm->datadir,$scormdir.'/'.$id);
     //
     // Parse scorm manifest
     //
     if ($scorm->launch == 0) {
-    $scorm->launch = scorm_parse($scormdir.'/'.$id,$scorm->pkgtype,$id);
+        $scorm->launch = scorm_parse($scormdir.'/'.$id,$scorm->pkgtype,$id);
         set_field('scorm','launch',$scorm->launch,'id',$id);
     }
-    
+
     return $id;
 }
 
 
 function scorm_update_instance($scorm) {
-/// Given an object containing all the necessary data, 
-/// (defined by the form in mod.html) this function 
+/// Given an object containing all the necessary data,
+/// (defined by the form in mod.html) this function
 /// will update an existing instance with new data.
-    
+
     $scorm->timemodified = time();
     $scorm->id = $scorm->instance;
 
     # May have to add extra stuff in here #
     global $CFG;
-    
-    
+
+
     //
     // Check if scorm manifest needs to be reparsed
     //
@@ -85,16 +85,16 @@ function scorm_update_instance($scorm) {
         }
         $scorm->launch = scorm_parse($scormdir.'/'.$scorm->id,$scorm->pkgtype,$scorm->id);
     }
-    
+
     return update_record('scorm', $scorm);
 }
 
 
 function scorm_delete_instance($id) {
-/// Given an ID of an instance of this module, 
-/// this function will permanently delete the instance 
-/// and any data that depends on it.  
-    
+/// Given an ID of an instance of this module,
+/// this function will permanently delete the instance
+/// and any data that depends on it.
+
     require('../config.php');
 
     if (! $scorm = get_record('scorm', 'id', $id)) {
@@ -116,30 +116,194 @@ function scorm_delete_instance($id) {
     if (! delete_records('scorm', 'id', $scorm->id)) {
         $result = false;
     }
-    
+
 
     return $result;
 }
 
 function scorm_user_outline($course, $user, $mod, $scorm) {
-/// Return a small object with summary information about what a 
+/// Return a small object with summary information about what a
 /// user has done with a given particular instance of this module
 /// Used for user activity reports.
-/// $return->time = the time they did it
-/// $return->info = a short text description
 
-    return NULL;   // TO FIX
+    $return = NULL;
+    $scores->values = 0;
+    $scores->sum = 0;
+    $scores->max = 0;
+    $scores->lastmodify = 0;
+    $scores->count = 0;
+    if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
+        foreach ($scoes as $sco) {
+            if ($sco->launch!='') {
+               $scores->count++;
+               $userdata = scorm_get_tracks($sco->id, $user->id);
+                if (!isset($scores->{$userdata->status})) {
+                    $scores->{$userdata->status} = 1;
+                } else {    
+                    $scores->{$userdata->status}++;
+                }
+                if (!empty($userdata->score_raw)) {
+                    $scores->values++;
+                    $scores->sum += $userdata->score_raw;
+                    $scores->max = ($userdata->score_raw > $scores->max)?$userdata->score_raw:$scores->max;
+                }
+                if (isset($userdata->timemodified) && ($userdata->timemodified > $scores->lastmodify)) {
+                    $scores->lastmodify = $userdata->timemodified;
+                }
+            }
+        }
+        switch ($scorm->grademethod) {
+            case VALUEHIGHEST:
+               if ($scores->values > 0) {
+                    $return->info = get_string('score','scorm').':&nbsp;'.$scores->max;
+                    $return->time = $scores->lastmodify;
+                }
+            break;
+            case VALUEAVERAGE:
+                if ($scores->values > 0) {
+                    $return->info = get_string('score','scorm').':&nbsp;'.$scores->sum/$scores->values;
+                    $return->time = $scores->lastmodify;
+                }
+            break;
+            case VALUESUM:
+                if ($scores->values > 0) {
+                    $return->info = get_string('score','scorm').':&nbsp;'.$scores->sum;
+                    $return->time = $scores->lastmodify;
+                }
+            break;
+            case VALUESCOES:
+                $return->info = '';
+                $scores->notattempted = $scores->count;
+                if (isset($scores->completed)) {
+                   $return->info .= get_string('completed','scorm').':&nbsp;'.$scores->completed.'<br />';
+                    $scores->notattempted -= $scores->completed;
+                }
+                if (isset($scores->passed)) {
+                   $return->info .= get_string('passed','scorm').':&nbsp;'.$scores->passed.'<br />';
+                    $scores->notattempted -= $scores->passed;
+                }
+                if (isset($scores->failed)) {
+                   $return->info .= get_string('failed','scorm').':&nbsp;'.$scores->failed.'<br />';
+                    $scores->notattempted -= $scores->failed;
+                }
+                if (isset($scores->incomplete)) {
+                   $return->info .= get_string('incomplete','scorm').':&nbsp;'.$scores->incomplete.'<br />';
+                    $scores->notattempted -= $scores->incomplete;
+                }
+                if (isset($scores->browsed)) {
+                   $return->info .= get_string('browsed','scorm').':&nbsp;'.$scores->browsed.'<br />';
+                    $scores->notattempted -= $scores->browsed;
+                }
+                $return->time = $scores->lastmodify;
+                if ($return->info == '') {
+                    $return = NULL;
+                } else {
+                   $return->info .= get_string('notattempted','scorm').':&nbsp;'.$scores->notattempted.'<br />';
+                }
+            break;
+        }
+    }
+    return $return;
 }
 
 function scorm_user_complete($course, $user, $mod, $scorm) {
-/// Print a detailed representation of what a  user has done with 
+/// Print a detailed representation of what a  user has done with
 /// a given particular instance of this module, for user activity reports.
+    global $CFG;
 
-    return true;   // TO FIX
+    $liststyle = 'structlist';
+    $scormpixdir = $CFG->wwwroot.'/mod/scorm/pix/';
+
+    echo "<ul id='0' class='$liststyle'>";
+    $currentorg = '';
+    $organizationsql = '';
+    if (!empty($currentorg)) {
+        $organizationsql = "AND organization='$currentorg'";
+    }
+    if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
+        $level=0;
+        $sublist=1;
+        $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++;
+            } else {
+                echo '<img src="'.$scormpixdir.'spacer.gif" />';
+            }
+
+            if ($sco->launch) {
+                $score = '';
+                $totaltime = '';
+                if ($usertrack=scorm_get_tracks($sco->id,$user->id)) {
+                    if ($usertrack->status == '') {
+                        $usertrack->status = 'notattempted';
+                    }
+                    $strstatus = get_string($usertrack->status,'scorm');
+                    echo "<img src='".$scormpixdir.$usertrack->status.".gif' alt='$strstatus' title='$strstatus' />";
+                    if ($usertrack->score_raw != '') {
+                        $score = get_string('score','scorm').':&nbsp;'.$usertrack->score_raw;
+                    }
+                    if ($usertrack->total_time != '00:00:00') {
+                        $totaltime = get_string('totaltime','scorm').':&nbsp;'.$usertrack->total_time;
+                        if (!empty($score)) {
+                            $totaltime = ' - '.$totaltime;
+                        }
+                    }
+                } else {
+                    if ($sco->scormtype == 'sco') {
+                        echo '<img src="'.$scormpixdir.'notattempted.gif" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
+                    } else {
+                        echo '<img src="'.$scormpixdir.'asset.gif" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
+                    }
+                }
+                echo "&nbsp;$sco->title</li>\n";
+                if ($usertrack !== false) {
+                    echo "\t\t\t<li><ul class='$liststyle'>\n";
+                    foreach($usertrack as $element => $value) {
+                        if (substr($element,0,3) == 'cmi') {
+                            echo '<li>'.$element.' => '.$value.'</li>';
+                        }
+                    }
+                    echo "\t\t\t</ul></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";
+
+    return true;
 }
 
 function scorm_print_recent_activity(&$logs, $isteacher=false) {
-/// Given a list of logs, assumed to be those since the last login 
+/// Given a list of logs, assumed to be those since the last login
 /// this function prints a short list of changes related to this module
 /// If isteacher is true then perhaps additional information is printed.
 /// This function is called from course/lib.php: print_recent_activity()
@@ -149,8 +313,8 @@ function scorm_print_recent_activity(&$logs, $isteacher=false) {
 
 function scorm_cron () {
 /// Function to be run periodically according to the moodle cron
-/// This function searches for things that need to be done, such 
-/// as sending out mail, toggling flags etc ... 
+/// This function searches for things that need to be done, such
+/// as sending out mail, toggling flags etc ...
 
     global $CFG;
 
@@ -158,16 +322,16 @@ function scorm_cron () {
 }
 
 function scorm_grades($scormid) {
-/// Must return an array of grades for a given instance of this module, 
+/// Must return an array of grades for a given instance of this module,
 /// indexed by user.  It also returns a maximum allowed grade.
 
     global $CFG;
-    
+
     if (!$scorm = get_record('scorm', 'id', $scormid)) {
         return NULL;
     }
     if (!$scoes = get_records('scorm_scoes','scorm',$scormid)) {
-    return NULL;
+        return NULL;
     }
 
     if ($scorm->grademethod == VALUESCOES) {
@@ -177,19 +341,19 @@ function scorm_grades($scormid) {
     } else {
         $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->scoes = 0;
             $scores->values = 0;
-        $scores->max = 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')) { 
+                if (($userdata->status == 'completed') || ($userdata->status == 'passed')) {
                     $scores->scoes++;
                 }
                 if (!empty($userdata->score_raw)) {
@@ -201,20 +365,20 @@ function scorm_grades($scormid) {
             switch ($scorm->grademethod) {
                 case VALUEHIGHEST:
                     $return->grades[$scouser->userid] = $scores->max;
-                    break;
+                break;
                 case VALUEAVERAGE:
-                    if ($score->values > 0) {
+                    if ($scores->values > 0) {
                         $return->grades[$scouser->userid] = $scores->sum/$scores->values;
                     } else {
                         $return->grades[$scouser->userid] = 0;
                     }
-                    break;
+                break;
                 case VALUESUM:
                     $return->grades[$scouser->userid] = $scores->sum;
-                    break;
+                break;
                 case VALUESCOES:
                     $return->grades[$scouser->userid] = $scores->scoes;
-                    break;
+                break;
             }
        }
     }
@@ -223,34 +387,33 @@ function scorm_grades($scormid) {
 
 
 //////////////////////////////////////////////////////////////////////////////////////
-/// Any other scorm functions go here.  Each of them must have a name that 
+/// Any other scorm functions go here.  Each of them must have a name that
 /// starts with scorm_
 
 
-function scorm_randstring($len = '8')
-{
-        $rstring = NULL;
-        $lchar = '';
-        for($i=0; $i<$len; $i++) {
-                $char = chr(rand(48,122));
-                while (!ereg('[a-zA-Z0-9]', $char)){
-                        if($char == $lchar) continue;
-                        $char = chr(rand(48,90));
-                }
-                $rstring .= $char;
-                $lchar = $char;
+function scorm_randstring($len = '8') {
+    $rstring = NULL;
+    $lchar = '';
+    for ($i=0; $i<$len; $i++) {
+        $char = chr(rand(48,122));
+        while (!ereg('[a-zA-Z0-9]', $char)){
+            if ($char == $lchar) continue;
+            $char = chr(rand(48,90));
         }
-        return $rstring;
+        $rstring .= $char;
+        $lchar = $char;
+    }
+    return $rstring;
 }
 
+
 function scorm_datadir($strPath, $existingdir='')
 {
     global $CFG;
 
     if (($existingdir!='') && (is_dir($strPath.'/'.$existingdir)))
         return $strPath.'/'.$existingdir;
-        
+
     if (is_dir($strPath)) {
         do {
             $datadir='/'.scorm_randstring();
@@ -261,10 +424,9 @@ function scorm_datadir($strPath, $existingdir='')
     } else {
         return false;
     }
-} 
+}
 
-function scorm_validate($packagedir)
-{
+function scorm_validate($packagedir) {
     if (is_file($packagedir.'/imsmanifest.xml')) {
         $validation->result = 'found';
         $validation->pkgtype = 'SCORM';
@@ -291,11 +453,9 @@ function scorm_validate($packagedir)
 function scorm_delete_files($directory) {
     if (is_dir($directory)) {
         $files=scorm_scandir($directory);
-        //print_r($files);
         foreach($files as $file) {
             if (($file != '.') && ($file != '..')) {
                 if (!is_dir($directory.'/'.$file)) {
-                    //chmod($directory.'/'.$file,0777);
                     unlink($directory.'/'.$file);
                 } else {
                     scorm_delete_files($directory.'/'.$file);
@@ -324,57 +484,60 @@ function scorm_scandir($directory) {
 function scorm_startElement($parser, $name, $attrs) {
 
     global $scoes,$i,$resources,$parent,$level,$organization,$manifest,$defaultorg;
-    
+
     switch ($name) {
-    case 'ITEM':
-        $i++;
-        $scoes[$i]['manifest'] = $manifest;
-        $scoes[$i]['organization'] = $organization;
-        $scoes[$i]['identifier'] = $attrs['IDENTIFIER'];
-        if (empty($attrs['IDENTIFIERREF']))
-            $attrs['IDENTIFIERREF'] = '';
-        $scoes[$i]['identifierref'] = $attrs['IDENTIFIERREF'];
-        if (empty($attrs['ISVISIBLE']))
-            $attrs['ISVISIBLE'] = '';
-        $scoes[$i]['isvisible'] = $attrs['ISVISIBLE'];
-        if (empty($attrs['PARAMETERS']))
-            $attrs['PARAMETERS'] = '';
-        $scoes[$i]['parameters'] = $attrs['PARAMETERS'];
-        $scoes[$i]['parent'] = $parent[$level];
-        $level++;
-        $parent[$level] = $attrs['IDENTIFIER'];
-    break;
-    case 'RESOURCE':
-        if (!isset($attrs['HREF'])) {
-            $attrs['HREF'] = '';
-        }
-        $resources[$attrs['IDENTIFIER']]['href']=$attrs['HREF'];
-        if (!isset($attrs['ADLCP:SCORMTYPE'])) {
-            $attrs['ADLCP:SCORMTYPE'] = 'sco'; //Default scorm type
-        }
-        $resources[$attrs['IDENTIFIER']]['scormtype']=$attrs['ADLCP:SCORMTYPE'];
-    break;
-    case 'ORGANIZATION':
-        $i++;
-        $scoes[$i]['manifest'] = $manifest;
-        $scoes[$i]['organization'] = '';
-        $scoes[$i]['identifier'] = $attrs['IDENTIFIER'];
-        $scoes[$i]['identifierref'] = '';
-        $scoes[$i]['isvisible'] = '';
-        $scoes[$i]['parent'] = $parent[$level];
-        $level++;
-        $parent[$level] = $attrs['IDENTIFIER'];
-        $organization = $attrs['IDENTIFIER'];
-    break;
-    case 'MANIFEST':
-        $manifest = $attrs['IDENTIFIER'];
-    break;
-    case 'ORGANIZATIONS':
-        if (!isset($attrs['DEFAULT'])) {
-            $attrs['DEFAULT'] = '';
-        }
-        $defaultorg = $attrs['DEFAULT'];
-    break;
+        case 'ITEM':
+            $i++;
+            $scoes[$i]['manifest'] = $manifest;
+            $scoes[$i]['organization'] = $organization;
+            $scoes[$i]['identifier'] = $attrs['IDENTIFIER'];
+            if (empty($attrs['IDENTIFIERREF'])) {
+                $attrs['IDENTIFIERREF'] = '';
+            }
+            $scoes[$i]['identifierref'] = $attrs['IDENTIFIERREF'];
+            if (empty($attrs['ISVISIBLE'])) {
+                $attrs['ISVISIBLE'] = '';
+            }
+            $scoes[$i]['isvisible'] = $attrs['ISVISIBLE'];
+            if (empty($attrs['PARAMETERS'])) {
+                $attrs['PARAMETERS'] = '';
+            }
+            $scoes[$i]['parameters'] = $attrs['PARAMETERS'];
+            $scoes[$i]['parent'] = $parent[$level];
+            $level++;
+            $parent[$level] = $attrs['IDENTIFIER'];
+        break;
+        case 'RESOURCE':
+            if (!isset($attrs['HREF'])) {
+                $attrs['HREF'] = '';
+            }
+            $resources[$attrs['IDENTIFIER']]['href']=$attrs['HREF'];
+            if (!isset($attrs['ADLCP:SCORMTYPE'])) {
+                $attrs['ADLCP:SCORMTYPE'] = 'sco'; //Default scorm type
+            }
+            $resources[$attrs['IDENTIFIER']]['scormtype']=$attrs['ADLCP:SCORMTYPE'];
+        break;
+        case 'ORGANIZATION':
+            $i++;
+            $scoes[$i]['manifest'] = $manifest;
+            $scoes[$i]['organization'] = '';
+            $scoes[$i]['identifier'] = $attrs['IDENTIFIER'];
+            $scoes[$i]['identifierref'] = '';
+            $scoes[$i]['isvisible'] = '';
+            $scoes[$i]['parent'] = $parent[$level];
+            $level++;
+            $parent[$level] = $attrs['IDENTIFIER'];
+            $organization = $attrs['IDENTIFIER'];
+        break;
+        case 'MANIFEST':
+            $manifest = $attrs['IDENTIFIER'];
+        break;
+        case 'ORGANIZATIONS':
+            if (!isset($attrs['DEFAULT'])) {
+                $attrs['DEFAULT'] = '';
+            }
+            $defaultorg = $attrs['DEFAULT'];
+        break;
     }
 }
 
@@ -416,8 +579,8 @@ function scorm_endElement($parser, $name) {
         if (preg_match("/^(1\.2)$|^(CAM )?(1\.3)$/",$datacontent,$matches)) {
             $version = 'SCORM_'.$matches[count($matches)-1];
         } else {
-           $version = 'SCORM_1.2';
-       }
+            $version = 'SCORM_1.2';
+        }
     }
 }
 
@@ -481,14 +644,14 @@ function scorm_parse_aicc($pkgdir,$scormid){
                     if (preg_match("/^(.+)=(.+)$/",$row,$matches)) {
                         switch (strtolower(trim($matches[1]))) {
                             case 'course_id':
-                                $courses[$courseid]->id = trim($matches[2]); 
-                                break;
+                                $courses[$courseid]->id = trim($matches[2]);
+                            break;
                             case 'course_title':
                                 $courses[$courseid]->title = trim($matches[2]);
-                                break;
+                            break;
                             case 'version':
                                 $courses[$courseid]->version = 'AICC_'.trim($matches[2]);
-                                break;
+                            break;
                         }
                     }
                 }
@@ -505,122 +668,115 @@ function scorm_parse_aicc($pkgdir,$scormid){
                         $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);
+            $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->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->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->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->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;
-            }
-        if (isset($course->elements)) {
-        foreach($course->elements as $element) {
+        foreach ($courses as $course) {
             unset($sco);
-            $sco->identifier = $element->system_id;
+            $sco->identifier = $course->id;
             $sco->scorm = $scormid;
-                $sco->organization = $course->id;
-            $sco->title = $element->title;
-            if (strtolower($element->parent) == 'root') {
+            $sco->organization = '';
+            $sco->title = $course->title;
             $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->launch = '';
             $sco->scormtype = '';
+            //print_r($sco);
+            $id = insert_record('scorm_scoes',$sco);
+            if ($launch == 0) {
+                $launch = $id;
             }
-            if (!isset($element->prerequisites)) {
-                $element->prerequisites = '';
-                    } 
+            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 = '';
-                    } 
+                    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 = '';
-                    } 
+                        $element->time_limit_action = '';
+                    }
                     $sco->timelimitaction = $element->time_limit_action;
                     if (!isset($element->mastery_score)) {
-                $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;
+                    $id = insert_record('scorm_scoes',$sco);
+                    if ($launch==0) {
+                        $launch = $id;
+                    }
+                }
             }
         }
-        }
-    }
     }
-    if (isset($courses[0]->version)) {
-    $version = $courses[0]->version;
-    }
-    set_field('scorm','version',$version,'id',$scormid);
+    set_field('scorm','version','AICC','id',$scormid);
     return $launch;
 }
 
@@ -649,8 +805,8 @@ function scorm_parse_scorm($pkgdir,$file,$scormid) {
     while ($data = fread($fp, 4096)) {
         if (!xml_parse($xmlparser, $data, feof($fp))) {
             die(sprintf('XML error: %s at line %d',
-                    xml_error_string(xml_get_error_code($xmlparser)),
-                    xml_get_current_line_number($xmlparser)));
+            xml_error_string(xml_get_error_code($xmlparser)),
+            xml_get_current_line_number($xmlparser)));
         }
     }
     xml_parser_free($xmlparser);
@@ -659,7 +815,7 @@ function scorm_parse_scorm($pkgdir,$file,$scormid) {
     $sco->scorm = $scormid;
     delete_records('scorm_scoes','scorm',$scormid);
     delete_records('scorm_scoes_track','scormid',$scormid);
-    
+
     if (isset($scoes[1])) {
         for ($j=1; $j<=$i; $j++) {
             $sco->identifier = $scoes[$j]['identifier'];
@@ -668,58 +824,58 @@ function scorm_parse_scorm($pkgdir,$file,$scormid) {
             $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;
+                $scoes[$j]['previous'] = 0;
             }
             $sco->previous = $scoes[$j]['previous'];
-        
+
             if (!isset($scoes[$j]['continue'])) {
-            $scoes[$j]['continue'] = 0;
+                $scoes[$j]['continue'] = 0;
             }
             $sco->next = $scoes[$j]['continue'];
-        
+
             if (scorm_remove_spaces($scoes[$j]['isvisible']) != 'false') {
-            $id = insert_record('scorm_scoes',$sco);
+                $id = insert_record('scorm_scoes',$sco);
             }
             if (($launch==0) && ($defaultorg==$sco->identifier)) {
-            $launch = $id;
+                $launch = $id;
             }
-    }
+        }
     } else {
         foreach ($resources as $label => $resource) {
             if (!empty($resource['href'])) {
@@ -729,9 +885,9 @@ function scorm_parse_scorm($pkgdir,$file,$scormid) {
                 $sco->launch = $resource['href'];
                 $sco->scormtype = $resource['type'];
                 $id = insert_record('scorm_scoes',$sco);
-                
+
                 if ($launch == 0) {
-                $launch = $id;
+                    $launch = $id;
                 }
             }
         }
@@ -741,47 +897,48 @@ function scorm_parse_scorm($pkgdir,$file,$scormid) {
 }
 
 function scorm_get_tracks($scoid,$userid) {
-/// Gets all tracks of specified sco and user 
+/// Gets all tracks of specified sco and user
     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;
+        $usertrack->timemodified = 0;
+        foreach ($tracks as $track) {
+            $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;
+            }
+            if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified)) {
+                $usertrack->timemodified = $track->timemodified;
+            }
         }
-    }
-    //print_r($usertrack);
-    return $usertrack;
+        return $usertrack;
     } else {
-    return false;
+        return false;
     }
 }
 
@@ -789,37 +946,40 @@ function scorm_get_user_data($userid) {
 /// Gets user info required to display the table of scorm results
 /// for report.php
 
-    return get_record('user','id',$userid,'','','','','firstname, lastname, picture'); 
+    return get_record('user','id',$userid,'','','','','firstname, lastname, picture');
 }
 
 function scorm_remove_spaces($sourcestr) {
 // Remove blank space from a string
     $newstr='';
     for( $i=0; $i<strlen($sourcestr); $i++) {
-        if ($sourcestr[$i]!=' ')
+        if ($sourcestr[$i]!=' ') {
             $newstr .=$sourcestr[$i];
+        }
     }
     return $newstr;
 }
 
 function scorm_string_round($stringa, $len=11) {
 // Crop a string to $len character and set an anchor title to the full string
-    if ( strlen($stringa)>$len ) {
-    return '<a name="none" title="'.$stringa.'">'.substr($stringa,0,$len-4).'...'.substr($stringa,strlen($stringa)-1,1).'</a>';
-    } else
-    return $stringa;
+    if (strlen($stringa)>$len) {
+        return '<a name="none" title="'.$stringa.'">'.substr($stringa,0,$len-4).'...'.substr($stringa,strlen($stringa)-1,1).'</a>';
+    } else {
+        return $stringa;
+    }
 }
 
 function scorm_external_link($link) {
 // check if a link is external
     $result = false;
     $link = strtolower($link);
-    if (substr($link,0,7) == 'http://')
+    if (substr($link,0,7) == 'http://') {
         $result = true;
-    else if (substr($link,0,8) == 'https://')
+    } else if (substr($link,0,8) == 'https://') {
         $result = true;
-    else if (substr($link,0,4) == 'www.')
+    } else if (substr($link,0,4) == 'www.') {
         $result = true;
+    }
     return $result;
 }
 
@@ -829,120 +989,116 @@ function scorm_count_launchable($scormid,$organization) {
 
 function scorm_display_structure($scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$play=false) {
     global $USER;
-    
+
     $strexpand = get_string('expcoll','scorm');
-    
+
     echo "<ul id='0' class='$liststyle'>";
     $incomplete = false;
     $organizationsql = '';
-    if (empty($currentorg)) {
-        //
-    } else {
+    if (!empty($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; 
+        $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++;
+                if ($level>0 && $parents[$level-1]==$sco->parent) {
+                    echo "\t\t</ul></li>\n";
+                    $level--;
                 } else {
-                    echo $closelist;
-                    $level = $i;
+                    $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;
                 }
-                $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>';
+                $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" />';
+                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';
+                    $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;
+                    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.')';
                     }
-                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;
+                    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').'" />';
+                    }
                 }
-            $shownext = $sco->next;
-            $showprev = $sco->previous;
+                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)) {
+                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";
+                echo "&nbsp;$startbold<a href='javascript:playSCO(".$sco->id.");'>$sco->title</a> $score$endbold</li>\n";
             } else {
-        echo "&nbsp;$sco->title</li>\n";
+                echo "&nbsp;$sco->title</li>\n";
+            }
+        }
+        for ($i=0;$i<$level;$i++) {
+            echo "\t\t</ul></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;
     }
index 65e62a5..a8166b5 100755 (executable)
@@ -5,7 +5,7 @@
     optional_variable($id);    // Course Module ID, or
     optional_variable($a);     // scorm ID
     optional_variable($scoid); // sco ID
-    optional_variable($mode); // lesson mode
+    optional_variable($mode);  // lesson mode
 
     if ($id) {
         if (! $cm = get_record("course_modules", "id", $id)) {
     }
 
     require_login($course->id, false, $cm);
-    
-
-    if (!empty($scoid)) {      
+    if (!empty($scoid)) {
     //
     // 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);
-               }
+                // 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);
+        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_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)) {
         if (stripos($sco->launch,'?') !== false) {
             $connector = '&';
         } else {
-           $connector = '?';
-       }
+            $connector = '?';
+        }
     }
     if (scorm_external_link($sco->launch)) {
         if ($version == 'AICC') {
             if (!empty($sco->parameters)) {
-               $sco->parameters = '&'. $sco->parameters;
+                $sco->parameters = '&'. $sco->parameters;
             }
             $result = $sco->launch.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
         } else {
 <html>
     <head>
         <title>LoadSCO</title>
-       <script language="javascript" type="text/javascript">
-       <!--
-           setTimeout('document.location = "<?php echo $result ?>";',1000);
-       -->
-       </script>
+        <script language="javascript" type="text/javascript">
+        <!--
+            setTimeout('document.location = "<?php echo $result ?>";',1000);
+        -->
+        </script>
     </head>
     <body>
         &nbsp;
index 50d42c9..a6df35f 100755 (executable)
 <script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
 <script type="text/javascript">
     function validate_scorm(theform,filename) {
-       //alert(filename);
+       //alert(filename);
         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);
+       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 = '';
             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;
+               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")) {
@@ -98,7 +98,7 @@
         } else {
             result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
             if (errorlogs != '') {
-               result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
+               result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
             }
             alert(result);
             return false;
                 <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
             </td>
         </tr>
-<?php 
+<?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) ?>
-               </font>
+               <font size="1">
+               <?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
+              </font>
             </td>
             <td>
         <?php print_textarea($usehtmleditor, 10, 50, 680, 400, "summary", $form->summary); ?>
         </tr>
         <tr valign="top">
             <td align="right" nowrap="nowrap">
-               <b><?php echo $strfilename?>:</b>
+                <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);
-               ?>
+                <?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">
                 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>
         <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" />
+               <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 align="right"><b><?php print_string("height","scorm") ?>:</b></td>
             <td>
-               <input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
+               <input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
                 <?php helpbutton("height", get_string("height", "scorm"), "scorm", true); ?>
             </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="launch" value="<?php p($form->launch) ?>" />
-    
-    <input type="hidden" name="course" value="<?php p($form->course) ?>" />
-    <input type="hidden" name="sesskey"        value="<?php p($form->sesskey) ?>" />
-    <input type="hidden" name="coursemodule"   value="<?php p($form->coursemodule) ?>" />
-    <input type="hidden" name="section"        value="<?php p($form->section) ?>" />
-    <input type="hidden" name="module" value="<?php p($form->module) ?>" />
-    <input type="hidden" name="modulename"     value="<?php p($form->modulename) ?>" />
-    <input type="hidden" name="instance"       value="<?php p($form->instance) ?>" />
-    <input type="hidden" name="mode"           value="<?php p($form->mode) ?>" />
+    <input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
+    <input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
+    <input type="hidden" name="launch"  value="<?php p($form->launch) ?>" />
+
+    <input type="hidden" name="course"  value="<?php p($form->course) ?>" />
+    <input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
+    <input type="hidden" name="section" value="<?php p($form->section) ?>" />
+    <input type="hidden" name="module"  value="<?php p($form->module) ?>" />
+    <input type="hidden" name="mode"    value="<?php p($form->mode) ?>" />
+    <input type="hidden" name="coursemodule"    value="<?php p($form->coursemodule) ?>" />
+    <input type="hidden" name="modulename"      value="<?php p($form->modulename) ?>" />
+    <input type="hidden" name="instance"        value="<?php p($form->instance) ?>" />
     <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 ?>'" />
index be9fc61..df03680 100755 (executable)
         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 (! $scorm = get_record('scorm', 'id', $cm->instance)) {
             error('Course module is incorrect');
         }
     }
 
     require_login($course->id, false, $cm);
-    
+
     $strscorms = get_string('modulenameplural', 'scorm');
     $strscorm  = get_string('modulename', 'scorm');
-       
+
     if ($course->category) {
         $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
                        <a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
     $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
 
     if (!$cm->visible and !isteacher($course->id)) {
-        print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true, 
+        print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
                      update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
         notice(get_string("activityiscurrentlyhidden"));
     }
-    
+
     //
     // Checkin script parameters
     //
     $currentorg = $_POST['currentorg'];
     $currentorgstring = '&currentorg='.$currentorg;
     }
-    
+
     $strexpand = get_string('expcoll','scorm');
     $strpopup = get_string('popup','scorm');
-    
+
     //
     // Print the page header
     //
-    
-    //$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));
 ?>
-    
-    <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="fullscreen">
+    <tr><td class="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 class="structurehead"><?php print_string('coursestruct','scorm') ?></div>
+                    <!--<div class="popupbutton">
+                        <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 class="top">
 <?php
-    $sco = scorm_display_structure($scorm,'scormlist',$currentorg,$scoid,$mode,true);
+    $sco = scorm_display_structure($scorm,'structurelist',$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';
+        $mode = 'review';
         }
     }
     }
 
     $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 class="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>
+    <td class="top" width="<?php print $scorm->width ?>">
+        <iframe name="main" width="<?php print $scorm->width ?>" height="<?php echo $scorm->height ?>" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></iframe>
     </td></tr>
     </table>
-    <style type="text/css">
-        .scormlist { 
-            list-style-type:none; 
-            text-indent:-4ex;
-        } 
-    </style>
     <script language="javascript" type="text/javascript">
     <!--
         function playSCO(scoid) {
             if (scoid == 0) {
-               document.location = 'view.php?id=<?php echo $cm->id ?>';
+                document.location = '<?php echo $CFG->wwwroot ?>/course/view.php?id=<?php echo $cm->course ?>';
             } else {
-               document.navform.scoid.value=scoid;
-               document.navform.submit();
+                document.navform.scoid.value=scoid;
+                document.navform.submit();
             }
         }
 
-    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;
-    }
+        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;
+        }
 
-    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";
-       
-           if (eval(beg+list+mid+".display") != "none") {
-               which.src = "pix/plus.gif";
-               eval(beg+list+mid+".display='none';");
-           } else {
-               which.src = "pix/minus.gif";
-               eval(beg+list+mid+".display='block';");
-           }
-       }
+            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";
+
+            if (eval(beg+list+mid+".display") != "none") {
+                which.src = "pix/plus.gif";
+                eval(beg+list+mid+".display='none';");
+            } else {
+                which.src = "pix/minus.gif";
+                eval(beg+list+mid+".display='block';");
+            }
+        }
     -->
     </script>
     <script language="JavaScript" type="text/javascript" src="request.js"></script>
index 10ef7d8..c4d90e6 100755 (executable)
@@ -6,18 +6,16 @@
     require_once("lib.php");
 
     optional_variable($id);    // Course Module ID, or
-    optional_variable($b);   // SCO ID 
-    optional_variable($user);
+    optional_variable($b);     // SCO ID
+    optional_variable($user);  // User ID
 
     if ($id) {
         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 (! $scorm = get_record("scorm", "id", $cm->instance)) {
             error("Course module is incorrect");
         }
@@ -34,7 +32,6 @@
         if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
             error("Course Module ID was incorrect");
         }
-    
     }
 
     require_login($course->id, false, $cm);
@@ -47,7 +44,6 @@
 
 /// Print the page header
     if (empty($noheader)) {
-
         if ($course->category) {
             $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
         } else {
         $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->wrap = array('nowrap', 'nowrap');
-               $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[] = '*';
-           }
+                $table->head = array('&nbsp;', $strname);
+                $table->align = array('center', 'left');
+                $table->wrap = array('nowrap', 'nowrap');
+                $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[] = '*';
+                    }
                 }
 
-       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');
+                notice('No users to report');
+            }
         }
-    }
     } else {
-    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();
+        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";
+                foreach($trackdata as $element => $value) {
+                    if (substr($element,0,3) == 'cmi') {
+                        echo $element.' => '.$value.'<br />';
+                    }
+                }
+                print_simple_box_end();
+            }
+        } else {
+            error('Missing script parameter');
         }
-    } else {
-        error('Missing script parameter');
-    }
     }
     if (empty($noheader)) {
         print_footer($course);
     }
-
-
 ?>
index bcc66bc..7b87671 100644 (file)
@@ -21,16 +21,16 @@ function NewHttpReq() {
 }
 
 function DoRequest(httpReq,url,param) {
-    //
+
     // httpReq.open (Method("get","post"), URL(string), Asyncronous(true,false))
-    //
-    httpReq.open("get", url+'?'+param,false);
-    //httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-    httpReq.send(null);
+
+    httpReq.open("POST", url,false);
+    httpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+    httpReq.send(param);
     if (httpReq.status == 200) {
-       return httpReq.responseText;
+        return httpReq.responseText;
     } else {
-       return httpReq.status;
+        return httpReq.status;
     }
 }
 
index 5e3a937..57ecd13 100755 (executable)
@@ -4,18 +4,18 @@
 
     //This is the "graphical" structure of the scorm mod:
     //
-    //                      scorm                                      
+    //                      scorm
     //                   (CL,pk->id)---------------------
-    //                        |                                |
-    //                        |                                |
-    //                        |                                |
-    //                   scorm_scoes                   |       
-    //             (UL,pk->id, fk->scorm)              |
-    //                        |                                |
-    //                        |                                |
-    //                        |                                |
-    //                scorm_scoes_track                |
-    //  (UL,pk->id, fk->scormid, fk->scoid, fk->userid)--      
+    //                        |                         |
+    //                        |                         |
+    //                        |                         |
+    //                   scorm_scoes                    |
+    //             (UL,pk->id, fk->scorm)               |
+    //                        |                         |
+    //                        |                         |
+    //                        |                         |
+    //                scorm_scoes_track                 |
+    //  (UL,pk->id, fk->scormid, fk->scoid, fk->userid)--
     //
     // Meaning: pk->primary key field of the table
     //          fk->foreign key to link with parent
             $scorm->launch = backup_todb($info['MOD']['#']['LAUNCH']['0']['#']);
             $scorm->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
             $scorm->auto = backup_todb($info['MOD']['#']['AUTO']['0']['#']);
+            $scorm->width = backup_todb($info['MOD']['#']['WIDTH']['0']['#']);
+            $scorm->height = backup_todb($info['MOD']['#']['HEIGHT']['0']['#']);
             $scorm->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
 
             //The structure is equal to the db, so insert the scorm
             $newid = insert_record ("scorm",$scorm);
-            //Do some output     
+            //Do some output
             echo "<li>".get_string("modulename","scorm")." \"".format_string(stripslashes($scorm->name),true)."\"</li>";
             backup_flush(300);
 
                 //We have the newid, update backup_ids
                 backup_putid($restore->backup_unique_code,$mod->modtype,
                              $mod->id, $newid);
-                             
+
                 //Now copy moddata associated files
                 $status = scorm_restore_files ($scorm, $restore);
-                
+
                 if ($status)
                     $status = scorm_scoes_restore_mods ($newid,$info,$restore);
-                    
+
             } else {
                 $status = false;
             }
@@ -97,7 +99,7 @@
 
             //We'll need this later!!
             $oldid = backup_todb($sub_info['#']['ID']['0']['#']);
-            
+
             //Now, build the scorm_scoes record structure
             $sco->scorm = $scorm_id;
             $sco->manifest = backup_todb($sub_info['#']['MANIFEST']['0']['#']);
 
             //The structure is equal to the db, so insert the scorm_scoes
             $newid = insert_record ("scorm_scoes",$sco);
-            
+
             //Now check if want to restore user data and do it.
             if ($restore->mods['scorm']->userinfo) {
                 //Restore scorm_scoes
                 }
                 backup_flush(300);
             }
-            
+
             if ($newid) {
                 //We have the newid, update backup_ids
                 backup_putid($restore->backup_unique_code,"scorm_scoes", $oldid, $newid);
 
         return $status;
     }
-    
+
     //This function restores the scorm_scoes_track
     function scorm_scoes_tracks_restore_mods($scorm_id,$info,$restore) {
 
             if ($user) {
                 $sco_track->userid = $user->new_id;
             }
-            
+
             //We have to recode the scoid field
             $sco = backup_getid($restore->backup_unique_code,"scorm_scoes",$sco_track->scoid);
             if ($sco) {
 
         return $status;
     }
-    
+
     //This function copies the scorm related info from backup temp dir to course moddata folder,
     //creating it if needed
     function scorm_restore_files ($package, $restore) {
 
         //First, locate course's moddata directory
         $moddata_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
-  
+
         //Check it exists and create it
         $status = check_dir_exists($moddata_path,true);
 
         if ($status and $todo) {
             //Make scorm package directory path
             $this_scorm_path = $scorm_path."/".$package->id;
-       
+
             $status = backup_copy_file($temp_path, $this_scorm_path);
         }
 
         return $status;
     }
-    
+
     //This function returns a log record with all the necessay transformations
     //done. It's used by restore_log_module() to restore modules log.
     function scorm_restore_logs($restore,$log) {
-                    
+
         $status = true;
-                    
+
         return $status;
     }
 ?>
diff --git a/mod/scorm/styles.php b/mod/scorm/styles.php
new file mode 100644 (file)
index 0000000..f4843de
--- /dev/null
@@ -0,0 +1,35 @@
+.top {
+  vertical-align: top;
+}
+.center {
+  text-align: center;
+}
+.fullscreen {
+  width: 100%;
+}
+.structlist  {
+  list-style-type: none;
+  white-space: nowrap;
+  font-size: small;
+}
+
+#mod-scorm-playscorm .structurehead {
+  float: left;
+}
+#mod-scorm-playscorm .structurelist {
+  list-style-type: none;
+  text-indent:-4ex;
+  font-size: small;
+}
+#mod-scorm-playscorm .popupbutton {
+  float: right;
+}
+
+#mod-scorm-view .structurehead {
+  font-weight: bold;
+  text-align: center;
+}
+#mod-scorm-view .structurelist  {
+  list-style-type: none;
+  white-space: nowrap;
+}
index 37b42e5..6ba14a2 100755 (executable)
@@ -6,71 +6,69 @@ require_once("lib.php");
 require_login();
 
 if (confirm_sesskey()) {
-    $reference = clean_param($_GET["reference"], PARAM_PATH);
-    $courseid = $_GET["id"];
+    $reference = clean_param($_POST["reference"], PARAM_PATH);
+    $courseid = $_POST["id"];
     $launch = 0;
-    if (isset($_GET["instance"])) {
-    $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;
-               if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
-                   // This is a new package
-           $launch = 0;
-               } else {
-                   // Old package already validated
-           $validation->result = 'found';
-           if (strpos($scorm->version,'AICC') !== false) {
-               $validation->pkgtype = 'AICC';
-           } else {
-               $validation->pkgtype = 'SCORM';
-           }
-       }
-           } else {
-       $validation->result = 'badinstance';
-       $launch = -1;
+    if (isset($_POST["instance"])) {
+        $scormid = $_POST["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;
+                if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
+                    // This is a new package
+                    $launch = 0;
+                } else {
+                    // Old package already validated
+                    $validation->result = 'found';
+                    if (strpos($scorm->version,'AICC') !== false) {
+                        $validation->pkgtype = 'AICC';
+                    } else {
+                        $validation->pkgtype = 'SCORM';
+                    }
+                }
+            } else {
+                $validation->result = 'badinstance';
+                $launch = -1;
+            }
+        } else {
+            $validation->result = 'badreference';
+            $launch = -1;
         }
-       } else {
-        $validation->result = 'badreference';
-        $launch = -1;
     }
-    } 
     //$launch = 0;
     if ($launch == 0) {
-       //
-       // Package must be validated
-       //
-    
+        //
+        // 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";
-       }
+        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);
+                    unlink ($tempdir."/".basename($reference));
+                    $validation = scorm_validate($tempdir);
+                } else {
+                    $validation->result = "packagefile";
+                }
+            } else {
+                $validation->result = "packagedir";
+            }
         } else {
-       $validation->result = "packagedir";
+            $validation->result = "datadir";
         }
-    } else {
-        $validation->result = "datadir";
-    }
-    if (($validation->result != "regular") && ($validation->result != "found")) {
-        $validation->result = get_string($validation->result,'scorm');
+        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);
-            } else {
-                // Delete package file
-                unlink ($tempdir."/".basename($reference));
             }
         } else {
             $datadir = substr($tempdir,strlen($scormdir));
@@ -79,25 +77,21 @@ if (confirm_sesskey()) {
     //
     // Print validation result
     //
-    echo 'result=' . $validation->result . "\n"; 
+    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);
-    }*/
 } else {
-    echo 'result=' . get_string('badrequest','scorm') . "\n"; 
+    echo 'result=' . get_string('badrequest','scorm') . "\n";
 }
 ?>
-    
index 18622ec..d4e83b7 100755 (executable)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2005050800;   // The (date) version of this module
+$module->version  = 2005052200;   // The (date) version of this module
 $module->requires = 2005021600;   // The version of Moodle that is required
 $module->cron     = 0;            // How often should cron check this module (seconds)?
 
index 2b89a4a..2f01c6d 100755 (executable)
         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 (! $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");
     }
 
     require_login($course->id, false, $cm);
-    
+
     if (isset($SESSION->scorm_scoid)) {
         unset($SESSION->scorm_scoid);
     }
-    
+
     $strscorms = get_string("modulenameplural", "scorm");
     $strscorm  = get_string("modulename", "scorm");
 
         $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
     }
 
-    $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
-    
-    add_to_log($course->id, "scorm", "pre-view", "view.php?id=$cm->id", "$scorm->id");
-    
+    $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
+
+    add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
+
     //
     // Print the page header
     //
     if (!$cm->visible and !isteacher($course->id)) {
-        print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), "", "", true, 
-        update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
-        notice(get_string("activityiscurrentlyhidden"));
+        print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
+                     update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
+        notice(get_string('activityiscurrentlyhidden'));
     } else {
-        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), navmenu($course, $cm));
-        
+        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), navmenu($course, $cm));
+
         if (isteacher($course->id)) {
             if ($trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c')) {
-            echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string("viewallreports","scorm",$trackedusers->c)."</a></div>";
+                echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
             } else {
-               echo "<div class=\"reportlink\">".get_string("noreports","scorm")."</div>";
+                echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
             }
         }
         // Print the main part of the page
             print_footer($course);
             exit;
         }
-        echo "<br />";
-        $liststyle = "style=\"list-style-type:none;\"";
-        print_simple_box_start("center");
-        echo "<table>\n";
-        echo "  <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
+        print_simple_box_start('center');
+?>
+        <div class="structurehead"><?php print_string('coursestruct','scorm') ?></div>
+<?php
         $organization = $scorm->launch;
         if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) {
             if (count($orgs) > 1) {
-            if (isset($_POST['organization'])) {
-                $organization = $_POST['organization'];
+                if (isset($_POST['organization'])) {
+                    $organization = $_POST['organization'];
+                }
+?>
+            <div class='center'>
+               <?php print_string('organizations','scorm') ?>
+                <form name='changeorg' method='post' action='view.php?id=<?php echo $cm->id ?>'>
+                    <?php choose_from_menu($orgs, 'organization', "$organization", '','submit()') ?>
+                </form>
+            </div>
+<?php
             }
-            echo "<tr><td align='center'><form name='changeorg' method='post' action='view.php?id=$cm->id'>".get_string('organizations','scorm').": \n";
-            choose_from_menu($orgs, 'organization', "$organization", '','submit()');
-            echo "</form></td></tr>\n"; 
         }
-    }
-    $orgidentifier = '';
-    if ($org = get_record('scorm_scoes','id',$organization)) {
-        if (($org->organization == '') && ($org->launch == '')) {
-            $orgidentifier = $org->identifier;
-        } else {
-            $orgidentifier = $org->organization;
+        $orgidentifier = '';
+        if ($org = get_record('scorm_scoes','id',$organization)) {
+            if (($org->organization == '') && ($org->launch == '')) {
+                $orgidentifier = $org->identifier;
+            } else {
+                $orgidentifier = $org->organization;
+            }
         }
-    }
-    echo "  <tr><td nowrap=\"nowrap\">\n";
-    $incomplete = scorm_display_structure($scorm,'scormlist',$orgidentifier);
-    echo "</td></tr>\n";
-    echo "</table>\n";
-    print_simple_box_end();
-    echo "<form name=\"theform\" method=\"post\" action=\"playscorm.php?id=$cm->id\">\n";
-    echo "<table align=\"center\">\n<tr>\n<td align=\"center\">";
+?>
+            <?php $incomplete = scorm_display_structure($scorm,'structurelist',$orgidentifier); ?>
+    <?php print_simple_box_end(); ?>
+    <div class="center">
+        <form name="theform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>">
+<?php
     if ($scorm->browsemode == 1) {
         print_string("mode","scorm");
-        echo ": <input type=\"radio\" id=\"b\" name=\"mode\" value=\"browse\" /><label for=\"b\">".get_string("browse","scorm")."</label>\n";
+        echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">'.get_string('browse','scorm').'</label>'."\n";
         if ($incomplete === true) {
-            echo "<input type=\"radio\" id=\"n\" name=\"mode\" value=\"normal\" checked=\"checked\" /><label for=\"n\">".get_string("normal","scorm")."</label>\n";
+            echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">'.get_string('normal','scorm')."</label>\n";
         } else {
-            echo "<input type=\"radio\" id=\"r\" name=\"mode\" value=\"review\" checked=\"checked\" /><label for=\"r\">".get_string("review","scorm")."</label>\n";
+            echo '<input type="radio" id="r" name="mode" value="review" checked="checked" /><label for="r">'.get_string('review','scorm')."</label>\n";
         }
     } else {
         if ($incomplete === true) {
         } else {
             echo '<input type="hidden" name="mode" value="review" />'."\n";
         }
-    }    
-    echo "</td>\n</tr>\n<tr><td align=\"center\">";
-    echo '<input type="hidden" name="scoid" />
-    <input type="hidden" name="currentorg" value="'.$orgidentifier.'" />
-    <input type="submit" value="'.get_string("entercourse","scorm").'" />';
-    echo "\n</td>\n</tr>\n</table>\n</form><br />";
+    }
 ?>
-<style type="text/css">
-        .scormlist { 
-            list-style-type:none; 
-        } 
-</style>
+            <br />
+            <input type="hidden" name="scoid" />
+            <input type="hidden" name="currentorg" value="<?php echo $orgidentifier ?>" />
+            <input type="submit" value="<? print_string('entercourse','scorm') ?>" />
+        </form>
+    </div>
 <script language="javascript" type="text/javascript">
 <!--
     function playSCO(scoid) {
         document.theform.scoid.value = scoid;
         document.theform.submit();
     }
-    
+
     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";
-        
+
         if (eval(beg+list+mid+".display") != "none") {
             which.src = "pix/plus.gif";
             eval(beg+list+mid+".display='none';");
         } else {
             which.src = "pix/minus.gif";
             eval(beg+list+mid+".display='block';");
-        }    
+        }
     }
 -->
 </script>