当前位置: 首页>>代码示例>>PHP>>正文


PHP api::reorder_plan_competency方法代码示例

本文整理汇总了PHP中core_competency\api::reorder_plan_competency方法的典型用法代码示例。如果您正苦于以下问题:PHP api::reorder_plan_competency方法的具体用法?PHP api::reorder_plan_competency怎么用?PHP api::reorder_plan_competency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_competency\api的用法示例。


在下文中一共展示了api::reorder_plan_competency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_complete_plan_doesnot_change_order

 /**
  * Test completing plan does not change the order of competencies.
  */
 public function test_complete_plan_doesnot_change_order()
 {
     global $DB;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $syscontext = context_system::instance();
     // Create users and roles for the test.
     $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()));
     // Create two plans and assign competencies.
     $plan = $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()));
     // Changing competencies order in plan competency.
     api::reorder_plan_competency($plan->get_id(), $c1->get_id(), $c3->get_id());
     $competencies = api::list_plan_competencies($plan);
     $this->assertEquals($c2->get_id(), $competencies[0]->competency->get_id());
     $this->assertEquals($c3->get_id(), $competencies[1]->competency->get_id());
     $this->assertEquals($c1->get_id(), $competencies[2]->competency->get_id());
     // Completing plan.
     api::complete_plan($plan);
     $competencies = api::list_plan_competencies($plan);
     // Completing plan does not change order.
     $this->assertEquals($c2->get_id(), $competencies[0]->competency->get_id());
     $this->assertEquals($c3->get_id(), $competencies[1]->competency->get_id());
     $this->assertEquals($c1->get_id(), $competencies[2]->competency->get_id());
     // Testing plan based on template.
     $template = $lpg->create_template();
     $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()));
     $lpg->create_template_competency(array('templateid' => $template->get_id(), 'competencyid' => $c1->get_id()));
     $lpg->create_template_competency(array('templateid' => $template->get_id(), 'competencyid' => $c2->get_id()));
     $lpg->create_template_competency(array('templateid' => $template->get_id(), 'competencyid' => $c3->get_id()));
     // Reorder competencies in template.
     api::reorder_template_competency($template->get_id(), $c1->get_id(), $c3->get_id());
     // Create plan from template.
     $plan = api::create_plan_from_template($template->get_id(), $user->id);
     $competencies = api::list_plan_competencies($plan);
     // Completing plan does not change order.
     $this->assertEquals($c2->get_id(), $competencies[0]->competency->get_id());
     $this->assertEquals($c3->get_id(), $competencies[1]->competency->get_id());
     $this->assertEquals($c1->get_id(), $competencies[2]->competency->get_id());
     // Completing plan.
     api::complete_plan($plan);
     $competencies = api::list_plan_competencies($plan);
     // Completing plan does not change order.
     $this->assertEquals($c2->get_id(), $competencies[0]->competency->get_id());
     $this->assertEquals($c3->get_id(), $competencies[1]->competency->get_id());
     $this->assertEquals($c1->get_id(), $competencies[2]->competency->get_id());
 }
开发者ID:dg711,项目名称:moodle,代码行数:62,代码来源:api_test.php

示例2: reorder_plan_competency

 /**
  * Change the order of plan competencies.
  *
  * @param int $planid The plan id
  * @param int $competencyidfrom The competency to move.
  * @param int $competencyidto The competency to move to.
  * @return bool
  */
 public static function reorder_plan_competency($planid, $competencyidfrom, $competencyidto)
 {
     $params = self::validate_parameters(self::reorder_plan_competency_parameters(), array('planid' => $planid, 'competencyidfrom' => $competencyidfrom, 'competencyidto' => $competencyidto));
     $plan = api::read_plan($params['planid']);
     self::validate_context($plan->get_context());
     return api::reorder_plan_competency($params['planid'], $params['competencyidfrom'], $params['competencyidto']);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:external.php


注:本文中的core_competency\api::reorder_plan_competency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。