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


PHP api::remove_competency_from_template方法代碼示例

本文整理匯總了PHP中core_competency\api::remove_competency_from_template方法的典型用法代碼示例。如果您正苦於以下問題:PHP api::remove_competency_from_template方法的具體用法?PHP api::remove_competency_from_template怎麽用?PHP api::remove_competency_from_template使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core_competency\api的用法示例。


在下文中一共展示了api::remove_competency_from_template方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: remove_competency_from_template

 /**
  * Count the competencies (visible to this user) in this learning plan template.
  *
  * @param int $templateid Template id.
  * @param int $competencyid Competency id.
  * @return int
  */
 public static function remove_competency_from_template($templateid, $competencyid)
 {
     $params = self::validate_parameters(self::remove_competency_from_template_parameters(), array('templateid' => $templateid, 'competencyid' => $competencyid));
     $template = api::read_template($params['templateid']);
     self::validate_context($template->get_context());
     return api::remove_competency_from_template($params['templateid'], $params['competencyid']);
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:14,代碼來源:external.php

示例2: test_completed_plan_doesnot_change

 /**
  * Test that completed plan created form a template does not change when template is modified.
  */
 public function test_completed_plan_doesnot_change()
 {
     global $DB;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $user = $dg->create_user();
     // Create a framework and assign competencies.
     $framework = $lpg->create_framework();
     $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     // Create template and assign competencies.
     $tp = $lpg->create_template();
     $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get_id(), 'competencyid' => $c1->get_id()));
     $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get_id(), 'competencyid' => $c2->get_id()));
     $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get_id(), 'competencyid' => $c3->get_id()));
     // Create a plan form template and change it status to complete.
     $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get_id()));
     api::complete_plan($plan);
     // Check user competency plan created correctly.
     $this->assertEquals(3, \core_competency\user_competency_plan::count_records());
     $ucp = \core_competency\user_competency_plan::get_records();
     $this->assertEquals($ucp[0]->get_competencyid(), $c1->get_id());
     $this->assertEquals($ucp[1]->get_competencyid(), $c2->get_id());
     $this->assertEquals($ucp[2]->get_competencyid(), $c3->get_id());
     // Add and remove a competency from the template.
     api::add_competency_to_template($tp->get_id(), $c4->get_id());
     api::remove_competency_from_template($tp->get_id(), $c1->get_id());
     // Check that user competency plan did not change.
     $competencies = $plan->get_competencies();
     $this->assertEquals(3, count($competencies));
     $ucp1 = array($c1->get_id(), $c2->get_id(), $c3->get_id());
     $ucp2 = array();
     foreach ($competencies as $id => $cmp) {
         $ucp2[] = $id;
     }
     $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));
 }
開發者ID:dg711,項目名稱:moodle,代碼行數:44,代碼來源:api_test.php

示例3: test_get_competency

 public function test_get_competency()
 {
     $this->resetAfterTest();
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $dg->get_plugin_generator('core_competency');
     $u1 = $dg->create_user();
     $u2 = $dg->create_user();
     $u3 = $dg->create_user();
     $u4 = $dg->create_user();
     $f1 = $lpg->create_framework();
     $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $c2 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $c3 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $c4 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $tpl1 = $lpg->create_template();
     $p1 = $lpg->create_plan(array('userid' => $u1->id));
     $p2 = $lpg->create_plan(array('userid' => $u2->id));
     $p3 = $lpg->create_plan(array('userid' => $u3->id, 'templateid' => $tpl1->get_id()));
     $p4 = $lpg->create_plan(array('userid' => $u4->id, 'templateid' => $tpl1->get_id()));
     $lpg->create_plan_competency(array('planid' => $p1->get_id(), 'competencyid' => $c1->get_id()));
     $lpg->create_plan_competency(array('planid' => $p2->get_id(), 'competencyid' => $c2->get_id()));
     $lpg->create_template_competency(array('templateid' => $tpl1->get_id(), 'competencyid' => $c3->get_id()));
     $lpg->create_template_competency(array('templateid' => $tpl1->get_id(), 'competencyid' => $c4->get_id()));
     // Completing the plans and removing a competency from the template.
     api::complete_plan($p2);
     api::complete_plan($p4);
     api::remove_competency_from_template($tpl1->get_id(), $c4->get_id());
     // We can find all competencies.
     $this->assertEquals($c1->to_record(), $p1->get_competency($c1->get_id())->to_record());
     $this->assertEquals($c2->to_record(), $p2->get_competency($c2->get_id())->to_record());
     $this->assertEquals($c3->to_record(), $p3->get_competency($c3->get_id())->to_record());
     $this->assertEquals($c4->to_record(), $p4->get_competency($c4->get_id())->to_record());
     // Getting the competency 4 from the non-completed plan based on a template p4, will throw an exception.
     $this->setExpectedException('coding_exception', 'The competency does not belong to this template: ');
     $p3->get_competency($c4->get_id());
 }
開發者ID:IFPBMoodle,項目名稱:moodle,代碼行數:37,代碼來源:plan_test.php


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