本文整理汇总了PHP中core_competency\api::delete_framework方法的典型用法代码示例。如果您正苦于以下问题:PHP api::delete_framework方法的具体用法?PHP api::delete_framework怎么用?PHP api::delete_framework使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::delete_framework方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_competency_framework
/**
* Delete a competency framework
*
* @param int $id The competency framework id
* @return boolean
*/
public static function delete_competency_framework($id)
{
$params = self::validate_parameters(self::delete_competency_framework_parameters(), array('id' => $id));
$framework = api::read_framework($params['id']);
self::validate_context($framework->get_context());
return api::delete_framework($params['id']);
}
示例2: test_delete_framework_competency_used_in_course
public function test_delete_framework_competency_used_in_course()
{
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
$this->setAdminUser();
$cat1 = $dg->create_category();
$u1 = $dg->create_user();
$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()));
$c2id = $c2->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()));
// Create related competencies.
$rc = $lpg->create_related_competency(array('competencyid' => $c2->get_id(), 'relatedcompetencyid' => $c11b->get_id()));
$this->assertEquals($c11b->get_id(), $rc->get_relatedcompetencyid());
// Creating a standard evidence with minimal information.
$uc1 = $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $c11b->get_id()));
$usercompetencyid = $uc1->get_id();
$evidence = $lpg->create_evidence(array('usercompetencyid' => $usercompetencyid));
$this->assertEquals($uc1->get_id(), $evidence->get_usercompetencyid());
$uc1->delete();
// Add competency to course.
$cc = $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $c11b->get_id()));
// We can not delete a framework if the competency or competencies children is linked to a course.
$this->assertFalse(api::delete_framework($f1->get_id()));
// Check that none of associated data are deleted.
$this->assertEquals($usercompetencyid, $evidence->read()->get_usercompetencyid());
$this->assertEquals($c2->get_id(), $rc->read()->get_competencyid());
// We can delete the framework if we remove the competency from course.
$cc->delete();
$this->assertTrue(api::delete_framework($f1->get_id()));
$this->assertFalse(competency::record_exists($c1->get_id()));
$this->assertFalse(competency::record_exists($c2->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()));
// Check if evidence are also deleted.
$this->assertEquals(0, \core_competency\user_evidence_competency::count_records(array('competencyid' => $c11b->get_id())));
// Check if related conpetency relation is deleted.
$this->assertEquals(0, count(\core_competency\related_competency::get_multiple_relations(array($c2id))));
}
示例3: test_competency_deleted_by_deleteframework
/**
* Test the competency deleted event by delete framework.
*
*/
public function test_competency_deleted_by_deleteframework()
{
$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()));
$c2 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c12 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
// Trigger and capture the event.
$sink = $this->redirectEvents();
// Delete framework should trigger a deleted event for competencies.
api::delete_framework($f1->get_id());
// Get our event event.
$events = $sink->get_events();
$this->assertEquals(4, count($events));
$event = array_shift($events);
$this->assertInstanceOf('\\core\\event\\competency_framework_deleted', $event);
$event = array_shift($events);
$this->assertInstanceOf('\\core\\event\\competency_deleted', $event);
$event = array_shift($events);
$this->assertInstanceOf('\\core\\event\\competency_deleted', $event);
$event = array_shift($events);
$this->assertInstanceOf('\\core\\event\\competency_deleted', $event);
}