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


PHP api::remove_competency_from_plan方法代碼示例

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


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

示例1: test_complete_plan

 /**
  * Test that the method to complete a plan.
  *
  * @expectedException coding_exception
  */
 public function test_complete_plan()
 {
     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 two plans and assign competencies.
     $plan = $lpg->create_plan(array('userid' => $user->id));
     $otherplan = $lpg->create_plan(array('userid' => $user->id));
     $lpg->create_plan_competency(array('planid' => $plan->get_id(), 'competencyid' => $c1->get_id()));
     $lpg->create_plan_competency(array('planid' => $plan->get_id(), 'competencyid' => $c2->get_id()));
     $lpg->create_plan_competency(array('planid' => $plan->get_id(), 'competencyid' => $c3->get_id()));
     $lpg->create_plan_competency(array('planid' => $otherplan->get_id(), 'competencyid' => $c1->get_id()));
     $uclist = array($lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get_id(), 'proficiency' => true, 'grade' => 1)), $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get_id(), 'proficiency' => false, 'grade' => 2)));
     $this->assertEquals(2, \core_competency\user_competency::count_records());
     $this->assertEquals(0, \core_competency\user_competency_plan::count_records());
     // Change status of the plan to complete.
     api::complete_plan($plan);
     // Check that user competencies are now in user_competency_plan objects and still in user_competency.
     $this->assertEquals(2, \core_competency\user_competency::count_records());
     $this->assertEquals(3, \core_competency\user_competency_plan::count_records());
     $usercompetenciesplan = \core_competency\user_competency_plan::get_records();
     $this->assertEquals($uclist[0]->get_userid(), $usercompetenciesplan[0]->get_userid());
     $this->assertEquals($uclist[0]->get_competencyid(), $usercompetenciesplan[0]->get_competencyid());
     $this->assertEquals($uclist[0]->get_proficiency(), (bool) $usercompetenciesplan[0]->get_proficiency());
     $this->assertEquals($uclist[0]->get_grade(), $usercompetenciesplan[0]->get_grade());
     $this->assertEquals($plan->get_id(), $usercompetenciesplan[0]->get_planid());
     $this->assertEquals($uclist[1]->get_userid(), $usercompetenciesplan[1]->get_userid());
     $this->assertEquals($uclist[1]->get_competencyid(), $usercompetenciesplan[1]->get_competencyid());
     $this->assertEquals($uclist[1]->get_proficiency(), (bool) $usercompetenciesplan[1]->get_proficiency());
     $this->assertEquals($uclist[1]->get_grade(), $usercompetenciesplan[1]->get_grade());
     $this->assertEquals($plan->get_id(), $usercompetenciesplan[1]->get_planid());
     $this->assertEquals($user->id, $usercompetenciesplan[2]->get_userid());
     $this->assertEquals($c3->get_id(), $usercompetenciesplan[2]->get_competencyid());
     $this->assertNull($usercompetenciesplan[2]->get_proficiency());
     $this->assertNull($usercompetenciesplan[2]->get_grade());
     $this->assertEquals($plan->get_id(), $usercompetenciesplan[2]->get_planid());
     // Check we can not add competency to completed plan.
     try {
         api::add_competency_to_plan($plan->get_id(), $c4->get_id());
         $this->fail('We can not add competency to completed plan.');
     } catch (coding_exception $e) {
         // All good.
     }
     // Check we can not remove competency to completed plan.
     try {
         api::remove_competency_from_plan($plan->get_id(), $c3->get_id());
         $this->fail('We can not remove competency to completed plan.');
     } catch (coding_exception $e) {
         // All good.
     }
     // Completing a plan that is completed throws an exception.
     api::complete_plan($plan);
 }
開發者ID:dg711,項目名稱:moodle,代碼行數:67,代碼來源:api_test.php

示例2: remove_competency_from_plan

 /**
  * Remove a competency from plan.
  *
  * @param int $planid Plan id.
  * @param int $competencyid Competency id.
  * @return int
  */
 public static function remove_competency_from_plan($planid, $competencyid)
 {
     $params = self::validate_parameters(self::remove_competency_from_plan_parameters(), array('planid' => $planid, 'competencyid' => $competencyid));
     $plan = api::read_plan($params['planid']);
     self::validate_context($plan->get_context());
     return api::remove_competency_from_plan($params['planid'], $params['competencyid']);
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:14,代碼來源:external.php


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