本文整理汇总了PHP中core_competency\api::list_evidence方法的典型用法代码示例。如果您正苦于以下问题:PHP api::list_evidence方法的具体用法?PHP api::list_evidence怎么用?PHP api::list_evidence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::list_evidence方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export_for_template
/**
* Export the data.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output)
{
if (!isset($related['user'])) {
$related['user'] = core_user::get_user($this->usercompetency->get_userid());
}
if (!isset($related['competency'])) {
$related['competency'] = $this->usercompetency->get_competency();
}
$related += array('usercompetency' => $this->usercompetency, 'usercompetencyplan' => null, 'usercompetencycourse' => null, 'evidence' => api::list_evidence($this->usercompetency->get_userid(), $this->usercompetency->get_competencyid()), 'relatedcompetencies' => api::list_related_competencies($this->usercompetency->get_competencyid()));
$exporter = new user_competency_summary_exporter(null, $related);
$data = $exporter->export($output);
return $data;
}
示例2: export_for_template
/**
* Export the data.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(\renderer_base $output)
{
global $DB;
$plan = api::read_plan($this->planid);
$pc = api::get_plan_competency($plan, $this->competencyid);
$competency = $pc->competency;
$usercompetency = $pc->usercompetency;
$usercompetencyplan = $pc->usercompetencyplan;
if (empty($competency)) {
throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the plan.');
}
$relatedcompetencies = api::list_related_competencies($competency->get_id());
$userid = $plan->get_userid();
$user = $DB->get_record('user', array('id' => $userid));
$evidence = api::list_evidence($userid, $this->competencyid, $plan->get_id());
$params = array('competency' => $competency, 'usercompetency' => $usercompetency, 'usercompetencyplan' => $usercompetencyplan, 'evidence' => $evidence, 'user' => $user, 'plan' => $plan, 'relatedcompetencies' => $relatedcompetencies);
$exporter = new user_competency_summary_in_plan_exporter(null, $params);
$data = $exporter->export($output);
return $data;
}
示例3: test_list_evidence
/**
* Test list of evidences for plan completed and not completed.
*/
public function test_list_evidence()
{
global $DB;
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$syscontext = context_system::instance();
// Create users.
$user = $dg->create_user();
$this->setUser($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()));
// Create 2 user plans and add competency to each plan.
$p1 = $lpg->create_plan(array('userid' => $user->id));
$p2 = $lpg->create_plan(array('userid' => $user->id));
$pc1 = $lpg->create_plan_competency(array('planid' => $p1->get_id(), 'competencyid' => $c1->get_id()));
$pc2 = $lpg->create_plan_competency(array('planid' => $p2->get_id(), 'competencyid' => $c1->get_id()));
// Create user competency and add an evidence.
$uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get_id()));
$e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get_id()));
// Check both plans as one evidence.
$this->assertEquals(1, count(api::list_evidence($user->id, $c1->get_id(), $p1->get_id())));
$this->assertEquals(1, count(api::list_evidence($user->id, $c1->get_id(), $p2->get_id())));
// Complete second plan.
$p2->set_status(plan::STATUS_COMPLETE);
$p2->update();
// Add another evidence for the same competency, but in the future (time + 1).
$e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get_id()));
$evidencesql = "UPDATE {" . evidence::TABLE . "} SET timecreated = :currenttime WHERE id = :evidenceid";
$DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get_id()));
// Check that the first plan, which is not completed, has all the evidence.
$this->assertEquals(2, count(api::list_evidence($user->id, $c1->get_id(), $p1->get_id())));
// Check that the second plan, completed before the new evidence, only has the first piece of evidence.
$listevidences = api::list_evidence($user->id, $c1->get_id(), $p2->get_id());
$this->assertEquals(1, count($listevidences));
$this->assertEquals($e1->get_id(), $listevidences[$e1->get_id()]->get_id());
}