Merge pull request #676 from AngelFQC/7385

Add skill management on admin index page - refs BT#9583 #7385
1.10.x
Yannick Warnier 10 years ago
commit 635d1d6df2
  1. 1
      main/admin/index.php
  2. 99
      main/admin/skill_create.php
  3. 103
      main/admin/skill_edit.php
  4. 55
      main/admin/skill_list.php
  5. 32
      main/admin/skills_wheel.php
  6. 36
      main/inc/ajax/skill.ajax.php
  7. 6
      main/inc/lib/course.lib.php
  8. 20
      main/inc/lib/display.lib.php
  9. 26
      main/inc/lib/skill.lib.php
  10. 29
      main/social/skills_wheel.php
  11. 38
      main/template/default/layout/hot_course_item_popup.tpl
  12. 36
      main/template/default/skill/list.tpl
  13. 15
      main/template/default/skill/skill_info.tpl
  14. 192
      main/template/default/skill/skill_wheel.js.tpl
  15. 254
      main/template/default/skill/skill_wheel.tpl
  16. 193
      main/template/default/skill/skill_wheel_student.tpl

@ -327,6 +327,7 @@ if (api_is_platform_admin()) {
//$items[] = array('url'=>'skills.php', 'label' => get_lang('SkillsTree'));
$items[] = array('url'=>'skills_wheel.php', 'label' => get_lang('SkillsWheel'));
$items[] = array('url'=>'skills_import.php', 'label' => get_lang('SkillsImport'));
$items[] = array('url'=>'skill_list.php', 'label' => get_lang('ManageSkills'));
//$items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
$items[] = array('url'=>api_get_path(WEB_CODE_PATH).'social/skills_ranking.php', 'label' => get_lang('SkillsRanking'));
$items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));

@ -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');

@ -45,21 +45,27 @@ $tpl->assign('url', $url);
$tpl->assign('isAdministration', true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addHidden('id', null);
$dialogForm->addText('name', get_lang('Name'), true, ['id' => 'name']);
$dialogForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']);
$dialogForm->addSelect('parent_id', get_lang('Parent'), [], ['id' => 'parent_id']);
$dialogForm->addHtml('<ul id="skill_edit_holder" class="holder holder_simple"></ul>');
$dialogForm->addHtml('<div id="gradebook_row">');
$dialogForm->addSelect(
'gradebook_id',
$dialogForm->addLabel(
get_lang('Name'),
Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
get_lang('ShortCode'),
Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
get_lang('Parent'),
Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
[get_lang('Gradebook'), get_lang('WithCertificate')],
[],
['id' => 'gradebook_id']
Display::tag('ul', null, ['id' => 'gradebook', 'class' => 'form-control-static list-unstyled'])
);
$dialogForm->addHtml('<ul id="gradebook_holder" class="holder holder_simple"></ul>');
$dialogForm->addHtml('</div>');
$dialogForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
$dialogForm->addLabel(
get_lang('Description'),
Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static'])
);
$tpl->assign('dialogForm', $dialogForm->returnForm());
$saveProfileForm = new FormValidator('form', 'post', null, null, ['id' => 'dialog-form-profile']);

@ -74,7 +74,11 @@ switch ($action) {
break;
case 'get_course_info_popup':
$course_info = api_get_course_info($_REQUEST['code']);
$courses = CourseManager::process_hot_course_item(array($course_info['real_id']));
$courses = CourseManager::process_hot_course_item(
[
['c_id' => $course_info['real_id']]
]
);
Display::display_no_header();
Display::$global_template->assign('hot_courses', $courses);
echo Display::$global_template->fetch('default/layout/hot_course_item_popup.tpl');
@ -115,27 +119,19 @@ switch ($action) {
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$skill_info = $skill->get_skill_info($id);
$courses = $skill->get_courses_by_skill($id);
$sessions = $skill->getSessionsBySkill($id);
$html = '';
if (!empty($courses)) {
$html = sprintf(
get_lang('ToGetToLearnXYouWillNeedToTakeOneOfTheFollowingCourses'),
'<i>'.$skill_info['name'].'</i>'
).'<br />';
foreach ($courses as $course) {
$url = '#';
$attributes = array('class' => 'course_description_popup', 'rel' => $course['code']);
$html .=
Display::url(
sprintf(
get_lang('SkillXWithCourseX'),
$skill_info['name'],
$course['title']
),
$url,
$attributes
).'<br />';
}
if (!empty($courses) || !empty($sessions)) {
Display::display_no_header();
Display::$global_template->assign('skill', $skill_info);
Display::$global_template->assign('courses', $courses);
Display::$global_template->assign('sessions', $sessions);
$html = Display::$global_template->fetch('default/skill/skill_info.tpl');
}
echo $html;
break;
case 'get_skills_tree_json':

@ -4756,6 +4756,8 @@ class CourseManager
*/
public static function process_hot_course_item($courses, $my_course_code_list = array())
{
$hotCourses = [];
$ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote';
$stok = Security::get_existing_token();
@ -4809,8 +4811,10 @@ class CourseManager
$point_info = self::get_course_ranking($course_info['real_id'], 0);
$my_course['extra_info']['rating_html'] = Display::return_rating_system('star_' . $course_info['real_id'],
$ajax_url . '&amp;course_id=' . $course_info['real_id'], $point_info);
$hotCourses[] = $my_course;
}
return $courses;
return $hotCourses;
}
/**

@ -2120,4 +2120,24 @@ class Display
</div>';
}
/**
* Get the button HTML with an Awesome Font icon
* @param string $text The button content
* @param string $url The url to button
* @param string $icon The Awesome Font class for icon
* @param string $type Ooptional. The button Bootstrap class. Default 'default' class
* @param array $attributes The additional attributes
* @return string The button HTML
*/
public static function toolbarButton($text, $url, $icon = 'check', $type = 'default', array $attributes = [])
{
$buttonClass = "btn btn-$type";
$icon = self::tag('i', null, ['class' => "fa fa-$icon"]);
$attributes['class'] = isset($attributes['class']) ? "$buttonClass {$attributes['class']}" : $buttonClass;
return self::url("$icon $text", $url, $attributes);
}
}

@ -531,6 +531,7 @@ class Skill extends Model
$this->table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$this->table_skill_rel_skill = Database::get_main_table(TABLE_MAIN_SKILL_REL_SKILL);
$this->table_gradebook = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$this->sessionTable = Database::get_main_table(TABLE_MAIN_SESSION);
}
/**
@ -1201,7 +1202,8 @@ class Skill extends Model
ON g.id = sg.gradebook_id
INNER JOIN {$this->table_course} c
ON c.code = g.course_code
WHERE sg.skill_id = $skill_id";
WHERE sg.skill_id = $skill_id
AND (g.session_id IS NULL OR g.session_id = 0)";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
@ -1371,4 +1373,26 @@ class Skill extends Model
return $list;
}
/**
* Get the session list where the user can achieve a skill
* @param int $skillId The skill id
* @return array
*/
public function getSessionsBySkill($skillId)
{
$skillId = intval($skillId);
$sql = "SELECT s.id, s.name
FROM {$this->table_gradebook} g
INNER JOIN {$this->table_skill_rel_gradebook} sg ON g.id = sg.gradebook_id
INNER JOIN {$this->sessionTable} s ON g.session_id = s.id
WHERE sg.skill_id = $skillId
AND g.session_id > 0";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
}

@ -55,15 +55,26 @@ $tpl->assign('countSkill', $countSkill);
$tpl->assign('mySkills', $mySkills);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
$dialogForm->addHidden('id', null);
$dialogForm->addText('name', get_lang('Name'), false, ['id' => 'name']);
$dialogForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']);
$dialogForm->addLabel(get_lang('ShortCode'), '<ul id="skill_edit_holder" class="holder holder_simple"></ul>');
$dialogForm->addHtml('<div id="gradebook_row">');
$dialogForm->addLabel([get_lang('Gradebook'), get_lang('WithCertificate')], '<ul id="gradebook_holder" class="holder holder_simple"></ul>');
$dialogForm->addHtml('<ul id="gradebook_holder" class="holder holder_simple"></ul>');
$dialogForm->addHtml('</div>');
$dialogForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]);
$dialogForm->addLabel(
get_lang('Name'),
Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
get_lang('ShortCode'),
Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
get_lang('Parent'),
Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static'])
);
$dialogForm->addLabel(
[get_lang('Gradebook'), get_lang('WithCertificate')],
Display::tag('ul', null, ['id' => 'gradebook', 'class' => 'form-control-static list-unstyled'])
);
$dialogForm->addLabel(
get_lang('Description'),
Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static'])
);
$tpl->assign('dialogForm', $dialogForm->returnForm());

@ -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>

@ -2,6 +2,62 @@
{% include template ~ "/layout/topbar.tpl" %}
<script>
var SkillWheel = {
currentSkill: null,
getSkillInfo: function(skillId) {
return $.getJSON(
'{{ url }}',
{
a: 'get_skill_info',
id: parseInt(skillId)
}
);
},
showFormSkill: function(skillId) {
skillId = parseInt(skillId);
var formSkill = $('form[name="form"]');
var getSkillInfo = SkillWheel.getSkillInfo(skillId);
$.when(getSkillInfo).done(function(skillInfo) {
SkillWheel.currentSkill = skillInfo;
var getSkillParentInfo = SkillWheel.getSkillInfo(skillInfo.extra.parent_id);
$.when(getSkillParentInfo).done(function(skillParentInfo) {
formSkill.find('p#parent').text(skillParentInfo.name);
});
formSkill.find('p#name').text(skillInfo.name);
if (skillInfo.short_code.length > 0) {
formSkill.find('p#short_code').text(skillInfo.short_code).parent().parent().show();
} else {
formSkill.find('p#short_code').parent().parent().hide();
}
if (skillInfo.description.length > 0) {
formSkill.find('p#description').text(skillInfo.description).parent().parent().show();
} else {
formSkill.find('p#description').parent().parent().hide();
}
if (skillInfo.gradebooks.length > 0) {
formSkill.find('ul#gradebook').empty().parent().parent().show();
$.each(skillInfo.gradebooks, function(index, gradebook) {
$('<li>').text(gradebook.name).appendTo(formSkill.find('ul#gradebook'));
});
} else {
formSkill.find('ul#gradebook').parent().parent().hide();
}
$('#frm-skill').modal('show');
});
}
};
/* Skill wheel settings */
var debug = true;
var url = '{{ url }}';
@ -316,134 +372,6 @@ function click_partition(d, path, text, icon, arc, x, y, r, p, vis) {
});*/
}
/*
Open a popup in order to modify the skill
*/
function open_popup(skill_id, parent_id) {
// Cleaning selects
$("#gradebook_id").find('option').remove();
$("#parent_id").find('option').remove();
//Cleaning lists
$("#gradebook_holder").find('li').remove();
$("#skill_edit_holder").find('li').remove();
var skill = false;
if (skill_id) {
skill = get_skill_info(skill_id);
}
var parent = false;
if (parent_id) {
parent = get_skill_info(parent_id);
}
if (skill) {
var parent_info = get_skill_info(skill.extra.parent_id);
if ("{{ isAdministration }}") {
$('input[name="id"]').val(skill.id);
$("#name").val(skill.name);
$("#short_code").val(skill.short_code);
$("#description").val(skill.description);
} else {
$("#name").prop('readonly', true).val(skill.name);
$("#short_code").prop('readonly', true).val(skill.short_code);
$("#description").prop('readonly', true).val(skill.description);
}
// Filling parent_id
$("#parent_id").append('<option class="selected" value="'+skill.extra.parent_id+'" selected="selected" >');
$("#skill_edit_holder").append('<li class="bit-box">'+parent_info.name+'</li>');
//Filling the gradebook_id
jQuery.each(skill.gradebooks, function(index, data) {
$("#gradebook_id").append('<option class="selected" value="'+data.id+'" selected="selected" >');
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
});
if ("{{ isAdministration }}") {
$("#dialog-form").dialog({
buttons: [
{
text: "{{ "Save"|get_lang }}",
class: 'btn btn-primary',
click: function() {
var params = $("#add_item").find(':input').serialize();
add_skill(params);
}
},
{
text: "{{ "CreateChildSkill"|get_lang }}",
class: 'btn btn-primary',
click: function() {
open_popup(0, skill.id);
}
},
{
text: "{{ "AddSkillToProfileSearch"|get_lang }}",
class: 'btn btn-primary',
click: function () {
add_skill_in_profile_list(skill.id, skill.name);
}
}
],
});
}
$("#dialog-form").dialog({
close: function() {
$("#name").attr('value','');
$("#description").attr('value', '');
if ("{{ isAdministration }}") {
//Redirect to the main root
load_nodes(0, main_depth);
}
}
});
$("#dialog-form").dialog("open");
}
if (parent) {
$('input[name="id"]').attr('value','');
$("#name").attr('value', '');
$("#short_code").attr('value', '');
$("#description").attr('value', '');
//Filling parent_id
$("#parent_id").append('<option class="selected" value="'+parent.id+'" selected="selected" >');
$("#skill_edit_holder").append('<li class="bit-box">'+parent.name+'</li>');
//Filling the gradebook_id
jQuery.each(parent.gradebooks, function(index, data) {
$("#gradebook_id").append('<option class="selected" value="'+data.id+'" selected="selected" >');
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
});
$("#dialog-form").dialog({
buttons: [
{
text: "{{ "Save"|get_lang }}",
class: 'btn btn-primary',
click: function() {
var params = $("#add_item").find(':input').serialize();
add_skill(params);
}
}
],
close: function() {
$("#name").attr('value', '');
$("#description").attr('value', '');
load_nodes(0, main_depth);
}
});
$("#dialog-form").dialog("open");
}
return false;
}
/* Handles mouse clicks */
function handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis) {
switch (d3.event.which) {
@ -455,7 +383,11 @@ function handle_mousedown_event(d, path, text, icon, arc, x, y, r, padding, vis)
//alert('Middle mouse button pressed');
break;
case 3:
open_popup(d.id);
if (typeof d.id === 'undefined') {
break;
}
SkillWheel.showFormSkill(d.id);
//alert('Right mouse button pressed');
break;
default:
@ -720,7 +652,7 @@ function load_nodes(load_skill_id, main_depth, extra_parent_id) {
return "rotate(" + rotate + ")translate(" + (y(d.y) + padding +80) + ")rotate(" + (angle > 90 ? -180 : 0) + ")";
})
.on("click", function(d){
open_popup(d);
SkillWheel.showFormSkill(d.id);
});
icon_click.append("tspan")

@ -2,17 +2,6 @@
<script>
function add_skill(params) {
$.ajax({
async: false,
url: url+'&a=add&'+params,
success:function(my_id) {
//Close dialog
$("#dialog-form").dialog("close");
}
});
}
/* Skill search input in the left menu */
function check_skills_sidebar() {
//Selecting only selected skills
@ -260,9 +249,25 @@ $(document).ready(function() {
return false;
});
$("#save_profile_form_button").submit(function() {
open_save_profile_popup();
return false;
$("form#save_profile_form_button").on('submit', function(e) {
e.preventDefault();
var profileId = parseInt($('input[name="profile_id"]').val());
var getProfileInfo = $.getJSON(
'{{ url }}',
{
a: 'get_profile',
profile_id: profileId
}
);
$.when(getProfileInfo).done(function(profileInfo) {
$("#name_profile").val(profileInfo.name);
$("#description_profile").val(profileInfo.description);
$('#frm-save-profile').modal('show');
});
});
/* Close button in profile matcher items */
@ -334,103 +339,8 @@ $(document).ready(function() {
newel: true
});
$("#parent_id").fcbkcomplete({
json_url: "{{ url }}&a=find_skills",
cache: false,
filter_case: false,
filter_hide: true,
complete_text:"{{ 'StartToType' | get_lang }}",
firstselected: true,
//onremove: "testme",
onselect:"check_skills_edit_form",
filter_selected: true,
newel: true
});
$("#gradebook_id").fcbkcomplete({
json_url: "{{ url }}&a=find_gradebooks",
cache: false,
filter_case: false,
filter_hide: true,
complete_text:"{{ 'StartToType' | get_lang }}",
firstselected: true,
//onremove: "testme",
onselect:"check_gradebook",
filter_selected: true,
newel: true
});
//Skill popup (edit, create child... )
$("#dialog-form").dialog({
autoOpen: false,
modal : true,
width : 900,
height : 630
});
//Save search profile dialog
$("#dialog-form-profile").dialog({
autoOpen: false,
modal : true,
width : 850,
height : 400
});
load_nodes(0, main_depth);
function open_save_profile_popup() {
var profileId = $('input[name="profile_id"]').val();
$.ajax({
url: '{{ url }}&a=get_profile&profile_id='+profileId,
success:function(data) {
if (data) {
var obj = jQuery.parseJSON (data);
$("#name_profile").attr('value', obj.name);
$("#description_profile").attr('value', obj.description);
}
}
});
$("#dialog-form-profile").dialog({
buttons: [
{
text: "{{ "Save"|get_lang }}",
class: 'btn btn-primary',
click: function() {
var name = $("#name_profile").val();
var description = $("#description_profile").val();
var skill_list = return_skill_list_from_profile_search();
skill_list = { 'skill_id' : skill_list };
skill_params = $.param(skill_list);
$.ajax({
url: '{{ url }}&a=save_profile&name='+name+'&description='+description+'&'+skill_params+'&profile='+profileId,
success:function(data) {
if (data == 1 ) {
update_my_saved_profiles();
alert("{{ "Saved"|get_lang }}");
} else {
alert("{{ "Error"|get_lang }}");
}
$("#dialog-form-profile").dialog("close");
$("#name_profile").attr('value', '');
$("#description_profile").attr('value', '');
$('input[name="profile_id"]').val(0);
}
});
}
}
],
close: function() {
$("#name_profile").val('');
$("#description_profile").val('');
$('input[name="profile_id"]').val(0);
}
});
$("#dialog-form-profile").dialog("open");
}
function update_my_saved_profiles() {
$.ajax({
url: '{{ url }}&a=get_saved_profiles',
@ -441,7 +351,6 @@ $(document).ready(function() {
}
/* change background color */
$(document).ready(function () {
$("#celestial").click(function () {
$("#page-back").css("background","#A9E2F3");
});
@ -457,7 +366,6 @@ $(document).ready(function() {
$("#light-yellow").click(function () {
$("#page-back").css("background","#F7F8E0");
});
});
/* Generated random colour */
/*
@ -473,6 +381,71 @@ $(document).ready(function() {
}
return d.colour || "#fff";
}*/
$('#form-button-edit').on('click', function(e) {
e.preventDefault();
if (SkillWheel.currentSkill === null) {
return;
}
window.location.href = "{{ _p.web_main }}admin/skill_edit.php?id=" + SkillWheel.currentSkill.id;
});
$('#form-button-create-child').on('click', function(e) {
e.preventDefault();
if (SkillWheel.currentSkill === null) {
return;
}
window.location.href = "{{ _p.web_main }}admin/skill_create.php?parent=" + SkillWheel.currentSkill.id;
});
$('#form-button-add-to-profile').on('click', function(e) {
e.preventDefault();
if (SkillWheel.currentSkill === null) {
return;
}
add_skill_in_profile_list(SkillWheel.currentSkill.id, SkillWheel.currentSkill.name);
});
$('#frm-save-profile').on('hidden.bs.modal', function () {
$("#name_profile").val('');
$("#description_profile").val('');
$('input[name="profile_id"]').val(0);
});
$('#form-button-save-profile').on('click', function(e) {
e.preventDefault();
var saveProfile = $.ajax(
'{{ url }}',
{
data: {
a: 'save_profile',
name: $("#name_profile").val(),
description: $("#description_profile").val(),
skill_id: return_skill_list_from_profile_search(),
profile: $('input[name="profile_id"]').val()
}
}
);
$.when(saveProfile).done(function(response) {
if (parseInt(response) === 1 ) {
update_my_saved_profiles();
alert("{{ "Saved" | get_lang }}");
} else {
alert("{{ "Error" | get_lang }}");
}
$('#frm-save-profile').modal('hide');
});
});
});
</script>
<div id="page-back" class="page-skill">
@ -582,14 +555,59 @@ $(document).ready(function() {
</div>
</div>
</div>
<div id="dialog-form" style="">
<p class="validateTips"></p>
{{ dialogForm }}
</div>
<div id="dialog-form-profile" style="display:none;">
{{ saveProfileForm }}
</div>
<div class="modal fade" id="frm-skill" tabindex="-1" role="dialog" aria-labelledby="form-skill-title" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ "Close" | get_lang }}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="form-skill-title">{{ "Skill" | get_lang }}</h4>
</div>
<div class="modal-body">
{{ dialogForm }}
</div>
<div class="modal-footer">
<button id="form-button-edit" class="btn btn-primary">
<i class="fa fa-edit"></i> {{ "Edit" | get_lang }}
</button>
<button id="form-button-create-child" class="btn btn-primary">
<i class="fa fa-plus"></i> {{ "CreateChildSkill" | get_lang }}
</button>
<button id="form-button-add-to-profile" class="btn btn-primary">
<i class="fa fa-check"></i> {{ "AddSkillToProfileSearch" | get_lang }}
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">
<i class="fa fa-close"></i> {{ "Close" | get_lang }}
</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="frm-save-profile" tabindex="-1" role="dialog" aria-labelledby="form-save-profile-title" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ "Close" | get_lang }}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="form-save-profile-title">{{ "SkillProfile" | get_lang }}</h4>
</div>
<div class="modal-body">
{{ saveProfileForm }}
</div>
<div class="modal-footer">
<button id="form-button-save-profile" class="btn btn-primary">
<i class="fa fa-save"></i> {{ "Save" | get_lang }}
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">
<i class="fa fa-close"></i> {{ "Close" | get_lang }}
</button>
</div>
</div>
</div>
</div>

@ -92,25 +92,26 @@ $(document).ready(function() {
});
/* When clicking in a course title */
$("#skill_info").on("click", "a.course_description_popup", function() {
course_code = $(this).attr('rel');
$.ajax({
url: url+'&a=get_course_info_popup&code='+course_code,
async: false,
success: function(data) {
$('#course_info').html(data);
$("#dialog-course-info").dialog({
close: function() {
$('#course_info').html('');
}
});
$("#dialog-course-info").dialog("open");
$("#skill_info").on("click", "a.course_description_popup[rel]", function(e) {
e.preventDefault();
var getCourseInfo = $.ajax(
url,
{
data: {
a: 'get_course_info_popup',
code: $(this).attr('rel')
}
}
);
$.when(getCourseInfo).done(function(response) {
$('#frm-course-info').find('.modal-body').html(response);
$('#frm-course-info').modal('show');
});
});
/* change background color */
$(document).ready(function () {
$("#celestial").click(function () {
$("#page-back").css("background","#A9E2F3");
});
@ -126,17 +127,9 @@ $(document).ready(function() {
$("#light-yellow").click(function () {
$("#page-back").css("background","#F7F8E0");
});
});
/* Wheel skill popup form */
/* Close button in gradebook select */
$("#gradebook_holder").on("click", "a.closebutton", function() {
gradebook_id = $(this).attr('rel');
skill_id = $('input[name="id"]').attr('value');
delete_gradebook_from_skill(skill_id, gradebook_id);
});
$("#skill_id").fcbkcomplete({
json_url: "{{ url }}&a=find_skills",
cache: false,
@ -150,124 +143,11 @@ $(document).ready(function() {
newel: true
});
$("#parent_id").fcbkcomplete({
json_url: "{{ url }}&a=find_skills",
cache: false,
filter_case: false,
filter_hide: true,
complete_text:"{{ 'StartToType' | get_lang }}",
firstselected: true,
//onremove: "testme",
onselect:"check_skills_edit_form",
filter_selected: true,
newel: true
});
$("#gradebook_id").fcbkcomplete({
json_url: "{{ url }}&a=find_gradebooks",
cache: false,
filter_case: false,
filter_hide: true,
complete_text:"{{ 'StartToType' | get_lang }}",
firstselected: true,
//onremove: "testme",
onselect:"check_gradebook",
filter_selected: true,
newel: true
});
//Open dialog
$("#dialog-form").dialog({
autoOpen: false,
modal : true,
width : 900,
height : 550
});
//Open dialog
$("#dialog-course-info").dialog({
autoOpen: false,
modal : true,
width : 550,
height : 250
});
load_nodes(0, main_depth);
function open_popup(skill_id, parent_id) {
//Cleaning selected
$("#gradebook_id").find('option').remove();
$("#parent_id").find('option').remove();
$("#gradebook_holder").find('li').remove();
$("#skill_edit_holder").find('li').remove();
var skill = false;
if (skill_id) {
skill = get_skill_info(skill_id);
}
var parent = false;
if (parent_id) {
parent = get_skill_info(parent_id);
}
if (skill) {
var parent_info = get_skill_info(skill.extra.parent_id);
$('input[name="id"]').attr('value', skill.id);
$("#name").attr('value', skill.name);
$("#short_code").attr('value', skill.short_code);
$("#description").attr('value', skill.description);
//Filling parent_id
$("#parent_id").append('<option class="selected" value="'+skill.extra.parent_id+'" selected="selected" >');
$("#skill_edit_holder").append('<li class="bit-box">'+parent_info.name+'</li>');
//Filling the gradebook_id
jQuery.each(skill.gradebooks, function(index, data) {
$("#gradebook_id").append('<option class="selected" value="'+data.id+'" selected="selected" >');
$("#gradebook_holder").append('<li id="gradebook_item_'+data.id+'" class="bit-box">'+data.name+' <a rel="'+data.id+'" class="closebutton" href="#"></a> </li>');
});
$("#dialog-form").dialog({
buttons: [
{
text: "{{ "Edit"|get_lang }}",
class: 'btn btn-primary',
click: function() {
var params = $("#add_item").find(':input').serialize();
add_skill(params);
}
},
{
text: "{{ "CreateChildSkill"|get_lang }}",
class: 'btn btn-primary',
click: function() {
open_popup(0, skill.id);
}
},
{
text: "{{ "AddSkillToProfileSearch"|get_lang }}",
class: 'btn btn-primary',
click: function() {
add_skill_in_profile_list(skill.id, skill.name);
}
}
],
close: function() {
$("#name").attr('value','');
$("#description").attr('value', '');
//Redirect to the main root
load_nodes(0, main_depth);
}
});
$("#dialog-form").dialog("open");
}
}
$('#frm-course-info').on('', function() {
$('#frm-course-info').find('.modal-body').html('');
});
});
</script>
@ -378,14 +258,41 @@ $(document).ready(function() {
</div>
</div>
</div>
<div id="dialog-course-info" style="display:none;">
<div id="course_info">
</div>
</div>
<div class="modal fade" id="frm-skill" tabindex="-1" role="dialog" aria-labelledby="form-skill-title" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ "Close" | get_lang }}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="form-skill-title">{{ "Skill" | get_lang }}</h4>
</div>
<div class="modal-body">
{{ dialogForm }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ "Close" | get_lang }}</button>
</div>
</div>
</div>
</div>
<div id="dialog-form" style="">
<p class="validateTips"></p>
{{ dialogForm }}
<div class="modal fade" id="frm-course-info" tabindex="-1" role="dialog" aria-labelledby="form-course-info-title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ "Close" | get_lang }}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="form-course-info-title">{{ "ChooseCourse" | get_lang }}</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ "Close" | get_lang }}</button>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save