本文整理汇总了PHP中core_competency\api::list_frameworks方法的典型用法代码示例。如果您正苦于以下问题:PHP api::list_frameworks方法的具体用法?PHP api::list_frameworks怎么用?PHP api::list_frameworks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_competency\api
的用法示例。
在下文中一共展示了api::list_frameworks方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct this renderable.
*
* @param context $pagecontext The page context
*/
public function __construct(context $pagecontext)
{
$this->pagecontext = $pagecontext;
if (competency_framework::can_manage_context($this->pagecontext)) {
$addpage = new single_button(new moodle_url('/admin/tool/lp/editcompetencyframework.php', array('pagecontextid' => $this->pagecontext->id)), get_string('addnewcompetencyframework', 'tool_lp'), 'get');
$this->navigation[] = $addpage;
}
$this->competencyframeworks = api::list_frameworks('shortname', 'ASC', 0, 0, $this->pagecontext);
}
示例2: definition
/**
* Define the form - called by parent constructor
*/
public function definition()
{
$mform = $this->_form;
$context = context_system::instance();
$frameworks = api::list_frameworks('shortname', 'ASC', null, null, $context);
$options = array();
foreach ($frameworks as $framework) {
$options[$framework->get_id()] = $framework->get_shortname();
}
if (empty($options)) {
$mform->addElement('static', 'frameworkid', '', get_string('noframeworks', 'tool_lpimportcsv'));
} else {
$mform->addElement('select', 'frameworkid', get_string('competencyframework', 'tool_lp'), $options);
$mform->setType('frameworkid', PARAM_INT);
$mform->addRule('frameworkid', null, 'required', null, 'client');
$this->add_action_buttons(true, get_string('export', 'tool_lpimportcsv'));
}
$mform->setDisableShortforms();
}
示例3: test_list_frameworks
/**
* Test listing framework with order param.
*/
public function test_list_frameworks()
{
$this->resetAfterTest(true);
$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
// Create a list of frameworks.
$framework1 = $lpg->create_framework(array('shortname' => 'shortname_alpha', 'idnumber' => 'idnumber_cinnamon', 'description' => 'description', 'descriptionformat' => FORMAT_HTML, 'visible' => true, 'contextid' => context_system::instance()->id));
$framework2 = $lpg->create_framework(array('shortname' => 'shortname_beetroot', 'idnumber' => 'idnumber_apple', 'description' => 'description', 'descriptionformat' => FORMAT_HTML, 'visible' => true, 'contextid' => context_system::instance()->id));
$framework3 = $lpg->create_framework(array('shortname' => 'shortname_crisps', 'idnumber' => 'idnumber_beer', 'description' => 'description', 'descriptionformat' => FORMAT_HTML, 'visible' => false, 'contextid' => context_system::instance()->id));
// Get frameworks list order by shortname desc.
$result = api::list_frameworks('shortname', 'DESC', null, 3, context_system::instance());
$f = (object) array_shift($result);
$this->assertEquals($framework3->get_id(), $f->get_id());
$f = (object) array_shift($result);
$this->assertEquals($framework2->get_id(), $f->get_id());
$f = (object) array_shift($result);
$this->assertEquals($framework1->get_id(), $f->get_id());
// Get frameworks list order by idnumber asc.
$result = api::list_frameworks('idnumber', 'ASC', null, 3, context_system::instance());
$f = (object) array_shift($result);
$this->assertEquals($framework2->get_id(), $f->get_id());
$f = (object) array_shift($result);
$this->assertEquals($framework3->get_id(), $f->get_id());
$f = (object) array_shift($result);
$this->assertEquals($framework1->get_id(), $f->get_id());
// Repeat excluding the non-visible ones.
$result = api::list_frameworks('idnumber', 'ASC', null, 3, context_system::instance(), 'self', true);
$this->assertCount(2, $result);
$f = (object) array_shift($result);
$this->assertEquals($framework2->get_id(), $f->get_id());
$f = (object) array_shift($result);
$this->assertEquals($framework1->get_id(), $f->get_id());
// Search by query string, trying match on shortname.
$result = api::list_frameworks('idnumber', 'ASC', null, 3, context_system::instance(), 'self', false, 'crisp');
$this->assertCount(1, $result);
$f = (object) array_shift($result);
$this->assertEquals($framework3->get_id(), $f->get_id());
// Search by query string, trying match on shortname, but hidden.
$result = api::list_frameworks('idnumber', 'ASC', null, 3, context_system::instance(), 'self', true, 'crisp');
$this->assertCount(0, $result);
// Search by query string, trying match on ID number.
$result = api::list_frameworks('idnumber', 'ASC', null, 3, context_system::instance(), 'self', false, 'apple');
$this->assertCount(1, $result);
$f = (object) array_shift($result);
$this->assertEquals($framework2->get_id(), $f->get_id());
// Search by query string, trying match on both.
$result = api::list_frameworks('idnumber', 'ASC', null, 3, context_system::instance(), 'self', false, 'bee');
$this->assertCount(2, $result);
$f = (object) array_shift($result);
$this->assertEquals($framework2->get_id(), $f->get_id());
$f = (object) array_shift($result);
$this->assertEquals($framework3->get_id(), $f->get_id());
}
示例4: list_competency_frameworks
/**
* List the existing competency frameworks
*
* @param int $sort
* @param string $order
* @param string $skip
* @param int $limit
* @param array $context
* @param bool $includes
* @param bool $onlyvisible
* @param string $query
*
* @return array
* @throws \required_capability_exception
* @throws invalid_parameter_exception
*/
public static function list_competency_frameworks($sort, $order, $skip, $limit, $context, $includes, $onlyvisible, $query = '')
{
global $PAGE;
$params = self::validate_parameters(self::list_competency_frameworks_parameters(), array('sort' => $sort, 'order' => $order, 'skip' => $skip, 'limit' => $limit, 'context' => $context, 'includes' => $includes, 'onlyvisible' => $onlyvisible, 'query' => $query));
$context = self::get_context_from_params($params['context']);
self::validate_context($context);
$output = $PAGE->get_renderer('core');
if ($params['order'] !== '' && $params['order'] !== 'ASC' && $params['order'] !== 'DESC') {
throw new invalid_parameter_exception('Invalid order param. Must be ASC, DESC or empty.');
}
$results = api::list_frameworks($params['sort'], $params['order'], $params['skip'], $params['limit'], $context, $params['includes'], $params['onlyvisible'], $params['query']);
$records = array();
foreach ($results as $result) {
$exporter = new competency_framework_exporter($result);
$record = $exporter->export($output);
array_push($records, $record);
}
return $records;
}