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


PHP api::create_competency方法代码示例

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


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

示例1: test_create_competency_reset_rules

 public function test_create_competency_reset_rules()
 {
     $data = $this->setup_framework_for_reset_rules_tests();
     $f1 = $data['f1'];
     $c1 = $data['c1'];
     $c1a = $data['c1a'];
     $c1a1 = $data['c1a1'];
     $c1a1a = $data['c1a1a'];
     $c1b = $data['c1b'];
     $c1b1 = $data['c1b1'];
     $c1b1a = $data['c1b1a'];
     $c2 = $data['c2'];
     $c2a = $data['c2a'];
     // Adding a new competency resets the rule of its parent.
     api::create_competency((object) array('shortname' => 'A', 'parentid' => $c1->get_id(), 'idnumber' => 'A', 'competencyframeworkid' => $f1->get_id()));
     $c1->read();
     $c1a->read();
     $c1a1->read();
     $c1b->read();
     $c2->read();
     $this->assertEquals(competency::OUTCOME_NONE, $c1->get_ruleoutcome());
     $this->assertEquals(competency::OUTCOME_EVIDENCE, $c1a->get_ruleoutcome());
     $this->assertEquals(competency::OUTCOME_EVIDENCE, $c1a1->get_ruleoutcome());
     $this->assertEquals(competency::OUTCOME_EVIDENCE, $c1b->get_ruleoutcome());
     $this->assertEquals(competency::OUTCOME_EVIDENCE, $c2->get_ruleoutcome());
 }
开发者ID:dg711,项目名称:moodle,代码行数:26,代码来源:api_test.php

示例2: moodle_url

// Get page URL.
$urloptions = ['id' => $id, 'competencyframeworkid' => $competencyframework->get_id(), 'parentid' => $parentid, 'pagecontextid' => $pagecontextid];
$url = new moodle_url("/admin/tool/lp/editcompetency.php", $urloptions);
// Set up the page.
list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_competency($pagecontextid, $url, $competencyframework, $competency, $parent);
// Set up the form.
$formoptions = ['competencyframework' => $competencyframework, 'parent' => $parent, 'persistent' => $competency, 'pagecontextid' => $pagecontextid];
$form = new \tool_lp\form\competency($url->out(false), $formoptions);
// Form cancelled.
if ($form->is_cancelled()) {
    redirect($returnurl);
}
// Get form data.
$data = $form->get_data();
if ($data) {
    if (empty($competency)) {
        \core_competency\api::create_competency($data);
        $returnmsg = get_string('competencycreated', 'tool_lp');
    } else {
        \core_competency\api::update_competency($data);
        $returnmsg = get_string('competencyupdated', 'tool_lp');
    }
    redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
}
// Render the page.
$output = $PAGE->get_renderer('tool_lp');
echo $output->header();
echo $output->heading($title);
echo $output->heading($subtitle, 3);
$form->display();
echo $output->footer();
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:editcompetency.php

示例3: create_competency

 public function create_competency($parent, $record, $framework)
 {
     $competency = new stdClass();
     $competency->competencyframeworkid = $framework->get_id();
     $competency->shortname = trim(clean_param(shorten_text($record->shortname, 50), PARAM_TEXT));
     if (!empty($record->description)) {
         $competency->description = trim(clean_param($record->description, PARAM_TEXT));
     }
     if ($parent) {
         $competency->parentid = $parent->get_id();
         if (empty($competency->shortname)) {
             if (!empty($competency->description)) {
                 $competency->shortname = shorten_text($competency->description, 50);
             } else {
                 $competency->shortname = $parent->get_shortname();
             }
         }
     } else {
         $competency->parentid = 0;
         if (empty($competency->shortname)) {
             if (!empty($competency->description)) {
                 $competency->shortname = shorten_text($competency->description, 50);
             } else {
                 $competency->shortname = $framework->get_shortname();
             }
         }
     }
     if (!empty($record->code)) {
         $competency->idnumber = trim(clean_param($record->code, PARAM_TEXT));
     } else {
         $competency->idnumber = trim(clean_param($record->idnumber, PARAM_TEXT));
     }
     if (!empty($competency->idnumber) && !empty($competency->shortname)) {
         $parent = api::create_competency($competency);
         $record->id = $parent->get_id();
         foreach ($record->children as $child) {
             $this->create_competency($parent, $child, $framework);
         }
         if (!empty($record->iscompetency) && !empty($record->children)) {
             $parent->set_ruletype('core_competency\\competency_rule_all');
             $parent->set_ruleoutcome(\core_competency\competency::OUTCOME_EVIDENCE);
             $parent->update();
         }
     }
 }
开发者ID:damyon,项目名称:moodle-tool_lpimportau,代码行数:45,代码来源:framework_importer.php

示例4: create_competency

 /**
  * Create a new competency
  *
  * @param array $competency All the fields for a competency record (including id)
  * @return array the competency
  */
 public static function create_competency($competency)
 {
     global $PAGE;
     $params = self::validate_parameters(self::create_competency_parameters(), array('competency' => $competency));
     $params = $params['competency'];
     $framework = api::read_framework($params['competencyframeworkid']);
     $context = $framework->get_context();
     self::validate_context($context);
     $output = $PAGE->get_renderer('core');
     $params = (object) $params;
     $result = api::create_competency($params);
     $exporter = new competency_exporter($result, array('context' => $context));
     $record = $exporter->export($output);
     return $record;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:external.php

示例5: test_competency_created

 /**
  * Test the competency created event.
  *
  */
 public function test_competency_created()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $f1 = $lpg->create_framework();
     $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
     $record = $c1->to_record();
     $record->id = 0;
     $record->idnumber = 'comp idnumber';
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     // Create competency should trigger a created event.
     $competency = api::create_competency($record);
     // Get our event event.
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\competency_created', $event);
     $this->assertEquals($competency->get_id(), $event->objectid);
     $this->assertEquals($competency->get_context()->id, $event->contextid);
     $this->assertEventContextNotUsed($event);
     $this->assertDebuggingNotCalled();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:event_test.php

示例6: create_competency

 /**
  * Recursive function to add a competency with all it's children.
  */
 public function create_competency($record, $parent, $framework)
 {
     $competency = new stdClass();
     $competency->competencyframeworkid = $framework->get_id();
     $competency->shortname = $record->shortname;
     if (!empty($record->description)) {
         $competency->description = $record->description;
         $competency->descriptionformat = $record->descriptionformat;
     }
     if ($record->scalevalues) {
         $competency->scaleid = $this->get_scale_id($record->scalevalues, $competency->shortname);
         $competency->scaleconfiguration = $this->get_scale_configuration($competency->scaleid, $record->scaleconfiguration);
     }
     if ($parent) {
         $competency->parentid = $parent->get_id();
     } else {
         $competency->parentid = 0;
     }
     $competency->idnumber = $record->idnumber;
     if (!empty($competency->idnumber) && !empty($competency->shortname)) {
         $comp = api::create_competency($competency);
         if ($record->exportid) {
             $this->mappings[$record->exportid] = $comp;
         }
         $record->createdcomp = $comp;
         foreach ($record->children as $child) {
             $this->create_competency($child, $comp, $framework);
         }
         return $comp;
     }
     return false;
 }
开发者ID:damyon,项目名称:moodle-tool_lpimportcsv,代码行数:35,代码来源:framework_importer.php


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