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


PHP api::delete_template方法代码示例

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


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

示例1: delete_template

 /**
  * Delete a learning plan template
  *
  * @param int $id The learning plan template id
  * @param boolean $deleteplans True to delete the plans associated to template or false to unlink them
  * @return boolean
  */
 public static function delete_template($id, $deleteplans = true)
 {
     $params = self::validate_parameters(self::delete_template_parameters(), array('id' => $id, 'deleteplans' => $deleteplans));
     $template = api::read_template($params['id']);
     self::validate_context($template->get_context());
     return api::delete_template($params['id'], $params['deleteplans']);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:external.php

示例2: test_delete_template_unlink_plans

 public function test_delete_template_unlink_plans()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $u1 = $dg->create_user();
     $f = $lpg->create_framework();
     $c1 = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
     $c2 = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
     $tpl = $lpg->create_template();
     $tplc1 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $c1->get_id(), 'sortorder' => 1));
     $tplc2 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $c2->get_id(), 'sortorder' => 2));
     $p1 = $lpg->create_plan(array('templateid' => $tpl->get_id(), 'userid' => $u1->id));
     // Check pre-test.
     $this->assertTrue(\core_competency\template::record_exists($tpl->get_id()));
     $this->assertEquals(2, \core_competency\template_competency::count_competencies($tpl->get_id()));
     $this->assertEquals(1, count(\core_competency\plan::get_records(array('templateid' => $tpl->get_id()))));
     $result = api::delete_template($tpl->get_id(), false);
     $this->assertTrue($result);
     // Check that the template does not exist anymore.
     $this->assertFalse(\core_competency\template::record_exists($tpl->get_id()));
     // Check that associated competencies are also deleted.
     $this->assertEquals(0, \core_competency\template_competency::count_competencies($tpl->get_id()));
     // Check that associated plan still exist but unlink from template.
     $plans = \core_competency\plan::get_records(array('id' => $p1->get_id()));
     $this->assertEquals(1, count($plans));
     $this->assertEquals($plans[0]->get_origtemplateid(), $tpl->get_id());
     $this->assertNull($plans[0]->get_templateid());
 }
开发者ID:dg711,项目名称:moodle,代码行数:30,代码来源:api_test.php

示例3: test_template_deleted

 /**
  * Test the template deleted event.
  *
  */
 public function test_template_deleted()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $template = $lpg->create_template();
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     api::delete_template($template->get_id());
     // Get our event event.
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\competency_template_deleted', $event);
     $this->assertEquals($template->get_id(), $event->objectid);
     $this->assertEquals($template->get_contextid(), $event->contextid);
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:23,代码来源:event_test.php


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