本文整理汇总了PHP中core_competency\api::update_competency方法的典型用法代码示例。如果您正苦于以下问题:PHP api::update_competency方法的具体用法?PHP api::update_competency怎么用?PHP api::update_competency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::update_competency方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_competency
/**
* Update an existing competency
*
* @param array $competency The array of competency fields (id is required).
* @return boolean
*/
public static function update_competency($competency)
{
$params = self::validate_parameters(self::update_competency_parameters(), array('competency' => $competency));
$params = $params['competency'];
$competency = api::read_competency($params['id']);
self::validate_context($competency->get_context());
$params = (object) $params;
return api::update_competency($params);
}
示例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();
示例3: test_competency_updated
/**
* Test the competency updated event.
*
*/
public function test_competency_updated()
{
$this->resetAfterTest(true);
$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$f1 = $lpg->create_framework();
$competency = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c2 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
$c12 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
$c13 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'parentid' => $c1->get_id()));
// Trigger and capture the event.
$sink = $this->redirectEvents();
$competency->set_shortname('Shortname modified');
api::update_competency($competency->to_record());
// Get our event event.
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\\core\\event\\competency_updated', $event);
$this->assertEquals($competency->get_id(), $event->objectid);
$this->assertEquals($competency->get_context()->id, $event->contextid);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingNotCalled();
}