Modified scorm module to allow remote packages updating
authorcsantossaenz <csantossaenz>
Wed, 17 Jan 2007 15:53:06 +0000 (15:53 +0000)
committercsantossaenz <csantossaenz>
Wed, 17 Jan 2007 15:53:06 +0000 (15:53 +0000)
mod/scorm/lib.php
mod/scorm/locallib.php

index 1588631..b5afbc3 100755 (executable)
@@ -40,7 +40,9 @@ function scorm_add_instance($scorm) {
     } else {
         global $CFG;
         $scorm->timemodified = time();
-
+               if(substr($scorm->reference,0,7)== 'http://'){
+                       $scorm->md5_result=md5_file($scorm->reference);
+               }
         $scorm = scorm_option2text($scorm);
         $scorm->width = str_replace('%','',$scorm->width);
         $scorm->height = str_replace('%','',$scorm->height);
@@ -110,7 +112,9 @@ function scorm_update_instance($scorm) {
 
     $scorm->timemodified = time();
     $scorm->id = $scorm->instance;
-
+       if(substr($scorm->reference,0,7)== 'http://'){
+                       $scorm->md5_result=md5_file($scorm->reference);
+       }
     $scorm = scorm_option2text($scorm);
     $scorm->width = str_replace('%','',$scorm->width);
     $scorm->height = str_replace('%','',$scorm->height);
index ced2b83..b0b4c6e 100755 (executable)
@@ -687,9 +687,14 @@ function scorm_validate($data) {
         //
         // SCORM Update
         //
-            if (($validation->launch != -1) && is_file($reference)) {
+                       if (($validation->launch != -1) && (is_file($reference) || (substr($reference,0,7) == 'http://'))){
                 $fp = fopen($reference,"r");
-                $fstat = fstat($fp);
+                if (substr($reference,0,7) != 'http://') {
+                                       $fstat = fstat($fp);
+                               }
+                               else if(substr($reference,0,7) == 'http://'){
+                                       $mdcheck=md5_file($reference);
+                               }
                 fclose($fp);
                 if ($scorm = get_record("scorm","id",$scormid)) {
                     if ($scorm->reference[0] == '#') {
@@ -701,9 +706,11 @@ function scorm_validate($data) {
                         }
                     } else if (substr($reference,0,7) != 'http://') {
                         $oldreference = $CFG->dataroot.'/'.$courseid.'/'.$scorm->reference;
-                    }
+                    } else{
+                                               $oldreference = $scorm->reference;
+                                       }
                     $validation->launch = $scorm->launch;
-                    if ((($scorm->timemodified < $fstat["mtime"]) && ($oldreference == $reference)) || ($oldreference != $reference)) {
+                     if ((($scorm->timemodified < $fstat["mtime"]) && ($oldreference == $reference) && (substr($reference,0,7) != 'http://')) || ($oldreference != $reference) || ((substr($reference,0,7) == 'http://') && ($mdcheck != $scorm->md5_result)&& ($oldreference == $reference))) {
                         // This is a new or a modified package
                         $validation->launch = 0;
                     } else {