Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a problem during scorm update.

Now tracks are deleted only if the scoes are really changed
  • Loading branch information...
commit 0fc250371841ddd40f15022966af270469c21204 1 parent f5c2ff5
bobopinna authored
View
91 mod/scorm/lib.php
@@ -47,6 +47,12 @@
set_config('scorm_framewidth','100%');
}
+//
+// Repository configurations
+//
+$repositoryconfigfile = $CFG->dirroot.'/mod/resource/type/ims/repository_config.php';
+$repositorybrowser = '/mod/resource/type/ims/finder.php';
+
/**
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
@@ -73,14 +79,14 @@ function scorm_add_instance($scorm) {
$id = insert_record('scorm', $scorm);
- if (basename($scorm->reference) != 'imsmanifest.xml') {
+ if ((basename($scorm->reference) != 'imsmanifest.xml') && ($scorm->reference[0] != '#')) {
// 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) {
+ if ($scorm->parse == 1) {
require_once('locallib.php');
$scorm->id = $id;
$scorm->launch = scorm_parse($scorm);
@@ -111,18 +117,17 @@ function scorm_update_instance($scorm) {
$scorm->height = str_replace('%','',$scorm->height);
// Check if scorm manifest needs to be reparsed
- if ($scorm->launch == 0) {
- // Delete old related records
- delete_records('scorm_scoes','scorm',$scorm->id);
- delete_records('scorm_scoes_track','scormid',$scorm->id);
-
+ if ($scorm->parse == 1) {
+ require_once('locallib.php');
$scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
- if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id) && (basename($scorm->reference) != 'imsmanifest.xml')) {
+ if (is_dir($scorm->dir.'/'.$scorm->id)) {
scorm_delete_files($scorm->dir.'/'.$scorm->id);
+ }
+ if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id) &&
+ (basename($scorm->reference) != 'imsmanifest.xml') && ($scorm->reference[0] != '#')) {
rename($scorm->dir.$scorm->datadir,$scorm->dir.'/'.$scorm->id);
}
- require_once('locallib.php');
$scorm->launch = scorm_parse($scorm);
}
return update_record('scorm', $scorm);
@@ -147,6 +152,7 @@ function scorm_delete_instance($id) {
$result = true;
// Delete any dependent files
+ require_once('locallib.php');
scorm_delete_files($CFG->dataroot.'/'.$scorm->course.'/moddata/scorm/'.$scorm->id);
// Delete any dependent records
@@ -186,8 +192,8 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
require_once('locallib.php');
foreach ($scoes as $sco) {
if ($sco->launch!='') {
- $scores->count++;
- if ($userdata = scorm_get_tracks($sco->id, $user->id)) {
+ $scores->count++;
+ if ($userdata = scorm_get_tracks($sco->id, $user->id)) {
if (!isset($scores->{$userdata->status})) {
$scores->{$userdata->status} = 1;
} else {
@@ -206,7 +212,7 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
}
switch ($scorm->grademethod) {
case GRADEHIGHEST:
- if ($scores->values > 0) {
+ if ($scores->values > 0) {
$return->info = get_string('score','scorm').': '.$scores->max;
$return->time = $scores->lastmodify;
}
@@ -227,30 +233,30 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
$return->info = '';
$scores->notattempted = $scores->count;
if (isset($scores->completed)) {
- $return->info .= get_string('completed','scorm').':&nbsp;'.$scores->completed.'<br />';
+ $return->info .= get_string('completed','scorm').':&nbsp;'.$scores->completed.'<br />';
$scores->notattempted -= $scores->completed;
}
if (isset($scores->passed)) {
- $return->info .= get_string('passed','scorm').':&nbsp;'.$scores->passed.'<br />';
+ $return->info .= get_string('passed','scorm').':&nbsp;'.$scores->passed.'<br />';
$scores->notattempted -= $scores->passed;
}
if (isset($scores->failed)) {
- $return->info .= get_string('failed','scorm').':&nbsp;'.$scores->failed.'<br />';
+ $return->info .= get_string('failed','scorm').':&nbsp;'.$scores->failed.'<br />';
$scores->notattempted -= $scores->failed;
}
if (isset($scores->incomplete)) {
- $return->info .= get_string('incomplete','scorm').':&nbsp;'.$scores->incomplete.'<br />';
+ $return->info .= get_string('incomplete','scorm').':&nbsp;'.$scores->incomplete.'<br />';
$scores->notattempted -= $scores->incomplete;
}
if (isset($scores->browsed)) {
- $return->info .= get_string('browsed','scorm').':&nbsp;'.$scores->browsed.'<br />';
+ $return->info .= get_string('browsed','scorm').':&nbsp;'.$scores->browsed.'<br />';
$scores->notattempted -= $scores->browsed;
}
$return->time = $scores->lastmodify;
if ($return->info == '') {
$return = NULL;
} else {
- $return->info .= get_string('notattempted','scorm').':&nbsp;'.$scores->notattempted.'<br />';
+ $return->info .= get_string('notattempted','scorm').':&nbsp;'.$scores->notattempted.'<br />';
}
break;
}
@@ -388,7 +394,7 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
echo get_string('report','scorm').":<br />\n";
echo $report;
} else {
- print_string('noactivity','scorm');
+ print_string('noactivity','scorm');
}
return true;
@@ -465,53 +471,6 @@ function scorm_get_post_actions() {
return array();
}
-/**
-* This function will permanently delete the given
-* directory and all files and subdirectories.
-*
-* @param string $directory The directory to remove
-* @return boolean
-*/
-function scorm_delete_files($directory) {
- if (is_dir($directory)) {
- $files=scorm_scandir($directory);
- foreach($files as $file) {
- if (($file != '.') && ($file != '..')) {
- if (!is_dir($directory.'/'.$file)) {
- unlink($directory.'/'.$file);
- } else {
- scorm_delete_files($directory.'/'.$file);
- }
- }
- set_time_limit(5);
- }
- rmdir($directory);
- return true;
- }
- return false;
-}
-
-/**
-* Given a diretory path returns the file list
-*
-* @param string $directory
-* @return array
-*/
-function scorm_scandir($directory) {
- if (version_compare(phpversion(),'5.0.0','>=')) {
- return scandir($directory);
- } else {
- $files = array();
- if ($dh = opendir($directory)) {
- while (($file = readdir($dh)) !== false) {
- $files[] = $file;
- }
- closedir($dh);
- }
- return $files;
- }
-}
-
function scorm_option2text($scorm) {
global $SCORM_POPUP_OPTIONS;
View
7 mod/scorm/loadSCO.php
@@ -4,7 +4,7 @@
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
- $scoid = required_param('scoid', PARAM_INT); // sco ID
+ $scoid = required_param('scoid', PARAM_INT); // sco ID
if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
@@ -33,7 +33,7 @@
require_login($course->id, false, $cm);
if (!empty($scoid)) {
//
- // Direct sco request
+ // Direct SCO request
//
if ($sco = get_record("scorm_scoes","id",$scoid)) {
if ($sco->launch == '') {
@@ -79,6 +79,9 @@
if (scorm_external_link($sco->launch)) {
$result = $launcher;
+ } else if ($scorm->reference[0] == '#') {
+ require_once($repositoryconfigfile);
+ $result = $CFG->repositorywebroot.substr($scorm->reference,1).'/'.$sco->launch;
} else {
if (basename($scorm->reference) == 'imsmanifest.xml') {
$basedir = dirname($scorm->reference);
View
146 mod/scorm/locallib.php
@@ -2,6 +2,62 @@
/// Local Library of functions and constants for module scorm
+//
+// Repository configurations
+//
+$repositoryconfigfile = $CFG->dirroot.'/mod/resource/type/ims/repository_config.php';
+$repositorybrowser = '/mod/resource/type/ims/finder.php';
+
+
+/// Local Library of functions and constants for module scorm
+
+/**
+* This function will permanently delete the given
+* directory and all files and subdirectories.
+*
+* @param string $directory The directory to remove
+* @return boolean
+*/
+function scorm_delete_files($directory) {
+ if (is_dir($directory)) {
+ $files=scorm_scandir($directory);
+ foreach($files as $file) {
+ if (($file != '.') && ($file != '..')) {
+ if (!is_dir($directory.'/'.$file)) {
+ unlink($directory.'/'.$file);
+ } else {
+ scorm_delete_files($directory.'/'.$file);
+ }
+ }
+ set_time_limit(5);
+ }
+ rmdir($directory);
+ return true;
+ }
+ return false;
+}
+
+/**
+* Given a diretory path returns the file list
+*
+* @param string $directory
+* @return array
+*/
+function scorm_scandir($directory) {
+ if (version_compare(phpversion(),'5.0.0','>=')) {
+ return scandir($directory);
+ } else {
+ $files = array();
+ if ($dh = opendir($directory)) {
+ while (($file = readdir($dh)) !== false) {
+ $files[] = $file;
+ }
+ closedir($dh);
+ }
+ return $files;
+ }
+}
+
/**
* Create a new temporary subdirectory with a random name in the given path
*
@@ -127,9 +183,6 @@ function scorm_eval_prerequisites($prerequisites,$usertracks) {
case '(':
case ')':
case '*':
- //case '{':
- //case '}':
- //case ',':
$element = trim($element);
if (!empty($element)) {
@@ -256,7 +309,6 @@ function scorm_eval_prerequisites($prerequisites,$usertracks) {
return eval('return '.implode($stack).';');
}
-
function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value) {
$id = null;
if ($track = get_record_select('scorm_scoes_track',"userid='$userid' AND scormid='$scormid' AND scoid='$scoid' AND attempt='$attempt' AND element='$element'")) {
@@ -276,7 +328,6 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value) {
return $id;
}
-
function scorm_add_time($a, $b) {
$aes = explode(':',$a);
$bes = explode(':',$b);
@@ -664,23 +715,29 @@ function scorm_get_tracks($scoid,$userid,$attempt='') {
}
}
-
/// Library of functions and constants for parsing packages
function scorm_parse($scorm) {
- global $CFG;
+ global $CFG,$repositoryconfigfile;
// Parse scorm manifest
if ($scorm->pkgtype == 'AICC') {
$scorm->launch = scorm_parse_aicc($scorm->dir.'/'.$scorm->id,$scorm->id);
} else {
- if (basename($scorm->reference) != 'imsmanifest.xml') {
+ $reference = $scorm->reference;
+ if ($scorm->reference[0] == '#') {
+ require_once($repositoryconfigfile);
+ $reference = $CFG->repository.substr($scorm->reference,1).'/imsmanifest.xml';
+ } else if (substr($reference,0,7) != 'http://') {
+ $reference = $CFG->dataroot.'/'.$scorm->course.'/'.$scorm->reference;
+ }
+
+ if (basename($reference) != 'imsmanifest.xml') {
$scorm->launch = scorm_parse_scorm($scorm->dir.'/'.$scorm->id,$scorm->id);
} else {
- $scorm->launch = scorm_parse_scorm($CFG->dataroot.'/'.$scorm->course.'/'.dirname($scorm->reference),$scorm->id);
+ $scorm->launch = scorm_parse_scorm(dirname($reference),$scorm->id);
}
}
-
return $scorm->launch;
}
@@ -737,7 +794,7 @@ function scorm_parse_aicc($pkgdir,$scormid) {
$extaiccfiles = array('crs','des','au','cst','ort','pre','cmp');
if ($handle = opendir($pkgdir)) {
while (($file = readdir($handle)) !== false) {
- if ($file[0] != '.') {
+ if ($file[0] != '.') {
$ext = substr($file,strrpos($file,'.'));
$extension = strtolower(substr($ext,1));
if (in_array($extension,$extaiccfiles)) {
@@ -827,6 +884,9 @@ function scorm_parse_aicc($pkgdir,$scormid) {
}
}
//print_r($courses);
+
+ $oldscoes = get_records('scorm_scoes','scorm',$scormid);
+
$launch = 0;
if (isset($courses)) {
foreach ($courses as $course) {
@@ -838,8 +898,15 @@ function scorm_parse_aicc($pkgdir,$scormid) {
$sco->parent = '/';
$sco->launch = '';
$sco->scormtype = '';
+
//print_r($sco);
- $id = insert_record('scorm_scoes',$sco);
+ if (get_record('scorm_scoes','scorm',$scormid,'identifier',$sco->identifier)) {
+ $id = update_record('scorm_scoes',$sco);
+ unset($oldscoes[$id]);
+ } else {
+ $id = insert_record('scorm_scoes',$sco);
+ }
+
if ($launch == 0) {
$launch = $id;
}
@@ -880,7 +947,13 @@ function scorm_parse_aicc($pkgdir,$scormid) {
$sco->masteryscore = $element->mastery_score;
$sco->previous = 0;
$sco->next = 0;
- $id = insert_record('scorm_scoes',$sco);
+ if ($oldscoid = scorm_array_search('identifier',$sco->identifier,$oldscoes)) {
+ $sco->id = $oldscoid;
+ $id = update_record('scorm_scoes',$sco);
+ unset($oldscoes[$oldscoid]);
+ } else {
+ $id = insert_record('scorm_scoes',$sco);
+ }
if ($launch==0) {
$launch = $id;
}
@@ -888,11 +961,18 @@ function scorm_parse_aicc($pkgdir,$scormid) {
}
}
}
+ if (!empty($oldscoes)) {
+ foreach($oldscoes as $oldsco) {
+ delete_records('scorm_scoes','id',$oldsco->id);
+ delete_records('scorm_scoes_track','scoid',$oldsco->id);
+ }
+ }
set_field('scorm','version','AICC','id',$scormid);
return $launch;
}
function scorm_get_resources($blocks) {
+ $resources = array();
foreach ($blocks as $block) {
if ($block['name'] == 'RESOURCES') {
foreach ($block['children'] as $resource) {
@@ -978,7 +1058,7 @@ function scorm_get_manifest($blocks,$scoes) {
case 'ITEM':
$parent = array_pop($parents);
array_push($parents, $parent);
-
+
$identifier = addslashes($block['attrs']['IDENTIFIER']);
$scoes->elements[$manifest][$organization][$identifier]->identifier = $identifier;
$scoes->elements[$manifest][$organization][$identifier]->parent = $parent->identifier;
@@ -1068,7 +1148,6 @@ function scorm_get_manifest($blocks,$scoes) {
}
}
}
-
return $scoes;
}
@@ -1083,19 +1162,26 @@ function scorm_parse_scorm($pkgdir,$scormid) {
$xmlstring = file_get_contents($manifestfile);
$objXML = new xml2Array();
$manifests = $objXML->parse($xmlstring);
-
+ // print_r($manifests);
$scoes = new stdClass();
$scoes->version = '';
$scoes = scorm_get_manifest($manifests,$scoes);
if (count($scoes->elements) > 0) {
+ $olditems = get_records('scorm_scoes','scorm',$scormid);
foreach ($scoes->elements as $manifest => $organizations) {
foreach ($organizations as $organization => $items) {
foreach ($items as $identifier => $item) {
$item->scorm = $scormid;
$item->manifest = $manifest;
$item->organization = $organization;
- $id = insert_record('scorm_scoes',$item);
+ if ($olditemid = scorm_array_search('identifier',$item->identifier,$olditems)) {
+ $item->id = $olditemid;
+ $id = update_record('scorm_scoes',$item);
+ unset($olditems[$olditemid]);
+ } else {
+ $id = insert_record('scorm_scoes',$item);
+ }
if (($launch == 0) && ((empty($scoes->defaultorg)) || ($scoes->defaultorg == $identifier))) {
$launch = $id;
@@ -1103,6 +1189,12 @@ function scorm_parse_scorm($pkgdir,$scormid) {
}
}
}
+ if (!empty($olditems)) {
+ foreach($olditems as $olditem) {
+ delete_records('scorm_scoes','id',$olditem->id);
+ delete_records('scorm_scoes_track','scoid',$olditem->id);
+ }
+ }
set_field('scorm','version',$scoes->version,'id',$scormid);
}
}
@@ -1110,6 +1202,23 @@ function scorm_parse_scorm($pkgdir,$scormid) {
return $launch;
}
+function scorm_array_search($item, $needle, $haystacks, $strict=false) {
+ if (!empty($haystacks)) {
+ foreach ($haystacks as $key => $element) {
+ if ($strict) {
+ if ($element->{$item} === $needle) {
+ return $key;
+ }
+ } else {
+ if ($element->{$item} == $needle) {
+ return $key;
+ }
+ }
+ }
+ }
+ return false;
+}
+
function scorm_course_format_display($user,$course) {
global $CFG;
@@ -1151,7 +1260,7 @@ function scorm_course_format_display($user,$course) {
} else {
if (isteacheredit($course->id, $user->id)) {
// Create a new activity
- redirect('mod.php?id='.$course->id.'&amp;section=0&sesskey='.sesskey().'&amp;add=scorm');
+ redirect('mod.php?id='.$course->id.'&amp;section=0&sesskey='.sesskey().'&amp;add=scorm');
} else {
notify('Could not find a scorm course here');
}
@@ -1231,7 +1340,6 @@ function scorm_view_display ($user, $scorm, $action, $cm, $blockwidth='') {
<?php
}
-
function scorm_repeater($what, $times) {
if ($times <= 0) {
return null;
View
45 mod/scorm/mod.html
@@ -79,6 +79,7 @@
$strfilename = get_string('coursepacket', 'scorm');
$strchooseafile = get_string('chooseapacket', 'scorm');
+ $strbrowserepository = get_string('browserepository', 'scorm');
$striframe = get_string('iframe', 'scorm');
$striframedisplay = get_string('iframedisplay', 'scorm');
$strnewwindow = get_string('popup', 'scorm');
@@ -96,9 +97,14 @@
<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
<script type="text/javascript">
- function validate_scorm(theform,filename) {
+ function validate_scorm(theform,filename,confirmed) {
+ var confirmedstr = '';
+ if (confirmed == true) {
+ confirmedstr = '&confirmed=true';
+ }
+
var myRequest = NewHttpReq();
- result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
+ result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>"+confirmedstr);
//alert(result);
results = result.split('\n');
result = '';
@@ -133,19 +139,28 @@
theform.datadir.value = datadir;
theform.pkgtype.value = pkgtype;
theform.launch.value = launch;
- if (launch == 0) {
- if ('<?php echo $scormid ?>' != '') {
- return confirm('<?php print_string('trackingloose','scorm') ?>');
- }
+ if (theform.mode.value == 'add') {
+ theform.parse.value = 1;
+ } else if (launch == 0) {
+ theform.parse.value = 1;
}
return true;
} else {
- result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
- if (errorlogs != '') {
- result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
+ if (result == "confirm") {
+ response = confirm("<?php print_string('confirmloosetracks','scorm') ?>");
+ if (response == true) {
+ return validate_scorm(theform,filename,true);
+ } else {
+ return false;
+ }
+ } else {
+ result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
+ if (errorlogs != '') {
+ result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
+ }
+ alert(result);
+ return false;
}
- alert(result);
- return false;
}
}
@@ -183,7 +198,7 @@
}
</script>
-<form name="form" method="post" action="mod.php" onsubmit="return validate_scorm(document.form,document.form.reference.value);">
+<form name="form" method="post" action="mod.php" onsubmit="return validate_scorm(document.form,document.form.reference.value,false,false);">
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string('name') ?>:</b></td>
@@ -208,6 +223,11 @@
<?php
button_to_popup_window ('/files/index.php?id='.$course->id.'&amp;choose=form.reference',
'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
+ require_once($repositoryconfigfile);
+ if ($CFG->repositoryactivate) {
+ button_to_popup_window ($repositorybrowser.'?choose=form.reference',
+ 'browserepository', $strbrowserepository, 500, 750, $strbrowserepository);
+ }
helpbutton('package', get_string('coursepacket', 'scorm'), 'scorm', true);
?>
</td>
@@ -401,6 +421,7 @@
<input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
<input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
<input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
+ <input type="hidden" name="parse" value="0" />
<?php
$scorms = get_all_instances_in_course('scorm', $course);
$coursescorm = current($scorms);
View
57 mod/scorm/validate.php
@@ -2,34 +2,67 @@
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
- $scormid = optional_param('instance', '', PARAM_INT); // scorm ID
+ $courseid = required_param('id', PARAM_INT); // Course Module ID
+ $reference = required_param('reference', PARAM_PATH); // Package path
+ $scormid = optional_param('instance', '', PARAM_INT); // scorm ID
+ $confirmed = optional_param('confirmed', false, PARAM_BOOL); // This package is changed and some tracks could be lost.
+ // Has the editor confirmed to continue?
require_login($courseid, false);
if (confirm_sesskey() && !empty($courseid)) {
$launch = 0;
$validation = new stdClass();
+ $referencefield = $reference;
if (empty($reference)) {
$launch = -1;
$validation->result = "packagefile";
+ } else if ($reference[0] == '#') {
+ require_once($repositoryconfigfile);
+ if ($CFG->repositoryactivate) {
+ $referencefield = $reference.'/imsmanfest.xml';
+ $reference = $CFG->repository.substr($reference,1).'/imsmanifest.xml';
+ } else {
+ $launch = -1;
+ $validation->result = "packagefile";
+ }
+ } else if (substr($reference,0,7) != 'http://') {
+ $reference = $CFG->dataroot.'/'.$courseid.'/'.$reference;
}
+
if (!empty($scormid)) {
//
// SCORM Update
//
- if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) {
- $fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r");
+ if (($launch != -1) && is_file($reference)) {
+ $fp = fopen($reference,"r");
$fstat = fstat($fp);
fclose($fp);
if ($scorm = get_record("scorm","id",$scormid)) {
+ if ($scorm->reference[0] == '#') {
+ require_once($repositoryconfigfile);
+ if ($CFG->repositoryactivate) {
+ $oldreference = $CFG->repository.substr($scorm->reference,1).'/imsmanifest.xml';
+ } else {
+ $oldreference = $scorm->reference;
+ }
+ } else if (substr($reference,0,7) != 'http://') {
+ $oldreference = $CFG->dataroot.'/'.$courseid.'/'.$scorm->reference;
+ }
$launch = $scorm->launch;
- if ((($scorm->timemodified < $fstat["mtime"]) && ($scorm->reference == $reference)) || ($scorm->reference != $reference)) {
- // This is a new package
- $launch = 0;
+ if ((($scorm->timemodified < $fstat["mtime"]) && ($oldreference == $reference)) || ($oldreference != $reference)) {
+ // This is a new or a modified package
+ if (!$confirmed) {
+ if ($tracks = get_records('scorm_scoes_track','scormid',$scormid)) {
+ $validation->result='confirm';
+ $launch = -1;
+ } else {
+ $launch = 0;
+ }
+ } else {
+ $launch = 0;
+ }
} else {
// Old package already validated
$validation->result = 'found';
@@ -63,7 +96,7 @@
$scormdir = '';
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
if ($tempdir = scorm_datadir($scormdir)) {
- copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
+ copy ("$reference", $tempdir."/".basename($reference));
unzip_file($tempdir."/".basename($reference), $tempdir, false);
unlink ($tempdir."/".basename($reference));
$validation = scorm_validate($tempdir);
@@ -76,7 +109,7 @@
break;
case '.xml':
if (basename($reference) == 'imsmanifest.xml') {
- $validation = scorm_validate("$CFG->dataroot/$courseid/".dirname($reference));
+ $validation = scorm_validate(dirname($reference));
} else {
$validation->result = "manifestfile";
}
@@ -93,7 +126,7 @@
}
} else {
if ($ext == '.xml') {
- $datadir = dirname($reference);
+ $datadir = dirname($referencefield);
} else {
$datadir = substr($tempdir,strlen($scormdir));
}
Please sign in to comment.
Something went wrong with that request. Please try again.