本文整理汇总了PHP中core_competency\api::list_related_competencies方法的典型用法代码示例。如果您正苦于以下问题:PHP api::list_related_competencies方法的具体用法?PHP api::list_related_competencies怎么用?PHP api::list_related_competencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::list_related_competencies方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct this renderable.
*
* @param \core_competency\competency $competency Competency persistent.
* @param \core_competency\competency_framework $framework framework persistent.
* @param boolean $includerelated Include or not related competencies.
* @param boolean $includecourses Include or not competency courses.
*/
public function __construct($competency, $framework, $includerelated, $includecourses)
{
$this->competency = $competency;
$this->framework = $framework;
if ($includerelated) {
$this->relatedcompetencies = api::list_related_competencies($competency->get_id());
}
if ($includecourses) {
$this->courses = api::list_courses_using_competency($competency->get_id());
}
}
示例2: 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;
}
示例3: export_for_template
/**
* Export the data.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output)
{
global $DB;
$usercompetencycourse = api::get_user_competency_in_course($this->courseid, $this->userid, $this->competencyid);
$competency = $usercompetencycourse->get_competency();
if (empty($usercompetencycourse) || empty($competency)) {
throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the course.');
}
$relatedcompetencies = api::list_related_competencies($competency->get_id());
$user = $DB->get_record('user', array('id' => $this->userid));
$evidence = api::list_evidence_in_course($this->userid, $this->courseid, $this->competencyid);
$course = $DB->get_record('course', array('id' => $this->courseid));
$params = array('competency' => $competency, 'usercompetencycourse' => $usercompetencycourse, 'evidence' => $evidence, 'user' => $user, 'course' => $course, 'scale' => $competency->get_scale(), 'relatedcompetencies' => $relatedcompetencies);
$exporter = new user_competency_summary_in_course_exporter(null, $params);
$data = $exporter->export($output);
return $data;
}
示例4: 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;
}
示例5: test_delete_competency
public function test_delete_competency()
{
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
$this->setAdminUser();
$u1 = $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()));
$c1a = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
$c1b = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1a->get_id()));
$c11b = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1b->get_id()));
$c12b = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1b->get_id()));
// Set rules on parent competency.
$c1->set_ruleoutcome(competency::OUTCOME_EVIDENCE);
$c1->set_ruletype('core_competency\\competency_rule_all');
$c1->update();
// If we delete competeny, the related competencies relations and evidences should be deleted.
// Create related competencies using one of c1a competency descendants.
$rc = $lpg->create_related_competency(array('competencyid' => $c2->get_id(), 'relatedcompetencyid' => $c11b->get_id()));
$this->assertEquals($c11b->get_id(), $rc->get_relatedcompetencyid());
// Creating a standard evidence with minimal information.
$uc2 = $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $c11b->get_id()));
$evidence = $lpg->create_evidence(array('usercompetencyid' => $uc2->get_id()));
$this->assertEquals($uc2->get_id(), $evidence->get_usercompetencyid());
$uc2->delete();
$this->assertTrue(api::delete_competency($c1a->get_id()));
$this->assertFalse(competency::record_exists($c1a->get_id()));
// Check that on delete, we reset the rule on parent competency.
$c1->read();
$this->assertNull($c1->get_ruletype());
$this->assertNull($c1->get_ruletype());
$this->assertEquals(competency::OUTCOME_NONE, $c1->get_ruleoutcome());
// Check that descendants were also deleted.
$this->assertFalse(competency::record_exists($c1b->get_id()));
$this->assertFalse(competency::record_exists($c11b->get_id()));
$this->assertFalse(competency::record_exists($c12b->get_id()));
// Check if evidence are also deleted.
$this->assertEquals(0, \core_competency\user_evidence_competency::count_records(array('competencyid' => $c11b->get_id())));
// Check if related conpetency relation is deleted.
$this->assertEquals(0, count(api::list_related_competencies($c2->get_id())));
// Delete a simple competency.
$this->assertTrue(api::delete_competency($c2->get_id()));
$this->assertFalse(competency::record_exists($c2->get_id()));
}
示例6: __construct
/**
* Construct this renderable.
*
* @param int $competencyid
*/
public function __construct($competencyid)
{
$this->competency = api::read_competency($competencyid);
$this->context = $this->competency->get_context();
$this->relatedcompetencies = api::list_related_competencies($competencyid);
}
示例7: export_for_template
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param \renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output)
{
$data = new stdClass();
$data->template = (new template_exporter($this->template))->export($output);
$data->pagecontextid = $this->pagecontext->id;
$data->competencies = array();
$contextcache = array();
$frameworkcache = array();
foreach ($this->competencies as $competency) {
if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
$contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
}
$context = $contextcache[$competency->get_competencyframeworkid()];
if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
$frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
}
$framework = $frameworkcache[$competency->get_competencyframeworkid()];
$courses = api::list_courses_using_competency($competency->get_id());
$relatedcompetencies = api::list_related_competencies($competency->get_id());
$related = array('competency' => $competency, 'linkedcourses' => $courses, 'context' => $context, 'relatedcompetencies' => $relatedcompetencies, 'framework' => $framework);
$exporter = new competency_summary_exporter(null, $related);
$record = $exporter->export($output);
array_push($data->competencies, $record);
}
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(false);
$data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
$data->canmanagetemplatecompetencies = $this->canmanagetemplatecompetencies;
$data->manageurl = $this->manageurl->out(true);
$exporter = new template_statistics_exporter($this->templatestatistics);
$data->statistics = $exporter->export($output);
$data->showcompetencylinks = true;
return $data;
}