Permalink
Browse files

Modified scorm module to allow remote packages updating

  • Loading branch information...
1 parent 75b4cb6 commit 456f5e6e4319911972603c6a498d7452d6e9fa01 csantossaenz committed Jan 17, 2007
Showing with 17 additions and 6 deletions.
  1. +6 −2 mod/scorm/lib.php
  2. +11 −4 mod/scorm/locallib.php
View
@@ -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);
View
@@ -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 {

0 comments on commit 456f5e6

Please sign in to comment.