本文整理汇总了PHP中core_competency\api::delete_competency方法的典型用法代码示例。如果您正苦于以下问题:PHP api::delete_competency方法的具体用法?PHP api::delete_competency怎么用?PHP api::delete_competency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::delete_competency方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_competency
/**
* Delete a competency
*
* @param int $id The competency id
* @return boolean
*/
public static function delete_competency($id)
{
$params = self::validate_parameters(self::delete_competency_parameters(), array('id' => $id));
$competency = api::read_competency($params['id']);
$context = $competency->get_context();
self::validate_context($context);
return api::delete_competency($params['id']);
}
示例2: test_delete_competency_used_in_course
public function test_delete_competency_used_in_course()
{
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
$this->setAdminUser();
$cat1 = $dg->create_category();
$course = $dg->create_course(array('category' => $cat1->id));
$f1 = $lpg->create_framework();
$c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c2 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c1a = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
$c1b = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1a->get_id()));
$c11b = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1b->get_id()));
$c12b = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1b->get_id()));
// Add competency to course.
$cc = $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $c11b->get_id()));
// We can not delete a competency if the competency or competencies children is linked to a course.
$this->assertFalse(api::delete_competency($c1a->get_id()));
// We can delete the competency if we remove the competency from course.
$cc->delete();
$this->assertTrue(api::delete_competency($c1a->get_id()));
$this->assertFalse(competency::record_exists($c1a->get_id()));
$this->assertFalse(competency::record_exists($c1b->get_id()));
$this->assertFalse(competency::record_exists($c11b->get_id()));
$this->assertFalse(competency::record_exists($c12b->get_id()));
}
示例3: test_competency_deleted
/**
* Test the competency deleted event.
*
*/
public function test_competency_deleted()
{
$this->resetAfterTest(true);
$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$f1 = $lpg->create_framework();
$c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c1id = $c1->get_id();
$contextid = $c1->get_context()->id;
// Trigger and capture the event.
$sink = $this->redirectEvents();
// Delete competency should trigger a deleted event.
api::delete_competency($c1id);
// Get our event event.
$events = $sink->get_events();
$event = reset($events);
$this->assertInstanceOf('\\core\\event\\competency_deleted', $event);
$this->assertEquals($c1id, $event->objectid);
$this->assertEquals($contextid, $event->contextid);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingNotCalled();
}