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


PHP api::add_related_competency方法代码示例

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


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

示例1: test_duplicate_framework

 /**
  * Test duplicate a framework.
  */
 public function test_duplicate_framework()
 {
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $syscontext = context_system::instance();
     $params = array('shortname' => 'shortname_a', 'idnumber' => 'idnumber_c', 'description' => 'description', 'descriptionformat' => FORMAT_HTML, 'visible' => true, 'contextid' => $syscontext->id);
     $framework = $lpg->create_framework($params);
     $competency1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $competency2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $competency3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $competency4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
     $competency41 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id(), 'parentid' => $competency4->get_id()));
     $competency42 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id(), 'parentid' => $competency4->get_id()));
     $competencyidnumbers = array($competency1->get_idnumber(), $competency2->get_idnumber(), $competency3->get_idnumber(), $competency4->get_idnumber(), $competency41->get_idnumber(), $competency42->get_idnumber());
     $config = json_encode(array('base' => array('points' => 4), 'competencies' => array(array('id' => $competency41->get_id(), 'points' => 3, 'required' => 0), array('id' => $competency42->get_id(), 'points' => 2, 'required' => 1))));
     $competency4->set_ruletype('core_competency\\competency_rule_points');
     $competency4->set_ruleoutcome(\core_competency\competency::OUTCOME_EVIDENCE);
     $competency4->set_ruleconfig($config);
     $competency4->update();
     api::add_related_competency($competency1->get_id(), $competency2->get_id());
     api::add_related_competency($competency3->get_id(), $competency4->get_id());
     $frameworkduplicated1 = api::duplicate_framework($framework->get_id());
     $frameworkduplicated2 = api::duplicate_framework($framework->get_id());
     $this->assertEquals($framework->get_idnumber() . '_1', $frameworkduplicated1->get_idnumber());
     $this->assertEquals($framework->get_idnumber() . '_2', $frameworkduplicated2->get_idnumber());
     $competenciesfr1 = api::list_competencies(array('competencyframeworkid' => $frameworkduplicated1->get_id()));
     $competenciesfr2 = api::list_competencies(array('competencyframeworkid' => $frameworkduplicated2->get_id()));
     $competencyidsfr1 = array();
     $competencyidsfr2 = array();
     foreach ($competenciesfr1 as $cmp) {
         $competencyidsfr1[] = $cmp->get_idnumber();
     }
     foreach ($competenciesfr2 as $cmp) {
         $competencyidsfr2[] = $cmp->get_idnumber();
     }
     $this->assertEmpty(array_diff($competencyidsfr1, $competencyidnumbers));
     $this->assertEmpty(array_diff($competencyidsfr2, $competencyidnumbers));
     $this->assertCount(6, $competenciesfr1);
     $this->assertCount(6, $competenciesfr2);
     // Test the related competencies.
     reset($competenciesfr1);
     $compduplicated1 = current($competenciesfr1);
     $relatedcompetencies = $compduplicated1->get_related_competencies();
     $comprelated = current($relatedcompetencies);
     $this->assertEquals($comprelated->get_idnumber(), $competency2->get_idnumber());
     // Check if config rule have been ported correctly.
     $competency4duplicated = competency::get_record(array('idnumber' => $competency4->get_idnumber(), 'competencyframeworkid' => $frameworkduplicated2->get_id()));
     $configduplicated = json_decode($competency4duplicated->get_ruleconfig(), true);
     $configorigin = json_decode($config, true);
     // Check that the 2 config have the same base.
     $this->assertEquals($configorigin['base'], $configduplicated['base']);
     $this->assertEquals(count($configorigin['competencies']), count($configduplicated['competencies']));
     $competencyidsrules = array();
     foreach ($configduplicated['competencies'] as $key => $value) {
         // Check that the only difference between the 2 config is id competency.
         $this->assertEquals(1, count(array_diff($value, $configorigin['competencies'][$key])));
         $competencyidsrules[] = $value['id'];
     }
     $this->assertTrue($competency4duplicated->is_parent_of($competencyidsrules));
     // Test duplicate an empty framework.
     $emptyfrm = $lpg->create_framework();
     $emptyfrmduplicated = api::duplicate_framework($emptyfrm->get_id());
     $this->assertEquals($emptyfrm->get_idnumber() . '_1', $emptyfrmduplicated->get_idnumber());
     $nbcomp = api::count_competencies(array('competencyframeworkid' => $emptyfrmduplicated->get_id()));
     $this->assertEquals(0, $nbcomp);
 }
开发者ID:dg711,项目名称:moodle,代码行数:70,代码来源:api_test.php

示例2: add_related_competency

 /**
  * Adds a related competency.
  *
  * @param int $competencyid
  * @param int $relatedcompetencyid
  * @return bool
  */
 public static function add_related_competency($competencyid, $relatedcompetencyid)
 {
     $params = self::validate_parameters(self::add_related_competency_parameters(), array('competencyid' => $competencyid, 'relatedcompetencyid' => $relatedcompetencyid));
     $competency = api::read_competency($params['competencyid']);
     self::validate_context($competency->get_context());
     return api::add_related_competency($params['competencyid'], $params['relatedcompetencyid']);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:external.php

示例3: set_related_competencies

 public function set_related_competencies($record)
 {
     if (!empty($record->related)) {
         foreach ($record->related as $related) {
             api::add_related_competency($record->id, $related->id);
         }
     }
     foreach ($record->children as $child) {
         $this->set_related_competencies($child);
     }
 }
开发者ID:damyon,项目名称:moodle-tool_lpimportau,代码行数:11,代码来源:framework_importer.php

示例4: set_related

 private function set_related($record)
 {
     $comp = $record->createdcomp;
     if ($record->relatedidnumbers) {
         $allidnumbers = explode(',', $record->relatedidnumbers);
         foreach ($allidnumbers as $rawidnumber) {
             $idnumber = str_replace('%2C', ',', $rawidnumber);
             if (isset($this->flat[$idnumber])) {
                 $relatedcomp = $this->flat[$idnumber]->createdcomp;
                 api::add_related_competency($comp->get_id(), $relatedcomp->get_id());
             }
         }
     }
     foreach ($record->children as $child) {
         $this->set_related($child);
     }
 }
开发者ID:damyon,项目名称:moodle-tool_lpimportcsv,代码行数:17,代码来源:framework_importer.php


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