]> git.mjollnir.org Git - moodle.git/commitdiff
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 15886315c00f1fa7a89b3b63843f8e8ace9c667a..b5afbc3f1a76b5ea894a4b132d64b9727af0e2c8 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 ced2b83cf09121a6abaa89858e777ab196dee23e..b0b4c6ed44f0b3e33921e8c8e8ea3cdbf6abddc1 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 {