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


PHP duplicate_module函数代码示例

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


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

示例1: test_duplicate_module

 /**
  * Test duplicate_module()
  */
 public function test_duplicate_module()
 {
     $this->setAdminUser();
     $this->resetAfterTest();
     $course = self::getDataGenerator()->create_course();
     $res = self::getDataGenerator()->create_module('resource', array('course' => $course));
     $cm = get_coursemodule_from_id('resource', $res->cmid, 0, false, MUST_EXIST);
     $newcm = duplicate_module($course, $cm);
     // Make sure they are the same, except obvious id changes.
     foreach ($cm as $prop => $value) {
         if ($prop == 'id' || $prop == 'url' || $prop == 'instance' || $prop == 'added') {
             // Ignore obviously different properties.
             continue;
         }
         $this->assertEquals($value, $newcm->{$prop});
     }
 }
开发者ID:uniedpa,项目名称:moodle,代码行数:20,代码来源:courselib_test.php

示例2: mod_duplicate_activity

/**
 * Duplicate a module on the course for ajax.
 *
 * @see mod_duplicate_module()
 * @param object $course The course
 * @param object $cm The course module to duplicate
 * @param int $sr The section to link back to (used for creating the links)
 * @throws moodle_exception if the plugin doesn't support duplication
 * @return Object containing:
 * - fullcontent: The HTML markup for the created CM
 * - cmid: The CMID of the newly created CM
 * - redirect: Whether to trigger a redirect following this change
 */
function mod_duplicate_activity($course, $cm, $sr = null)
{
    global $PAGE;
    $newcm = duplicate_module($course, $cm);
    $resp = new stdClass();
    if ($newcm) {
        $courserenderer = $PAGE->get_renderer('core', 'course');
        $completioninfo = new completion_info($course);
        $modulehtml = $courserenderer->course_section_cm($course, $completioninfo, $newcm, null, array());
        $resp->fullcontent = $courserenderer->course_section_cm_list_item($course, $completioninfo, $newcm, $sr);
        $resp->cmid = $newcm->id;
    } else {
        // Trigger a redirect.
        $resp->redirect = true;
    }
    return $resp;
}
开发者ID:rushi963,项目名称:moodle,代码行数:30,代码来源:lib.php

示例3: count

        $section_mods = $modinfo->sections[$section];
        if (is_array($section_mods)) {
            $progress_bar_elements = count($section_mods);
            $data_progress = new stdClass();
            $data_progress->current = 0;
            $data_progress->size = $progress_bar_elements;
            $k = 0;
            $pbar->update_full(40, get_string('progress_counter', 'format_onetopic', $data_progress));
            foreach ($section_mods as $modnumber) {
                $k++;
                $mod = $modinfo->cms[$modnumber];
                $cm = get_coursemodule_from_id('', $mod->id, 0, true, MUST_EXIST);
                $modcontext = context_module::instance($cm->id);
                if (has_capability('moodle/course:manageactivities', $modcontext)) {
                    // Duplicate the module.
                    $newcm = duplicate_module($course, $cm);
                    //Move new module to new section
                    if ($newcm && is_object($newcm)) {
                        moveto_module($newcm, $new_sectioninfo);
                    }
                }
                $data_progress->current = $k;
                $percent = 40 + $k / $progress_bar_elements * 60;
                $pbar->update_full($percent, get_string('progress_counter', 'format_onetopic', $data_progress));
            }
        }
    } else {
        $pbar->update_full(100, get_string('progress_full', 'format_onetopic'));
    }
    $section_togo = $num_newsection;
} else {
开发者ID:dibarbado,项目名称:moodle,代码行数:31,代码来源:duplicate.php


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