当前位置: 首页>>代码示例>>PHP>>正文


PHP scorm_parse_scorm函数代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:helenagarcia90,项目名称:moodle,代码行数:101,代码来源:locallib.php

示例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;
}
开发者ID:veritech,项目名称:pare-project,代码行数:24,代码来源:locallib.php

示例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;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:24,代码来源:locallib.php

示例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";
//.........这里部分代码省略.........
开发者ID:Healthcare-Learning,项目名称:TCAPI-Moodle-SCORM-mod,代码行数:101,代码来源:locallib.php


注:本文中的scorm_parse_scorm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。