From d445934fdda58a99ad5f30382ae3f4e55da76cac Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 16 Apr 2015 13:51:42 -0500 Subject: [PATCH] Add create child skill form - refs BT#9583 #7385 --- main/admin/skill_create.php | 19 +++++++++++++++++++ main/template/default/skill/list.tpl | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/main/admin/skill_create.php b/main/admin/skill_create.php index 88a2119f60..ae0a5905e2 100644 --- a/main/admin/skill_create.php +++ b/main/admin/skill_create.php @@ -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()); diff --git a/main/template/default/skill/list.tpl b/main/template/default/skill/list.tpl index ead8ab57ce..d92e5aeeef 100644 --- a/main/template/default/skill/list.tpl +++ b/main/template/default/skill/list.tpl @@ -7,7 +7,6 @@ {{ "Name" | get_lang }} {{ "ShortCode" | get_lang }} - {{ "Description" | get_lang }} {{ "Options" | get_lang }} @@ -15,7 +14,6 @@ {{ "Name" | get_lang }} {{ "ShortName" | get_lang }} - {{ "Description" | get_lang }} {{ "Options" | get_lang }} @@ -24,11 +22,13 @@ {{ skill.name }} {{ skill.short_code }} - {{ skill.description }} {{ "Edit" | get_lang }} + + {{ "CreateChildSkill" | get_lang }} + {% endfor %}