本文整理汇总了PHP中core_competency\api::create_framework方法的典型用法代码示例。如果您正苦于以下问题:PHP api::create_framework方法的具体用法?PHP api::create_framework怎么用?PHP api::create_framework使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::create_framework方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_competency_framework_created
/**
* Test the competency framework created event.
*
*/
public function test_competency_framework_created()
{
$this->resetAfterTest(true);
$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
// Use DataGenerator to have a record framework with the right format.
$record = $lpg->create_framework()->to_record();
$record->id = 0;
$record->shortname = "New shortname";
$record->idnumber = "New idnumber";
// Trigger and capture the event.
$sink = $this->redirectEvents();
$framework = api::create_framework((object) $record);
// Get our event event.
$events = $sink->get_events();
$event = reset($events);
// Check that the event data is valid.
$this->assertInstanceOf('\\core\\event\\competency_framework_created', $event);
$this->assertEquals($framework->get_id(), $event->objectid);
$this->assertEquals($framework->get_contextid(), $event->contextid);
$this->assertEventContextNotUsed($event);
$this->assertDebuggingNotCalled();
}
示例2: create_competency_framework
/**
* Create a new competency framework
*
* @param array $competencyframework A single param with all the fields for a competency framework.
* @return \stdClass The new record
*/
public static function create_competency_framework($competencyframework)
{
global $PAGE;
$params = self::validate_parameters(self::create_competency_framework_parameters(), array('competencyframework' => $competencyframework));
$params = $params['competencyframework'];
$context = self::get_context_from_params($params);
self::validate_context($context);
$output = $PAGE->get_renderer('core');
unset($params['contextlevel']);
unset($params['instanceid']);
$params['contextid'] = $context->id;
$params = (object) $params;
$result = api::create_framework($params);
$exporter = new competency_framework_exporter($result);
$record = $exporter->export($output);
return $record;
}
示例3: import
/**
* Do the job.
*/
public function import()
{
$record = clone $this->framework;
unset($record->children);
$record->scaleid = $this->get_scale_id($record->scalevalues, $record->shortname);
$record->scaleconfiguration = $this->get_scale_configuration($record->scaleid, $record->scaleconfiguration);
unset($record->scalevalues);
$record->contextid = context_system::instance()->id;
$framework = api::create_framework($record);
// Now all the children;
foreach ($this->framework->children as $comp) {
$this->create_competency($comp, null, $framework);
}
// Now create the rules.
foreach ($this->framework->children as $record) {
$this->set_rules($record);
$this->set_related($record);
}
$this->importer->cleanup();
return $framework;
}
示例4: require_login
// We check that we have the permission to edit this framework, in its own context.
require_login();
\core_competency\api::require_enabled();
require_capability('moodle/competency:competencymanage', $context);
// Set up the framework page.
list($pagetitle, $pagesubtitle, $url, $frameworksurl) = tool_lp\page_helper::setup_for_framework($id, $pagecontextid, $framework, $returntype);
$output = $PAGE->get_renderer('tool_lp');
$form = new \tool_lp\form\competency_framework($url->out(false), array('context' => $context, 'persistent' => $framework));
if ($form->is_cancelled()) {
redirect($frameworksurl);
} else {
if ($data = $form->get_data()) {
if (empty($data->id)) {
// Create new framework.
$data->contextid = $context->id;
$framework = \core_competency\api::create_framework($data);
$frameworkmanageurl = new moodle_url('/admin/tool/lp/competencies.php', array('pagecontextid' => $pagecontextid, 'competencyframeworkid' => $framework->get_id()));
$messagesuccess = get_string('competencyframeworkcreated', 'tool_lp');
redirect($frameworkmanageurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS);
} else {
\core_competency\api::update_framework($data);
$messagesuccess = get_string('competencyframeworkupdated', 'tool_lp');
redirect($frameworksurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS);
}
}
}
echo $output->header();
echo $output->heading($pagetitle, 2);
echo $output->heading($pagesubtitle, 3);
$form->display();
echo $output->footer();