Add create child skill form - refs BT#9583 #7385

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent 4991e1ea67
commit d445934fdd
  1. 19
      main/admin/skill_create.php
  2. 6
      main/template/default/skill/list.tpl

@ -22,9 +22,26 @@ if (api_get_setting('allow_skills_tool') != 'true') {
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
/* Process data */
$skillParentId = isset($_GET['parent']) ? intval($_GET['parent']) : 0;
$formDefaultValues = [];
$objSkill = new Skill();
$objGradebook = new Gradebook();
if ($skillParentId > 0) {
$skillParentInfo = $objSkill->get_skill_info($skillParentId);
$formDefaultValues = [
'parent_id' => $skillParentInfo['id'],
'gradebook_id' => []
];
foreach ($skillParentInfo['gradebooks'] as $gradebook) {
$formDefaultValues['gradebook_id'][] = intval($gradebook['id']);
}
}
$allSkills = $objSkill->get_all();
$allGradebooks = $objGradebook->find('all');
@ -55,6 +72,8 @@ $createForm->addTextarea('description', get_lang('Description'), ['id' => 'descr
$createForm->addButtonSave(get_lang('Save'));
$createForm->addHidden('id', null);
$createForm->setDefaults($formDefaultValues);
if ($createForm->validate()) {
$created = $objSkill->add($createForm->getSubmitValues());

@ -7,7 +7,6 @@
<tr>
<th>{{ "Name" | get_lang }}</th>
<th>{{ "ShortCode" | get_lang }}</th>
<th>{{ "Description" | get_lang }}</th>
<th>{{ "Options" | get_lang }}</th>
</tr>
</thead>
@ -15,7 +14,6 @@
<tr>
<th>{{ "Name" | get_lang }}</th>
<th>{{ "ShortName" | get_lang }}</th>
<th>{{ "Description" | get_lang }}</th>
<th>{{ "Options" | get_lang }}</th>
</tr>
</tfoot>
@ -24,11 +22,13 @@
<tr>
<td>{{ skill.name }}</td>
<td>{{ skill.short_code }}</td>
<td>{{ skill.description }}</td>
<td>
<a href="{{ _p.web_main }}admin/skill_edit.php?id={{ skill.id }}" class="btn btn-default">
<i class="fa fa-edit"></i> {{ "Edit" | get_lang }}
</a>
<a href="{{ _p.web_main }}admin/skill_create.php?parent={{ skill.id }}" class="btn btn-default">
<i class="fa fa-plus"></i> {{ "CreateChildSkill" | get_lang }}
</a>
</td>
</tr>
{% endfor %}

Loading…
Cancel
Save