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