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


PHP api::create_plan方法代码示例

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


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

示例1: test_create_plan_from_template

 /**
  * @expectedException coding_exception
  */
 public function test_create_plan_from_template()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $u1 = $this->getDataGenerator()->create_user();
     $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();
     // Creating a new plan.
     $plan = api::create_plan_from_template($tpl, $u1->id);
     $record = $plan->to_record();
     $this->assertInstanceOf('\\core_competency\\plan', $plan);
     $this->assertTrue(\core_competency\plan::record_exists($plan->get_id()));
     $this->assertEquals($tpl->get_id(), $plan->get_templateid());
     $this->assertEquals($u1->id, $plan->get_userid());
     $this->assertTrue($plan->is_based_on_template());
     // Creating a plan that already exists.
     $plan = api::create_plan_from_template($tpl, $u1->id);
     $this->assertFalse($plan);
     // Check that api::create_plan cannot be used.
     unset($record->id);
     $plan = api::create_plan($record);
 }
开发者ID:dg711,项目名称:moodle,代码行数:24,代码来源:api_test.php

示例2: create_plan

 /**
  * Create a new learning plan.
  *
  * @param array $plan List of fields for the plan.
  * @return array New plan record.
  */
 public static function create_plan($plan)
 {
     global $PAGE;
     $params = self::validate_parameters(self::create_plan_parameters(), array('plan' => $plan));
     $params = $params['plan'];
     $context = context_user::instance($params['userid']);
     self::validate_context($context);
     $output = $PAGE->get_renderer('core');
     $params = (object) $params;
     $result = api::create_plan($params);
     $exporter = new plan_exporter($result, array('template' => null));
     return $exporter->export($output);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:external.php

示例3: coding_exception

    if (!$plan->can_be_edited()) {
        throw new coding_exception('Completed plan can not be edited');
    }
} else {
    if (!$cancreate) {
        throw new required_capability_exception($PAGE->context, 'moodle/competency:planmanage', 'nopermissions', '');
    }
}
$form = new \tool_lp\form\plan($url->out(false), $customdata);
if ($form->is_cancelled()) {
    redirect($returnurl);
}
$data = $form->get_data();
if ($data) {
    if (empty($data->id)) {
        $plan = \core_competency\api::create_plan($data);
        $returnurl = new moodle_url('/admin/tool/lp/plan.php', ['id' => $plan->get_id()]);
        $returnmsg = get_string('plancreated', 'tool_lp');
    } else {
        \core_competency\api::update_plan($data);
        $returnmsg = get_string('planupdated', 'tool_lp');
    }
    redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
}
echo $output->header();
echo $output->heading($title);
if (!empty($subtitle)) {
    echo $output->heading($subtitle, 3);
}
$form->display();
echo $output->footer();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:editplan.php

示例4: test_plan_created

 /**
  * Test the plan created event.
  *
  */
 public function test_plan_created()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $user = $dg->create_user();
     $plan = array('name' => 'plan', 'userid' => $user->id);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $plan = api::create_plan((object) $plan);
     // Get our event event.
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\competency_plan_created', $event);
     $this->assertEquals($plan->get_id(), $event->objectid);
     $this->assertEquals($plan->get_context()->id, $event->contextid);
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:25,代码来源:event_test.php


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