本文整理汇总了PHP中Skill::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Skill::add方法的具体用法?PHP Skill::add怎么用?PHP Skill::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skill
的用法示例。
在下文中一共展示了Skill::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_data
/**
* Save the imported data
* @param array List of users
* @return void
* @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
*/
function save_data($skills)
{
if (is_array($skills)) {
$parents = array();
foreach ($skills as $index => $skill) {
if (isset($parents[$skill['parent_id']])) {
$skill['parent_id'] = $parents[$skill['parent_id']];
} else {
$skill['parent_id'] = 1;
}
$skill['a'] = 'add';
$saved_id = $skill['id'];
$skill['id'] = null;
$oskill = new Skill();
$skill_id = $oskill->add($skill);
$parents[$saved_id] = $skill_id;
}
}
}
示例2: FormValidator
$skillList = [0 => get_lang('None')];
$gradebookList = [];
foreach ($allSkills as $skill) {
$skillList[$skill['id']] = $skill['name'];
}
foreach ($allGradebooks as $gradebook) {
$gradebookList[$gradebook['id']] = $gradebook['name'];
}
/* Form */
$createForm = new FormValidator('skill_create');
$createForm->addHeader(get_lang('CreateSkill'));
$createForm->addText('name', get_lang('Name'), true, ['id' => 'name']);
$createForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']);
$createForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']);
$createForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]);
$createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
$createForm->addButtonSave(get_lang('Save'));
$createForm->addHidden('id', null);
$createForm->setDefaults($formDefaultValues);
if ($createForm->validate()) {
$created = $objSkill->add($createForm->getSubmitValues());
if ($created) {
Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success');
} else {
Display::return_message(get_lang('CannotCreateSkill'), 'error');
}
header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php');
exit;
}
//$tpl = new Template(get_lang('CreateSkill'));
echo $createForm->returnForm();
示例3: isset
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
if (api_get_setting('skill.allow_skills_tool') != 'true') {
exit;
}
Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
api_block_anonymous_users();
$skill = new Skill();
$gradebook = new Gradebook();
$skill_gradebook = new SkillRelGradebook();
switch ($action) {
case 'add':
if (api_is_platform_admin() || api_is_drh()) {
if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
$skill_id = $skill->edit($_REQUEST);
} else {
$skill_id = $skill->add($_REQUEST);
}
}
echo $skill_id;
break;
case 'delete_skill':
if (api_is_platform_admin() || api_is_drh()) {
echo $skill->delete($_REQUEST['skill_id']);
}
break;
case 'find_skills':
$skills = $skill->find('all', array('where' => array('name LIKE %?% ' => $_REQUEST['tag'])));
$return_skills = array();
foreach ($skills as $skill) {
$skill['caption'] = $skill['name'];
$skill['value'] = $skill['id'];