From 456f5e6e4319911972603c6a498d7452d6e9fa01 Mon Sep 17 00:00:00 2001 From: csantossaenz Date: Wed, 17 Jan 2007 15:53:06 +0000 Subject: [PATCH] Modified scorm module to allow remote packages updating --- mod/scorm/lib.php | 8 ++++++-- mod/scorm/locallib.php | 15 +++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 15886315c0..b5afbc3f1a 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -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); diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index ced2b83cf0..b0b4c6ed44 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -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 { -- 2.39.5