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


PHP assign::can_upgrade_assignment方法代码示例

本文整理汇总了PHP中assign::can_upgrade_assignment方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::can_upgrade_assignment方法的具体用法?PHP assign::can_upgrade_assignment怎么用?PHP assign::can_upgrade_assignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assign的用法示例。


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

示例1: upgrade_mod_assign

 /**
  * This function will attempt to upgrade the newly restored assignment to an instance of mod_assign if
  * mod_assignment is currently disabled and mod_assign is enabled and mod_assign says it can upgrade this assignment.
  *
  * @return none
  */
 private function upgrade_mod_assign()
 {
     global $DB, $CFG;
     // The current module must exist.
     $pluginmanager = core_plugin_manager::instance();
     $plugininfo = $pluginmanager->get_plugin_info('mod_assign');
     // Check that the assignment module is installed.
     if ($plugininfo && $plugininfo->is_installed_and_upgraded()) {
         // Include the required mod assign upgrade code.
         require_once $CFG->dirroot . '/mod/assign/upgradelib.php';
         require_once $CFG->dirroot . '/mod/assign/locallib.php';
         // Get the id and type of this assignment.
         $newinstance = $this->task->get_activityid();
         $record = $DB->get_record('assignment', array('id' => $newinstance), 'assignmenttype', MUST_EXIST);
         $type = $record->assignmenttype;
         $subplugininfo = $pluginmanager->get_plugin_info('assignment_' . $type);
         // See if it is possible to upgrade.
         if (assign::can_upgrade_assignment($type, $subplugininfo->versiondb)) {
             $assignment_upgrader = new assign_upgrade_manager();
             $log = '';
             $success = $assignment_upgrader->upgrade_assignment($newinstance, $log);
             if (!$success) {
                 throw new restore_step_exception('mod_assign_upgrade_failed', $log);
             }
         }
     }
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:33,代码来源:restore_assignment_stepslib.php

示例2: tool_assignmentupgrade_load_all_upgradable_assignmentids

/**
 * Load a list of all the assignmentids that can be upgraded
 * @return array of assignment ids
 */
function tool_assignmentupgrade_load_all_upgradable_assignmentids()
{
    global $DB, $CFG;
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    // first find all the unique assignment types
    $types = $DB->get_records_sql('SELECT plugin AS assignmenttype, value AS version FROM {config_plugins} WHERE name = ? AND plugin LIKE ?', array('version', 'assignment_%'));
    $upgradabletypes = array();
    foreach ($types as $assignment) {
        $shorttype = substr($assignment->assignmenttype, strlen('assignment_'));
        if (assign::can_upgrade_assignment($shorttype, $assignment->version)) {
            $upgradabletypes[] = $shorttype;
        }
    }
    list($sql, $params) = $DB->get_in_or_equal($upgradabletypes);
    $records = $DB->get_records_sql('SELECT id from {assignment} where assignmenttype ' . $sql, $params);
    $ids = array();
    foreach ($records as $record) {
        $ids[] = $record->id;
    }
    return $ids;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:25,代码来源:locallib.php


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