本文整理汇总了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);
}
示例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']);
}