Merge pull request #676 from AngelFQC/7385
Add skill management on admin index page - refs BT#9583 #73851.10.x
commit
635d1d6df2
@ -0,0 +1,99 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Create skill form |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.admin |
||||
*/ |
||||
use ChamiloSession as Session; |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
if (api_get_setting('allow_skills_tool') != 'true') { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array('url' => 'skill_list.php', 'name' => get_lang('ManageSkills')); |
||||
|
||||
/* 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'); |
||||
|
||||
$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) { |
||||
Session::write( |
||||
'message', |
||||
Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success') |
||||
); |
||||
} else { |
||||
Session::write( |
||||
'message', |
||||
Display::return_message(get_lang('CannotCreateSkill'), 'error') |
||||
); |
||||
} |
||||
|
||||
Header::location(api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php'); |
||||
} |
||||
|
||||
/* view */ |
||||
$tpl = new Template(get_lang('CreateSkill')); |
||||
$tpl->assign('content', $createForm->returnForm()); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,103 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Skill edit form |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.admin |
||||
*/ |
||||
use ChamiloSession as Session; |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
if (api_get_setting('allow_skills_tool') != 'true') { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
||||
$interbreadcrumb[] = array('url' => 'skill_list.php', 'name' => get_lang('ManageSkills')); |
||||
|
||||
/* Process data */ |
||||
$skillId = isset($_GET['id']) ? intval($_GET['id']) : 0; |
||||
|
||||
$objSkill = new Skill(); |
||||
$objGradebook = new Gradebook(); |
||||
|
||||
$skillInfo = $objSkill->get_skill_info($skillId); |
||||
|
||||
$allSkills = $objSkill->get_all(); |
||||
$allGradebooks = $objGradebook->find('all'); |
||||
|
||||
$skillDefaultInfo = [ |
||||
'id' => $skillInfo['id'], |
||||
'name' => $skillInfo['name'], |
||||
'short_code' => $skillInfo['short_code'], |
||||
'description' => $skillInfo['description'], |
||||
'parent_id' => $skillInfo['extra']['parent_id'], |
||||
'gradebook_id' => [] |
||||
]; |
||||
|
||||
foreach ($skillInfo['gradebooks'] as $gradebook) { |
||||
$skillDefaultInfo['gradebook_id'][] = $gradebook['id']; |
||||
} |
||||
|
||||
$skillList = [0 => get_lang('None')]; |
||||
$gradebookList = []; |
||||
|
||||
foreach ($allSkills as $skill) { |
||||
if ($skill['id'] == $skillInfo['id']) { |
||||
continue; |
||||
} |
||||
|
||||
$skillList[$skill['id']] = $skill['name']; |
||||
} |
||||
|
||||
foreach ($allGradebooks as $gradebook) { |
||||
$gradebookList[$gradebook['id']] = $gradebook['name']; |
||||
} |
||||
|
||||
/* Form */ |
||||
$editForm = new FormValidator('skill_edit'); |
||||
$editForm->addHeader(get_lang('SkillEdit')); |
||||
$editForm->addText('name', get_lang('Name'), true, ['id' => 'name']); |
||||
$editForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']); |
||||
$editForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']); |
||||
$editForm->addSelect( |
||||
'gradebook_id', |
||||
[get_lang('Gradebook'), get_lang('WithCertificate')], |
||||
$gradebookList, |
||||
['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10] |
||||
); |
||||
$editForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]); |
||||
$editForm->addButtonSave(get_lang('Save')); |
||||
$editForm->addHidden('id', null); |
||||
|
||||
$editForm->setDefaults($skillDefaultInfo); |
||||
|
||||
if ($editForm->validate()) { |
||||
$updated = $objSkill->edit($editForm->getSubmitValues()); |
||||
|
||||
if ($updated) { |
||||
Session::write( |
||||
'message', |
||||
Display::return_message(get_lang('TheSkillHasBeenUpdated'), 'success') |
||||
); |
||||
} else { |
||||
Session::write( |
||||
'message', |
||||
Display::return_message(get_lang('CannotUpdateSkill'), 'error') |
||||
); |
||||
} |
||||
|
||||
Header::location(api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php'); |
||||
} |
||||
|
||||
/* view */ |
||||
$tpl = new Template(get_lang('SkillEdit')); |
||||
$tpl->assign('content', $editForm->returnForm()); |
||||
$tpl->display_one_col_template(); |
@ -0,0 +1,55 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Skill list for management |
||||
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> |
||||
* @package chamilo.admin |
||||
*/ |
||||
use ChamiloSession as Session; |
||||
|
||||
$cidReset = true; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
if (api_get_setting('allow_skills_tool') != 'true') { |
||||
api_not_allowed(); |
||||
} |
||||
|
||||
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); |
||||
|
||||
$message = Session::has('message') ? Session::read('message') : null; |
||||
|
||||
$toolbar = Display::toolbarButton( |
||||
get_lang('CreateSkill'), |
||||
api_get_path(WEB_CODE_PATH) . 'admin/skill_create.php', |
||||
'plus', |
||||
'success', |
||||
['title' => get_lang('CreateSkill')] |
||||
); |
||||
$toolbar .= Display::toolbarButton( |
||||
get_lang('SkillsWheel'), |
||||
api_get_path(WEB_CODE_PATH) . 'admin/skills_wheel.php', |
||||
'bullseye', |
||||
'primary', |
||||
['title' => get_lang('CreateSkill')] |
||||
); |
||||
|
||||
/* View */ |
||||
$skill = new Skill(); |
||||
$skillList = $skill->get_all(); |
||||
|
||||
$tpl = new Template(get_lang('ManageSkills')); |
||||
$tpl->assign('message', $message); |
||||
$tpl->assign('skills', $skillList); |
||||
|
||||
$content = $tpl->fetch('default/skill/list.tpl'); |
||||
|
||||
$tpl->assign('actions', $toolbar); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
|
||||
Session::erase('message'); |
@ -1,27 +1,23 @@ |
||||
{% for hot_course in hot_courses %} |
||||
{% if hot_course.extra_info.title %} |
||||
<div class="span5"> |
||||
<div class="well_border"> |
||||
<div class="row"> |
||||
<div class="span2"> |
||||
<div class="thumbnail"> |
||||
<img src="{{ hot_course.extra_info.course_image }}" /> |
||||
</div> |
||||
</div> |
||||
<div class="span2"> |
||||
<div class="categories-course-description"> |
||||
<h3>{{ hot_course.extra_info.title}}</h3> |
||||
<h5>{{ hot_course.extra_info.teachers }}</h5> |
||||
{# hot_course.extra_info.rating_html #} |
||||
</div> |
||||
<p> |
||||
{{ hot_course.extra_info.description_button }} |
||||
{{ hot_course.extra_info.go_to_course_button }} |
||||
{{ hot_course.extra_info.register_button }} |
||||
</p> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-sm-3"> |
||||
<div class="thumbnail"> |
||||
<img src="{{ hot_course.extra_info.course_image }}" /> |
||||
</div> |
||||
</div> |
||||
<div class="col-sm-9"> |
||||
<div class="categories-course-description"> |
||||
<h3>{{ hot_course.extra_info.title}}</h3> |
||||
<h5>{{ hot_course.extra_info.teachers }}</h5> |
||||
{# hot_course.extra_info.rating_html #} |
||||
</div> |
||||
<p> |
||||
{{ hot_course.extra_info.description_button }} |
||||
{{ hot_course.extra_info.go_to_course_button }} |
||||
{{ hot_course.extra_info.register_button }} |
||||
</p> |
||||
</div> |
||||
</div> |
||||
{% endif %} |
||||
{% endfor %} |
||||
{% endfor %} |
||||
|
@ -0,0 +1,36 @@ |
||||
<header class="page-header"> |
||||
<h1>{{ "ManageSkills" | get_lang }}</h1> |
||||
</header> |
||||
|
||||
<table class="table table-hover table-striped"> |
||||
<thead> |
||||
<tr> |
||||
<th>{{ "Name" | get_lang }}</th> |
||||
<th>{{ "ShortCode" | get_lang }}</th> |
||||
<th>{{ "Options" | get_lang }}</th> |
||||
</tr> |
||||
</thead> |
||||
<tfoot> |
||||
<tr> |
||||
<th>{{ "Name" | get_lang }}</th> |
||||
<th>{{ "ShortName" | get_lang }}</th> |
||||
<th>{{ "Options" | get_lang }}</th> |
||||
</tr> |
||||
</tfoot> |
||||
<tbody> |
||||
{% for skill in skills %} |
||||
<tr> |
||||
<td>{{ skill.name }}</td> |
||||
<td>{{ skill.short_code }}</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 %} |
||||
</tbody> |
||||
</table> |
@ -0,0 +1,15 @@ |
||||
<p>{{ "ToGetToLearnXYouWillNeedToTakeOneOfTheFollowingCourses" | get_lang | format( "<em>" ~ skill.name ~ "</em>") }}</p> |
||||
|
||||
<ul> |
||||
{% for course in courses %} |
||||
<li> |
||||
<a href="#" class="course_description_popup" rel="{{ course.code }}">{{ "SkillXWithCourseX" | get_lang | format(skill.name, course.title) }}</a> |
||||
</li> |
||||
{% endfor %} |
||||
|
||||
{% for session in sessions %} |
||||
<li> |
||||
{{ "SkillXWithCourseX" | get_lang | format(skill.name, session.name) }} |
||||
</li> |
||||
{% endfor %} |
||||
</ul> |
Loading…
Reference in new issue