本文整理汇总了PHP中scorm_parse_scorm函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_parse_scorm函数的具体用法?PHP scorm_parse_scorm怎么用?PHP scorm_parse_scorm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_parse_scorm函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scorm_parse
/**
* Extracts scrom package, sets up all variables.
* Called whenever scorm changes
* @param object $scorm instance - fields are updated and changes saved into database
* @param bool $full force full update if true
* @return void
*/
function scorm_parse($scorm, $full)
{
global $CFG, $DB;
$cfg_scorm = get_config('scorm');
if (!isset($scorm->cmid)) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
$scorm->cmid = $cm->id;
}
$context = context_module::instance($scorm->cmid);
$newhash = $scorm->sha1hash;
if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
$fs = get_file_storage();
$packagefile = false;
$packagefileimsmanifest = false;
if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
if ($packagefile = $fs->get_file($context->id, 'mod_scorm', 'package', 0, '/', $scorm->reference)) {
if ($packagefile->is_external_file()) {
// Get zip file so we can check it is correct.
$packagefile->import_external_file_contents();
}
$newhash = $packagefile->get_contenthash();
if (strtolower($packagefile->get_filename()) == 'imsmanifest.xml') {
$packagefileimsmanifest = true;
}
} else {
$newhash = null;
}
} else {
if (!$cfg_scorm->allowtypelocalsync) {
// sorry - localsync disabled
return;
}
if ($scorm->reference !== '' and (!$full or $scorm->sha1hash !== sha1($scorm->reference))) {
$fs->delete_area_files($context->id, 'mod_scorm', 'package');
$file_record = array('contextid' => $context->id, 'component' => 'mod_scorm', 'filearea' => 'package', 'itemid' => 0, 'filepath' => '/');
if ($packagefile = $fs->create_file_from_url($file_record, $scorm->reference, array('calctimeout' => true))) {
$newhash = sha1($scorm->reference);
} else {
$newhash = null;
}
}
}
if ($packagefile) {
if (!$full and $packagefile and $scorm->sha1hash === $newhash) {
if (strpos($scorm->version, 'SCORM') !== false) {
if ($packagefileimsmanifest || $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
// No need to update.
return;
}
} else {
if (strpos($scorm->version, 'AICC') !== false) {
// TODO: add more sanity checks - something really exists in scorm_content area
return;
}
}
}
if (!$packagefileimsmanifest) {
// Now extract files.
$fs->delete_area_files($context->id, 'mod_scorm', 'content');
$packer = get_file_packer('application/zip');
$packagefile->extract_to_storage($packer, $context->id, 'mod_scorm', 'content', 0, '/');
}
} else {
if (!$full) {
return;
}
}
if ($packagefileimsmanifest) {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/scormlib.php";
// Direct link to imsmanifest.xml file.
if (!scorm_parse_scorm($scorm, $packagefile)) {
$scorm->version = 'ERROR';
}
} else {
if ($manifest = $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/scormlib.php";
// SCORM
if (!scorm_parse_scorm($scorm, $manifest)) {
$scorm->version = 'ERROR';
}
} else {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/aicclib.php";
// AICC
if (!scorm_parse_aicc($scorm)) {
$scorm->version = 'ERROR';
}
$scorm->version = 'AICC';
}
}
} else {
if ($scorm->scormtype === SCORM_TYPE_EXTERNAL and $cfg_scorm->allowtypeexternal) {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/scormlib.php";
// SCORM only, AICC can not be external
//.........这里部分代码省略.........
示例2: scorm_parse
function scorm_parse($scorm)
{
global $CFG, $repositoryconfigfile;
if ($scorm->reference[0] == '#') {
$reference = $CFG->repository . substr($scorm->reference, 1);
require_once $repositoryconfigfile;
} else {
if (!scorm_external_link($scorm->reference) && basename($scorm->reference) == 'imsmanifest.xml') {
$referencedir = dirname($scorm->reference) == '.' ? '' : dirname($scorm->reference);
$reference = $CFG->dataroot . '/' . $scorm->course . '/' . $referencedir;
} else {
$reference = $scorm->dir . '/' . $scorm->id;
}
}
// Parse scorm manifest
if ($scorm->pkgtype == 'AICC') {
require_once 'datamodels/aicclib.php';
$scorm->launch = scorm_parse_aicc($reference, $scorm->id);
} else {
require_once 'datamodels/scormlib.php';
$scorm->launch = scorm_parse_scorm($reference, $scorm->id);
}
return $scorm->launch;
}
示例3: scorm_parse
function scorm_parse($scorm)
{
global $CFG;
if ($scorm->reference[0] == '#') {
if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) {
$referencedir = $CFG->repository . substr($scorm->reference, 1);
}
} else {
if (!scorm_external_link($scorm->reference) && basename($scorm->reference) == 'imsmanifest.xml') {
$referencedir = $CFG->dataroot . '/' . $scorm->course . '/' . $scorm->datadir;
} else {
$referencedir = $CFG->dataroot . '/' . $scorm->course . '/moddata/scorm/' . $scorm->id;
}
}
// Parse scorm manifest
if ($scorm->pkgtype == 'AICC') {
require_once 'datamodels/aicclib.php';
$scorm->launch = scorm_parse_aicc($referencedir, $scorm->id);
} else {
require_once 'datamodels/scormlib.php';
$scorm->launch = scorm_parse_scorm($referencedir, $scorm->id);
}
return $scorm->launch;
}
示例4: scorm_parse
/**
* Extracts scrom package, sets up all variables.
* Called whenever scorm changes
* @param object $scorm instance - fields are updated and changes saved into database
* @param bool $full force full update if true
* @return void
*/
function scorm_parse($scorm, $full)
{
global $CFG, $DB;
$cfg_scorm = get_config('scorm');
if (!isset($scorm->cmid)) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
$scorm->cmid = $cm->id;
}
$context = context_module::instance($scorm->cmid);
$newhash = $scorm->sha1hash;
if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
$fs = get_file_storage();
$packagefile = false;
if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
if ($packagefile = $fs->get_file($context->id, 'mod_scorm', 'package', 0, '/', $scorm->reference)) {
$newhash = $packagefile->get_contenthash();
} else {
$newhash = null;
}
} else {
if (!$cfg_scorm->allowtypelocalsync) {
// sorry - localsync disabled
return;
}
if ($scorm->reference !== '' and (!$full or $scorm->sha1hash !== sha1($scorm->reference))) {
$fs->delete_area_files($context->id, 'mod_scorm', 'package');
$file_record = array('contextid' => $context->id, 'component' => 'mod_scorm', 'filearea' => 'package', 'itemid' => 0, 'filepath' => '/');
if ($packagefile = $fs->create_file_from_url($file_record, $scorm->reference, array('calctimeout' => true))) {
$newhash = sha1($scorm->reference);
} else {
$newhash = null;
}
}
}
if ($packagefile) {
if (!$full and $packagefile and $scorm->sha1hash === $newhash) {
if (strpos($scorm->version, 'SCORM') !== false) {
if ($fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
// no need to update
return;
}
/*
* TCAPI Modification
* Allow for TinCan package file, tincan.xml.
*/
} else {
if (strpos($scorm->version, 'TCAPI') !== false) {
if ($fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'tincan.xml')) {
// no need to update
return;
}
/*
* End TCAPI Modification
*/
} else {
if (strpos($scorm->version, 'AICC') !== false) {
// TODO: add more sanity checks - something really exists in scorm_content area
return;
}
}
}
}
// now extract files
$fs->delete_area_files($context->id, 'mod_scorm', 'content');
$packer = get_file_packer('application/zip');
$packagefile->extract_to_storage($packer, $context->id, 'mod_scorm', 'content', 0, '/');
} else {
if (!$full) {
return;
}
}
if ($manifest = $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/scormlib.php";
// SCORM
if (!scorm_parse_scorm($scorm, $manifest)) {
$scorm->version = 'ERROR';
}
/*
* TCAPI Modification
* Detect if tincan.xml exists and handle as TCAPI package.
*/
} else {
if ($manifest = $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'tincan.xml')) {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/tincanlib.php";
// TCAPI
if (!scorm_parse_tincan($scorm, $manifest)) {
$scorm->version = 'ERROR';
}
/*
* End TCAPI Modification
*/
} else {
require_once "{$CFG->dirroot}/mod/scorm/datamodels/aicclib.php";
//.........这里部分代码省略.........