本文整理汇总了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});
}
}
示例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;
}
示例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 {