當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。