Permalink
Browse files

Fixes for Bug 5749 and Bug 5750

summary of bug 5749 and 5750
fixes for: function causes timeout when deleting temporary files for large scorm objects
scorm\validate.php calls function scorm_delete_files from scorm\lib.php - but lib.php not included in validate.php

Validation of Scorm objects broken - adds entry in modules database even when scorm object is not created.
  • Loading branch information...
1 parent 146a173 commit 3cfe476b3952bf13636f32bdd29dcb868f654039 danmarsden committed Jul 23, 2006
Showing with 28 additions and 23 deletions.
  1. +26 −22 mod/scorm/lib.php
  2. +1 −1 mod/scorm/locallib.php
  3. +1 −0 mod/scorm/validate.php
View
@@ -57,35 +57,38 @@
* @return int
*/
function scorm_add_instance($scorm) {
+ if(empty($scorm->datadir)) { //check to make sure scorm object is valid BEFORE entering it in the database.
+ error(get_string('nomanifest', 'scorm'));
+ } else {
+ global $CFG;
+ $scorm->timemodified = time();
- global $CFG;
- $scorm->timemodified = time();
+ $scorm = scorm_option2text($scorm);
+ $scorm->width = str_replace('%','',$scorm->width);
+ $scorm->height = str_replace('%','',$scorm->height);
- $scorm = scorm_option2text($scorm);
- $scorm->width = str_replace('%','',$scorm->width);
- $scorm->height = str_replace('%','',$scorm->height);
+ //sanitize submitted values a bit
+ $scorm->width = clean_param($scorm->width, PARAM_INT);
+ $scorm->height = clean_param($scorm->height, PARAM_INT);
- //sanitize submitted values a bit
- $scorm->width = clean_param($scorm->width, PARAM_INT);
- $scorm->height = clean_param($scorm->height, PARAM_INT);
+ $id = insert_record('scorm', $scorm);
- $id = insert_record('scorm', $scorm);
+ if (basename($scorm->reference) != 'imsmanifest.xml') {
+ // Rename temp scorm dir to scorm id
+ $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
+ rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$id);
+ }
- if (basename($scorm->reference) != 'imsmanifest.xml') {
- // Rename temp scorm dir to scorm id
- $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
- rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$id);
- }
+ // Parse scorm manifest
+ if ($scorm->launch == 0) {
+ require_once('locallib.php');
+ $scorm->id = $id;
+ $scorm->launch = scorm_parse($scorm);
+ set_field('scorm','launch',$scorm->launch,'id',$scorm->id);
+ }
- // Parse scorm manifest
- if ($scorm->launch == 0) {
- require_once('locallib.php');
- $scorm->id = $id;
- $scorm->launch = scorm_parse($scorm);
- set_field('scorm','launch',$scorm->launch,'id',$scorm->id);
+ return $id;
}
-
- return $id;
}
/**
@@ -480,6 +483,7 @@ function scorm_delete_files($directory) {
scorm_delete_files($directory.'/'.$file);
}
}
+ set_time_limit(5);
}
rmdir($directory);
return true;
View
@@ -60,7 +60,7 @@ function scorm_validate($packagedir) {
}
closedir($handle);
}
- if (!isset($validation)) {
+ if (!isset($validation->result)) {
$validation->result = 'nomanifest';
$validation->pkgtype = 'SCORM';
}
View
@@ -2,6 +2,7 @@
require_once("../../config.php");
require_once('locallib.php');
+ require_once('lib.php');
$courseid = required_param('id', PARAM_INT); // Course Module ID, or
$reference = required_param('reference', PARAM_PATH); // Package path

0 comments on commit 3cfe476

Please sign in to comment.