mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Added direct import of manifest files.
Now is possible to select in the package field a imsmanifest.xml file
This commit is contained in:
parent
e112e31851
commit
45b700159a
@ -48,10 +48,11 @@ function scorm_add_instance($scorm) {
|
||||
|
||||
$id = insert_record('scorm', $scorm);
|
||||
|
||||
|
||||
// Rename temp scorm dir to scorm id
|
||||
$scormdir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
|
||||
rename($scormdir.$scorm->datadir,$scormdir.'/'.$id);
|
||||
if (basename($scorm->reference) != 'imsmanifest.xml') {
|
||||
// Rename temp scorm dir to scorm id
|
||||
$scormdir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
|
||||
rename($scormdir.$scorm->datadir,$scormdir.'/'.$id);
|
||||
}
|
||||
|
||||
// Parse scorm manifest
|
||||
if ($scorm->launch == 0) {
|
||||
@ -59,7 +60,11 @@ function scorm_add_instance($scorm) {
|
||||
if ($scorm->pkgtype == 'AICC') {
|
||||
$scorm->launch = scorm_parse_aicc($scormdir.'/'.$id,$id);
|
||||
} else {
|
||||
$scorm->launch = scorm_parse_scorm($scormdir.'/'.$id,$id);
|
||||
if (basename($scorm->reference) != 'imsmanifest.xml') {
|
||||
$scorm->launch = scorm_parse_scorm($scormdir.'/'.$id,$id);
|
||||
} else {
|
||||
$scorm->launch = scorm_parse_scorm($CFG->dataroot.'/'.$scorm->course.'/'.dirname($scorm->reference),$id);
|
||||
}
|
||||
}
|
||||
set_field('scorm','launch',$scorm->launch,'id',$id);
|
||||
}
|
||||
@ -89,7 +94,7 @@ function scorm_update_instance($scorm) {
|
||||
delete_records('scorm_scoes_track','scormid',$scorm->id);
|
||||
|
||||
$scormdir = $CFG->dataroot.'/'.$scorm->course.'/moddata/scorm';
|
||||
if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id)) {
|
||||
if (isset($scorm->datadir) && ($scorm->datadir != $scorm->id) && (basename($scorm->reference) != 'imsmanifest.xml')) {
|
||||
scorm_delete_files($scormdir.'/'.$scorm->id);
|
||||
rename($scormdir.$scorm->datadir,$scormdir.'/'.$scorm->id);
|
||||
}
|
||||
@ -97,7 +102,11 @@ function scorm_update_instance($scorm) {
|
||||
if ($scorm->pkgtype == 'AICC') {
|
||||
$scorm->launch = scorm_parse_aicc($scormdir.'/'.$scorm->id,$scorm->id);
|
||||
} else {
|
||||
$scorm->launch = scorm_parse_scorm($scormdir.'/'.$scorm->id,$scorm->id);
|
||||
if (basename($scorm->reference) != 'imsmanifest.xml') {
|
||||
$scorm->launch = scorm_parse_scorm($scormdir.'/'.$scorm->id,$scorm->id);
|
||||
} else {
|
||||
$scorm->launch = scorm_parse_scorm($CFG->dataroot.'/'.$scorm->course.'/'.dirname($scorm->reference),$scorm->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +123,7 @@ function scorm_update_instance($scorm) {
|
||||
*/
|
||||
function scorm_delete_instance($id) {
|
||||
|
||||
require('../config.php');
|
||||
global $CFG;
|
||||
|
||||
if (! $scorm = get_record('scorm', 'id', $id)) {
|
||||
return false;
|
||||
|
@ -75,7 +75,7 @@
|
||||
} else {
|
||||
$connector = '?';
|
||||
}
|
||||
if ($sco->parameters[0] == '?') {
|
||||
if (!empty($sco->parameters) && ($sco->parameters[0] == '?')) {
|
||||
$sco->parameters = substr($sco->parameters,1);
|
||||
}
|
||||
}
|
||||
@ -92,10 +92,15 @@
|
||||
if (scorm_external_link($sco->launch)) {
|
||||
$result = $launcher;
|
||||
} else {
|
||||
if ($CFG->slasharguments) {
|
||||
$result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/moddata/scorm/'.$scorm->id.'/'.$launcher;
|
||||
if (basename($scorm->reference) == 'imsmanifest.xml') {
|
||||
$basedir = dirname($scorm->reference);
|
||||
} else {
|
||||
$result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/moddata/scorm/'.$scorm->id.'/'.$launcher;
|
||||
$basedir = 'moddata/scorm/'.$scorm->id;
|
||||
}
|
||||
if ($CFG->slasharguments) {
|
||||
$result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/'.$basedir.'/'.$launcher;
|
||||
} else {
|
||||
$result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/'.$basedir.'/'.$launcher;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -62,6 +62,7 @@
|
||||
function validate_scorm(theform,filename) {
|
||||
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 ?>");
|
||||
//alert(result);
|
||||
results = result.split('\n');
|
||||
result = '';
|
||||
errorlogs = '';
|
||||
|
@ -7,7 +7,7 @@
|
||||
$reference = required_param('reference', '', PARAM_PATH); // Package path
|
||||
$scormid = optional_param('instance', '', PARAM_INT); // scorm ID
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
require_login($courseid, false);
|
||||
|
||||
if (confirm_sesskey() && !empty($courseid)) {
|
||||
$launch = 0;
|
||||
@ -53,25 +53,36 @@ if (confirm_sesskey() && !empty($courseid)) {
|
||||
// Package must be validated
|
||||
//
|
||||
|
||||
// Create a temporary directory to unzip package and validate package
|
||||
$tempdir = '';
|
||||
$scormdir = '';
|
||||
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
|
||||
if ($tempdir = scorm_datadir($scormdir)) {
|
||||
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
|
||||
$ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.')));
|
||||
if (($ext == '.zip') || ($ext == '.pif')) {
|
||||
unzip_file($tempdir."/".basename($reference), $tempdir, false);
|
||||
unlink ($tempdir."/".basename($reference));
|
||||
$validation = scorm_validate($tempdir);
|
||||
$ext = strtolower(substr(basename($reference),strrpos(basename($reference),'.')));
|
||||
switch ($ext) {
|
||||
case '.pif':
|
||||
case '.zip':
|
||||
// Create a temporary directory to unzip package and validate package
|
||||
$tempdir = '';
|
||||
$scormdir = '';
|
||||
if ($scormdir = make_upload_directory("$courseid/$CFG->moddata/scorm")) {
|
||||
if ($tempdir = scorm_datadir($scormdir)) {
|
||||
copy ("$CFG->dataroot/$courseid/$reference", $tempdir."/".basename($reference));
|
||||
unzip_file($tempdir."/".basename($reference), $tempdir, false);
|
||||
unlink ($tempdir."/".basename($reference));
|
||||
$validation = scorm_validate($tempdir);
|
||||
} else {
|
||||
$validation->result = "packagedir";
|
||||
}
|
||||
} else {
|
||||
$validation->result = "packagefile";
|
||||
$validation->result = "datadir";
|
||||
}
|
||||
} else {
|
||||
$validation->result = "packagedir";
|
||||
}
|
||||
} else {
|
||||
$validation->result = "datadir";
|
||||
break;
|
||||
case '.xml':
|
||||
if (basename($reference) == 'imsmanifest.xml') {
|
||||
$validation = scorm_validate("$CFG->dataroot/$courseid/".dirname($reference));
|
||||
} else {
|
||||
$validation->result = "manifestfile";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$validation->result = "packagefile";
|
||||
break;
|
||||
}
|
||||
if (($validation->result != "regular") && ($validation->result != "found")) {
|
||||
$validation->result = get_string($validation->result,'scorm');
|
||||
@ -80,7 +91,11 @@ if (confirm_sesskey() && !empty($courseid)) {
|
||||
scorm_delete_files($tempdir);
|
||||
}
|
||||
} else {
|
||||
$datadir = substr($tempdir,strlen($scormdir));
|
||||
if ($ext == '.xml') {
|
||||
$datadir = dirname($reference);
|
||||
} else {
|
||||
$datadir = substr($tempdir,strlen($scormdir));
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user