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


PHP api::reorder_template_competency方法代码示例

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


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

示例1: reorder_template_competency

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

示例2: test_reorder_template_competencies_permissions

 public function test_reorder_template_competencies_permissions()
 {
     $this->resetAfterTest(true);
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $cat = $dg->create_category();
     $catcontext = context_coursecat::instance($cat->id);
     $syscontext = context_system::instance();
     $user = $dg->create_user();
     $role = $dg->create_role();
     assign_capability('moodle/competency:templatemanage', CAP_ALLOW, $role, $syscontext->id, true);
     $dg->role_assign($role, $user->id, $syscontext->id);
     // Create a template.
     $template = $lpg->create_template(array('contextid' => $catcontext->id));
     // Create a competency framework.
     $framework = $lpg->create_framework(array('contextid' => $catcontext->id));
     // Create competencies.
     $competency1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $competency2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     // Add the competencies.
     $lpg->create_template_competency(array('templateid' => $template->get_id(), 'competencyid' => $competency1->get_id()));
     $lpg->create_template_competency(array('templateid' => $template->get_id(), 'competencyid' => $competency2->get_id()));
     $this->setUser($user);
     // Can reorder competencies with system context permissions in category context.
     $result = api::reorder_template_competency($template->get_id(), $competency2->get_id(), $competency1->get_id());
     $this->assertTrue($result);
     unassign_capability('moodle/competency:templatemanage', $role, $syscontext->id);
     accesslib_clear_all_caches_for_unit_testing();
     try {
         api::reorder_template_competency($template->get_id(), $competency2->get_id(), $competency1->get_id());
         $this->fail('Exception expected due to not permissions to manage template competencies');
     } catch (required_capability_exception $e) {
         $this->assertEquals('nopermissions', $e->errorcode);
     }
     // Giving permissions in category context.
     assign_capability('moodle/competency:templatemanage', CAP_ALLOW, $role, $catcontext->id, true);
     $dg->role_assign($role, $user->id, $catcontext->id);
     // User with templatemanage capability in category context can reorder competencies in temple.
     $result = api::reorder_template_competency($template->get_id(), $competency1->get_id(), $competency2->get_id());
     $this->assertTrue($result);
     // Removing templatemanage capability in category context.
     unassign_capability('moodle/competency:templatemanage', $role, $catcontext->id);
     accesslib_clear_all_caches_for_unit_testing();
     try {
         api::reorder_template_competency($template->get_id(), $competency2->get_id(), $competency1->get_id());
         $this->fail('Exception expected due to not permissions to manage template competencies');
     } catch (required_capability_exception $e) {
         $this->assertEquals('nopermissions', $e->errorcode);
     }
 }
开发者ID:dg711,项目名称:moodle,代码行数:50,代码来源:api_test.php

示例3: 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:IFPBMoodle,项目名称:moodle,代码行数:62,代码来源:api_test.php


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