MDL-14620 - fix link to repository and tidy up using $CFG vars merged from HEAD

This commit is contained in:
danmarsden
2008-08-21 01:54:10 +00:00
parent d730018ff2
commit 20a2a2c49d
5 changed files with 16 additions and 28 deletions
+5 -3
View File
@@ -63,7 +63,7 @@ function scorm_get_manifest($blocks,$scoes) {
}
break;
case 'ORGANIZATIONS':
if (!isset($scoes->defaultorg)) {
if (!isset($scoes->defaultorg) && isset($block['attrs']['DEFAULT'])) {
$scoes->defaultorg = addslashes($block['attrs']['DEFAULT']);
}
$scoes = scorm_get_manifest($block['children'],$scoes);
@@ -489,7 +489,9 @@ function scorm_parse_scorm($pkgdir,$scormid) {
$newitem->organization = $organization;
$standarddatas = array('parent', 'identifier', 'launch', 'scormtype', 'title');
foreach ($standarddatas as $standarddata) {
$newitem->$standarddata = addslashes($item->$standarddata);
if (isset($item->$standarddata)) {
$newitem->$standarddata = addslashes($item->$standarddata);
}
}
// Insert the new SCO, and retain the link between the old and new for later adjustment
@@ -791,4 +793,4 @@ class xml2Array {
}
?>
?>
+3 -3
View File
@@ -85,9 +85,9 @@ function scorm_update_instance($scorm) {
$scorm->launch = $packagedata->launch;
$scorm->datadir = $packagedata->datadir;
$scorm->parse = 1;
if (!scorm_external_link($scorm->reference)) {
if (!scorm_external_link($scorm->reference) && $scorm->reference[0] != '#') { //dont set md5hash if this is from a repo.
$scorm->md5hash = md5_file($CFG->dataroot.'/'.$scorm->course.'/'.$scorm->reference);
} else {
} elseif($scorm->reference[0] != '#') { //dont set md5hash if this is from a repo.
$scorm->dir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
$scorm->md5hash = md5_file($scorm->dir.$scorm->datadir.'/'.basename($scorm->reference));
}
@@ -634,4 +634,4 @@ function scorm_get_extra_capabilities() {
return array('moodle/site:accessallgroups');
}
?>
?>
-1
View File
@@ -95,7 +95,6 @@
$result = $launcher;
} else if ($scorm->reference[0] == '#') {
// Repository
require_once($repositoryconfigfile);
$result = $CFG->repositorywebroot.substr($scorm->reference,1).'/'.$sco->launch;
} else {
if ((basename($scorm->reference) == 'imsmanifest.xml') && scorm_external_link($scorm->reference)) {
+6 -19
View File
@@ -67,12 +67,6 @@ if (!isset($CFG->scorm_windowsettings)) {
set_config('scorm_windowsettings','0');
}
//
// Repository configurations
//
$repositoryconfigfile = $CFG->dirroot.'/mod/resource/type/ims/repository_config.php';
$repositorybrowser = '/mod/resource/type/ims/finder.php';
/// Local Library of functions for module scorm
/**
@@ -667,11 +661,10 @@ function scorm_simple_play($scorm,$user) {
}
*/
function scorm_parse($scorm) {
global $CFG,$repositoryconfigfile;
global $CFG;
if ($scorm->reference[0] == '#') {
require_once($repositoryconfigfile);
if ($CFG->repositoryactivate) {
if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
$referencedir = $CFG->repository.substr($scorm->reference,1);
}
} else {
@@ -688,9 +681,6 @@ function scorm_parse($scorm) {
$scorm->launch = scorm_parse_aicc($referencedir, $scorm->id);
} else {
require_once('datamodels/scormlib.php');
if ($scorm->reference[0] == '#') {
require_once($repositoryconfigfile);
}
$scorm->launch = scorm_parse_scorm($referencedir,$scorm->id);
}
return $scorm->launch;
@@ -772,8 +762,7 @@ function scorm_validate($data) {
}
if ($reference[0] == '#') {
require_once($repositoryconfigfile);
if ($CFG->repositoryactivate) {
if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
$reference = $CFG->repository.substr($reference,1).'/imsmanifest.xml';
} else {
$validation->errors['reference'] = get_string('badpackage','scorm');
@@ -864,8 +853,7 @@ function scorm_check_package($data) {
if (empty($reference)) {
$validation = null;
} else if ($reference[0] == '#') {
require_once($repositoryconfigfile);
if ($CFG->repositoryactivate) {
if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
$referencefield = $reference.'/imsmanifest.xml';
$reference = $CFG->repository.substr($reference,1).'/imsmanifest.xml';
} else {
@@ -895,8 +883,7 @@ function scorm_check_package($data) {
if ($scorm = get_record('scorm','id',$scormid)) {
if ($scorm->reference[0] == '#') {
require_once($repositoryconfigfile);
if ($CFG->repositoryactivate) {
if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
$oldreference = $CFG->repository.substr($scorm->reference,1).'/imsmanifest.xml';
} else {
$oldreference = $scorm->reference;
@@ -1025,4 +1012,4 @@ function scorm_get_count_users($scormid, $groupingid=null) {
return(count_records_sql($sql));
}
?>
?>
+2 -2
View File
@@ -30,7 +30,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->setHelpButton('summary', array('writing', 'questions', 'richtext'), false, 'editorhelpbutton');
// Reference
$mform->addElement('choosecoursefile', 'reference', get_string('package','scorm'));
$mform->addElement('choosecoursefileorimsrepo', 'reference', get_string('package','scorm'));
$mform->setType('reference', PARAM_RAW); // We need to find a better PARAM
$mform->addRule('reference', get_string('required'), 'required');
$mform->setHelpButton('reference',array('package', get_string('package', 'scorm'), 'scorm'));
@@ -254,4 +254,4 @@ class mod_scorm_mod_form extends moodleform_mod {
}
}
?>
?>