本文整理汇总了PHP中core_competency\api::count_plans_for_template方法的典型用法代码示例。如果您正苦于以下问题:PHP api::count_plans_for_template方法的具体用法?PHP api::count_plans_for_template怎么用?PHP api::count_plans_for_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::count_plans_for_template方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Return the custom definition of the properties of this model.
*
* @param int $templateid The template we want to generate statistics for.
*/
public function __construct($templateid)
{
$template = new template($templateid);
$this->competencycount = api::count_competencies_in_template($template);
$this->unlinkedcompetencycount = api::count_competencies_in_template_with_no_courses($template);
$this->plancount = api::count_plans_for_template($template, 0);
$this->completedplancount = api::count_plans_for_template($template, plan::STATUS_COMPLETE);
$this->usercompetencyplancount = api::count_user_competency_plans_for_template($template);
$this->proficientusercompetencyplancount = api::count_user_competency_plans_for_template($template, true);
$this->leastproficientcompetencies = api::get_least_proficient_competencies_for_template($template, 0, 3);
}
示例2: test_template_statistics
/**
* Test template statistics api functions.
*/
public function test_template_statistics()
{
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
$this->setAdminUser();
$u1 = $dg->create_user();
$u2 = $dg->create_user();
$u3 = $dg->create_user();
$u4 = $dg->create_user();
$c1 = $dg->create_course();
$framework = $lpg->create_framework();
// Create 6 competencies.
$comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
// Link 5 out of 6 to a course.
$lpg->create_course_competency(array('competencyid' => $comp1->get_id(), 'courseid' => $c1->id));
$lpg->create_course_competency(array('competencyid' => $comp2->get_id(), 'courseid' => $c1->id));
$lpg->create_course_competency(array('competencyid' => $comp3->get_id(), 'courseid' => $c1->id));
$lpg->create_course_competency(array('competencyid' => $comp4->get_id(), 'courseid' => $c1->id));
$lpg->create_course_competency(array('competencyid' => $comp5->get_id(), 'courseid' => $c1->id));
// Put all 6 in a template.
$tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();
$tplc1 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $comp1->get_id()));
$tplc2 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $comp2->get_id()));
$tplc3 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $comp3->get_id()));
$tplc4 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $comp4->get_id()));
$tplc5 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $comp5->get_id()));
$tplc6 = $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $comp6->get_id()));
// Create some plans from the template.
$p1 = $lpg->create_plan(array('templateid' => $tpl->get_id(), 'userid' => $u1->id));
$p2 = $lpg->create_plan(array('templateid' => $tpl->get_id(), 'userid' => $u2->id));
$p3 = $lpg->create_plan(array('templateid' => $tpl->get_id(), 'userid' => $u3->id));
$p4 = $lpg->create_plan(array('templateid' => $tpl->get_id(), 'userid' => $u4->id));
// Rate some competencies.
// User 1.
$lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $comp1->get_id(), 'proficiency' => true, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $comp2->get_id(), 'proficiency' => true, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $comp3->get_id(), 'proficiency' => true, 'grade' => 1));
// User 2.
$lpg->create_user_competency(array('userid' => $u2->id, 'competencyid' => $comp1->get_id(), 'proficiency' => false, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u2->id, 'competencyid' => $comp2->get_id(), 'proficiency' => false, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u2->id, 'competencyid' => $comp3->get_id(), 'proficiency' => false, 'grade' => 1));
// User 3.
$lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp2->get_id(), 'proficiency' => false, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp3->get_id(), 'proficiency' => true, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp4->get_id(), 'proficiency' => false, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp5->get_id(), 'proficiency' => true, 'grade' => 1));
// User 4.
$lpg->create_user_competency(array('userid' => $u4->id, 'competencyid' => $comp3->get_id(), 'proficiency' => true, 'grade' => 1));
$lpg->create_user_competency(array('userid' => $u4->id, 'competencyid' => $comp5->get_id(), 'proficiency' => true, 'grade' => 1));
// Complete 3 out of 4 plans.
api::complete_plan($p1->get_id());
api::complete_plan($p2->get_id());
api::complete_plan($p3->get_id());
// OK we have enough data - lets call some API functions and check for expected results.
$result = api::count_competencies_in_template_with_no_courses($tpl->get_id());
$this->assertEquals(1, $result);
$result = api::count_plans_for_template($tpl->get_id());
$this->assertEquals(4, $result);
$result = api::count_plans_for_template($tpl->get_id(), plan::STATUS_COMPLETE);
$this->assertEquals(3, $result);
// This counts the records of competencies in completed plans for all users with a plan from this template.
$result = api::count_user_competency_plans_for_template($tpl->get_id());
// There should be 3 plans * 6 competencies.
$this->assertEquals(18, $result);
// This counts the records of proficient competencies in completed plans for all users with a plan from this template.
$result = api::count_user_competency_plans_for_template($tpl->get_id(), true);
// There should be 5.
$this->assertEquals(5, $result);
// This counts the records of not proficient competencies in completed plans for all users with a plan from this template.
$result = api::count_user_competency_plans_for_template($tpl->get_id(), false);
// There should be 13.
$this->assertEquals(13, $result);
// This lists the plans based on this template, optionally filtered by status.
$result = api::list_plans_for_template($tpl->get_id());
$this->assertEquals(4, count($result));
foreach ($result as $one) {
$this->assertInstanceOf('\\core_competency\\plan', $one);
}
// This lists the plans based on this template, optionally filtered by status.
$result = api::list_plans_for_template($tpl->get_id(), plan::STATUS_COMPLETE);
$this->assertEquals(3, count($result));
foreach ($result as $one) {
$this->assertInstanceOf('\\core_competency\\plan', $one);
$this->assertEquals(plan::STATUS_COMPLETE, $one->get_status());
}
$result = api::get_least_proficient_competencies_for_template($tpl->get_id(), 0, 2);
// Our times completed counts should look like this:
// - comp1 - 1
// - comp2 - 1
// - comp3 - 2
// - comp4 - 0
//.........这里部分代码省略.........