當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。