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


PHP api::create_template方法代码示例

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


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

示例1: test_update_template

 /**
  * Test updating a template.
  *
  * @expectedException coding_exception
  */
 public function test_update_template()
 {
     $cat = $this->getDataGenerator()->create_category();
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $syscontext = context_system::instance();
     $template = api::create_template((object) array('shortname' => 'testing', 'contextid' => $syscontext->id));
     $this->assertEquals('testing', $template->get_shortname());
     $this->assertEquals($syscontext->id, $template->get_contextid());
     // Simple update.
     api::update_template((object) array('id' => $template->get_id(), 'shortname' => 'success'));
     $template = api::read_template($template->get_id());
     $this->assertEquals('success', $template->get_shortname());
     // Trying to change the context.
     api::update_template((object) array('id' => $template->get_id(), 'contextid' => context_coursecat::instance($cat->id)));
 }
开发者ID:dg711,项目名称:moodle,代码行数:21,代码来源:api_test.php

示例2: test_template_created

 /**
  * Test the template created event.
  *
  */
 public function test_template_created()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     // Use DataGenerator to have a template record with the right format.
     $record = $lpg->create_template()->to_record();
     $record->id = 0;
     $record->shortname = "New shortname";
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $template = api::create_template((object) $record);
     // Get our event event.
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\competency_template_created', $event);
     $this->assertEquals($template->get_id(), $event->objectid);
     $this->assertEquals($template->get_contextid(), $event->contextid);
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:25,代码来源:event_test.php

示例3: create_template

 /**
  * Create a new learning plan template
  *
  * @param array $template The list of fields for the template.
  * @return \stdClass Record of new template.
  */
 public static function create_template($template)
 {
     global $PAGE;
     $params = self::validate_parameters(self::create_template_parameters(), array('template' => $template));
     $params = $params['template'];
     $context = self::get_context_from_params($params);
     self::validate_context($context);
     $output = $PAGE->get_renderer('core');
     unset($params['contextlevel']);
     unset($params['instanceid']);
     $params = (object) $params;
     $params->contextid = $context->id;
     $result = api::create_template($params);
     $exporter = new template_exporter($result);
     $record = $exporter->export($output);
     return $record;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:23,代码来源:external.php

示例4: get_string

if (empty($id)) {
    $pagetitle = get_string('addnewtemplate', 'tool_lp');
    list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, null, $pagetitle, $returntype);
} else {
    $template = \core_competency\api::read_template($id);
    $pagetitle = get_string('edittemplate', 'tool_lp');
    list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, $pagetitle, $returntype);
}
$form = new \tool_lp\form\template($url->out(false), array('persistent' => $template, 'context' => $context));
if ($form->is_cancelled()) {
    redirect($returnurl);
}
$data = $form->get_data();
if ($data) {
    if (empty($data->id)) {
        $template = \core_competency\api::create_template($data);
        $returnurl = new moodle_url('/admin/tool/lp/templatecompetencies.php', ['templateid' => $template->get_id(), 'pagecontextid' => $pagecontextid]);
        $returnmsg = get_string('templatecreated', 'tool_lp');
    } else {
        \core_competency\api::update_template($data);
        $returnmsg = get_string('templateupdated', 'tool_lp');
    }
    redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
}
$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
echo $output->heading($title);
if (!empty($subtitle)) {
    echo $output->heading($subtitle, 3);
}
$form->display();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:edittemplate.php


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