Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 3cfe476b3952bf13636f32bdd29dcb868f654039 1 parent 146a173
danmarsden authored
48 mod/scorm/lib.php
@@ -57,35 +57,38 @@
57 57 * @return int
58 58 */
59 59 function scorm_add_instance($scorm) {
  60 + if(empty($scorm->datadir)) { //check to make sure scorm object is valid BEFORE entering it in the database.
  61 + error(get_string('nomanifest', 'scorm'));
  62 + } else {
  63 + global $CFG;
  64 + $scorm->timemodified = time();
60 65
61   - global $CFG;
62   - $scorm->timemodified = time();
  66 + $scorm = scorm_option2text($scorm);
  67 + $scorm->width = str_replace('%','',$scorm->width);
  68 + $scorm->height = str_replace('%','',$scorm->height);
63 69
64   - $scorm = scorm_option2text($scorm);
65   - $scorm->width = str_replace('%','',$scorm->width);
66   - $scorm->height = str_replace('%','',$scorm->height);
  70 + //sanitize submitted values a bit
  71 + $scorm->width = clean_param($scorm->width, PARAM_INT);
  72 + $scorm->height = clean_param($scorm->height, PARAM_INT);
67 73
68   - //sanitize submitted values a bit
69   - $scorm->width = clean_param($scorm->width, PARAM_INT);
70   - $scorm->height = clean_param($scorm->height, PARAM_INT);
  74 + $id = insert_record('scorm', $scorm);
71 75
72   - $id = insert_record('scorm', $scorm);
  76 + if (basename($scorm->reference) != 'imsmanifest.xml') {
  77 + // Rename temp scorm dir to scorm id
  78 + $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
  79 + rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$id);
  80 + }
73 81
74   - if (basename($scorm->reference) != 'imsmanifest.xml') {
75   - // Rename temp scorm dir to scorm id
76   - $scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
77   - rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$id);
78   - }
  82 + // Parse scorm manifest
  83 + if ($scorm->launch == 0) {
  84 + require_once('locallib.php');
  85 + $scorm->id = $id;
  86 + $scorm->launch = scorm_parse($scorm);
  87 + set_field('scorm','launch',$scorm->launch,'id',$scorm->id);
  88 + }
79 89
80   - // Parse scorm manifest
81   - if ($scorm->launch == 0) {
82   - require_once('locallib.php');
83   - $scorm->id = $id;
84   - $scorm->launch = scorm_parse($scorm);
85   - set_field('scorm','launch',$scorm->launch,'id',$scorm->id);
  90 + return $id;
86 91 }
87   -
88   - return $id;
89 92 }
90 93
91 94 /**
@@ -480,6 +483,7 @@ function scorm_delete_files($directory) {
480 483 scorm_delete_files($directory.'/'.$file);
481 484 }
482 485 }
  486 + set_time_limit(5);
483 487 }
484 488 rmdir($directory);
485 489 return true;
2  mod/scorm/locallib.php
@@ -60,7 +60,7 @@ function scorm_validate($packagedir) {
60 60 }
61 61 closedir($handle);
62 62 }
63   - if (!isset($validation)) {
  63 + if (!isset($validation->result)) {
64 64 $validation->result = 'nomanifest';
65 65 $validation->pkgtype = 'SCORM';
66 66 }
1  mod/scorm/validate.php
@@ -2,6 +2,7 @@
2 2
3 3 require_once("../../config.php");
4 4 require_once('locallib.php');
  5 + require_once('lib.php');
5 6
6 7 $courseid = required_param('id', PARAM_INT); // Course Module ID, or
7 8 $reference = required_param('reference', PARAM_PATH); // Package path

0 comments on commit 3cfe476

Please sign in to comment.
Something went wrong with that request. Please try again.