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


PHP scorm_option2text函数代码示例

本文整理汇总了PHP中scorm_option2text函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_option2text函数的具体用法?PHP scorm_option2text怎么用?PHP scorm_option2text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scorm_option2text函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: scorm_update_instance

/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @global stdClass
 * @global object
 * @uses CONTEXT_MODULE
 * @uses SCORM_TYPE_LOCAL
 * @uses SCORM_TYPE_LOCALSYNC
 * @uses SCORM_TYPE_EXTERNAL
 * @param object $scorm Form data
 * @param object $mform
 * @return bool
 */
function scorm_update_instance($scorm, $mform=null) {
    global $CFG, $DB;

    require_once($CFG->dirroot.'/mod/scorm/locallib.php');

    if (empty($scorm->timeopen)) {
        $scorm->timeopen = 0;
    }
    if (empty($scorm->timeclose)) {
        $scorm->timeclose = 0;
    }

    $cmid       = $scorm->coursemodule;
    $cmidnumber = $scorm->cmidnumber;
    $courseid   = $scorm->course;

    $scorm->id = $scorm->instance;

    $context = context_module::instance($cmid);

    if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
        if (!empty($scorm->packagefile)) {
            $fs = get_file_storage();
            $fs->delete_area_files($context->id, 'mod_scorm', 'package');
            file_save_draft_area_files($scorm->packagefile, $context->id, 'mod_scorm', 'package',
                0, array('subdirs' => 0, 'maxfiles' => 1));
            // Get filename of zip that was uploaded.
            $files = $fs->get_area_files($context->id, 'mod_scorm', 'package', 0, '', false);
            $file = reset($files);
            $filename = $file->get_filename();
            if ($filename !== false) {
                $scorm->reference = $filename;
            }
        }

    } else if ($scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
        $scorm->reference = $scorm->packageurl;
    } else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
        $scorm->reference = $scorm->packageurl;
    } else if ($scorm->scormtype === SCORM_TYPE_AICCURL) {
        $scorm->reference = $scorm->packageurl;
        $scorm->hidetoc = SCORM_TOC_DISABLED; // TOC is useless for direct AICCURL so disable it.
    } else {
        return false;
    }

    $scorm = scorm_option2text($scorm);
    $scorm->width        = (int)str_replace('%', '', $scorm->width);
    $scorm->height       = (int)str_replace('%', '', $scorm->height);
    $scorm->timemodified = time();

    if (!isset($scorm->whatgrade)) {
        $scorm->whatgrade = 0;
    }

    $DB->update_record('scorm', $scorm);

    $scorm = $DB->get_record('scorm', array('id' => $scorm->id));

    // Extra fields required in grade related functions.
    $scorm->course   = $courseid;
    $scorm->idnumber = $cmidnumber;
    $scorm->cmid     = $cmid;

    scorm_parse($scorm, (bool)$scorm->updatefreq);

    scorm_grade_item_update($scorm);
    scorm_update_grades($scorm);

    return true;
}
开发者ID:ruddj,项目名称:moodle,代码行数:86,代码来源:lib.php

示例2: scorm_update_instance

/**
* Given an object containing all the necessary data,
* (defined by the form in mod.html) this function
* will update an existing instance with new data.
*
* @param mixed $scorm Form data
* @return int
*/
function scorm_update_instance($scorm)
{
    global $CFG;
    require_once 'locallib.php';
    $scorm->parse = 0;
    if (($packagedata = scorm_check_package($scorm)) != null) {
        $scorm->pkgtype = $packagedata->pkgtype;
        if ($packagedata->launch == 0) {
            $scorm->launch = $packagedata->launch;
            $scorm->datadir = $packagedata->datadir;
            $scorm->parse = 1;
            if (!scorm_external_link($scorm->reference)) {
                $scorm->md5hash = md5_file($CFG->dataroot . '/' . $scorm->course . '/' . $scorm->reference);
            } else {
                $scorm->dir = $CFG->dataroot . '/' . $scorm->course . '/moddata/scorm';
                $scorm->md5hash = md5_file($scorm->dir . $scorm->datadir . '/' . basename($scorm->reference));
            }
        }
    }
    $scorm->timemodified = time();
    $scorm->id = $scorm->instance;
    $scorm = scorm_option2text($scorm);
    $scorm->width = str_replace('%', '', $scorm->width);
    $scorm->height = str_replace('%', '', $scorm->height);
    if (!isset($scorm->whatgrade)) {
        $scorm->whatgrade = 0;
    }
    $scorm->grademethod = $scorm->whatgrade * 10 + $scorm->grademethod;
    // Check if scorm manifest needs to be reparsed
    if ($scorm->parse == 1) {
        $scorm->dir = $CFG->dataroot . '/' . $scorm->course . '/moddata/scorm';
        if (is_dir($scorm->dir . '/' . $scorm->id)) {
            scorm_delete_files($scorm->dir . '/' . $scorm->id);
        }
        if (isset($scorm->datadir) && $scorm->datadir != $scorm->id && (scorm_external_link($scorm->reference) || basename($scorm->reference) != 'imsmanifest.xml' && $scorm->reference[0] != '#')) {
            rename($scorm->dir . $scorm->datadir, $scorm->dir . '/' . $scorm->id);
        }
        $scorm->launch = scorm_parse($scorm);
    } else {
        $oldscorm = get_record('scorm', 'id', $scorm->id);
        $scorm->reference = $oldscorm->reference;
        // This fix a problem with Firefox when the teacher choose Cancel on overwrite question
    }
    if ($result = update_record('scorm', $scorm)) {
        scorm_grade_item_update(stripslashes_recursive($scorm));
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:56,代码来源:lib.php

示例3: scorm_update_instance

/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @global stdClass
 * @global object
 * @uses CONTEXT_MODULE
 * @uses SCORM_TYPE_LOCAL
 * @uses SCORM_TYPE_LOCALSYNC
 * @uses SCORM_TYPE_EXTERNAL
 * @uses SCORM_TYPE_IMSREPOSITORY
 * @param object $scorm Form data
 * @param object $mform
 * @return bool
 */
function scorm_update_instance($scorm, $mform = null)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/scorm/locallib.php';
    if (empty($scorm->timeopen)) {
        $scorm->timeopen = 0;
    }
    if (empty($scorm->timeclose)) {
        $scorm->timeclose = 0;
    }
    $cmid = $scorm->coursemodule;
    $cmidnumber = $scorm->cmidnumber;
    $courseid = $scorm->course;
    $scorm->id = $scorm->instance;
    $context = get_context_instance(CONTEXT_MODULE, $cmid);
    if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
        if ($mform) {
            $filename = $mform->get_new_filename('packagefile');
            if ($filename !== false) {
                $scorm->reference = $filename;
                $fs = get_file_storage();
                $fs->delete_area_files($context->id, 'mod_scorm', 'package');
                $mform->save_stored_file('packagefile', $context->id, 'mod_scorm', 'package', 0, '/', $filename);
            }
        }
    } else {
        if ($scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
            $scorm->reference = $scorm->packageurl;
        } else {
            if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
                $scorm->reference = $scorm->packageurl;
            } else {
                if ($scorm->scormtype === SCORM_TYPE_IMSREPOSITORY) {
                    $scorm->reference = $scorm->packageurl;
                } else {
                    return false;
                }
            }
        }
    }
    $scorm = scorm_option2text($scorm);
    $scorm->width = (int) str_replace('%', '', $scorm->width);
    $scorm->height = (int) str_replace('%', '', $scorm->height);
    $scorm->timemodified = time();
    if (!isset($scorm->whatgrade)) {
        $scorm->whatgrade = 0;
    }
    $DB->update_record('scorm', $scorm);
    $scorm = $DB->get_record('scorm', array('id' => $scorm->id));
    /// extra fields required in grade related functions
    $scorm->course = $courseid;
    $scorm->idnumber = $cmidnumber;
    $scorm->cmid = $cmid;
    scorm_parse($scorm, (bool) $scorm->updatefreq);
    scorm_grade_item_update($scorm);
    scorm_update_grades($scorm);
    return true;
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:74,代码来源:lib.php


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