當前位置: 首頁>>代碼示例>>PHP>>正文


PHP api::delete_competency方法代碼示例

本文整理匯總了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']);
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:14,代碼來源:external.php

示例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()));
 }
開發者ID:dg711,項目名稱:moodle,代碼行數:27,代碼來源:api_test.php

示例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();
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:26,代碼來源:event_test.php


注:本文中的core_competency\api::delete_competency方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。