Fix Skills lib

- Format code
- Convert function names to camelCase
- Add Database::escape_string
- Fix return message using Display::addFlash (skills_gradebook.php)
pull/2487/head
jmontoyaa 7 years ago
parent 0ebac8306d
commit 2b788be2bc
  1. 2
      main/admin/skill_create.php
  2. 4
      main/admin/skill_edit.php
  3. 2
      main/admin/skill_list.php
  4. 2
      main/admin/skills.php
  5. 43
      main/admin/skills_gradebook.php
  6. 9
      main/admin/skills_profile.php
  7. 12
      main/exercise/exercise.class.php
  8. 4
      main/gradebook/lib/be/category.class.php
  9. 6
      main/inc/ajax/model.ajax.php
  10. 24
      main/inc/ajax/skill.ajax.php
  11. 20
      main/inc/lib/gradebook.lib.php
  12. 130
      main/inc/lib/skill.lib.php
  13. 2
      main/inc/lib/social.lib.php
  14. 2
      main/social/skills_tree.php
  15. 4
      main/social/skills_wheel.php
  16. 88
      main/template/default/gradebook/custom_certificate.tpl

@ -30,7 +30,7 @@ $objSkill = new Skill();
$objGradebook = new Gradebook();
if ($skillParentId > 0) {
$skillParentInfo = $objSkill->get_skill_info($skillParentId);
$skillParentInfo = $objSkill->getSkillInfo($skillParentId);
$formDefaultValues = [
'parent_id' => $skillParentInfo['id'],

@ -26,9 +26,7 @@ $skillId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$objSkill = new Skill();
$objGradebook = new Gradebook();
$skillInfo = $objSkill->get_skill_info($skillId);
$skillInfo = $objSkill->getSkillInfo($skillId);
$allSkills = $objSkill->get_all();
$allGradebooks = $objGradebook->find('all');

@ -77,7 +77,7 @@ switch ($action) {
$entityManager->persist($skill);
$skillObj = new Skill();
$childrens = $skillObj->get_children($skill->getId());
$childrens = $skillObj->getChildren($skill->getId());
foreach ($childrens as $children) {
$skill = $entityManager->find(

@ -20,7 +20,7 @@ $htmlHeadXtra[] = api_get_js('skills.js');
$skill = new Skill();
$type = 'edit'; //edit
$tree = $skill->get_skills_tree(null, null, true);
$tree = $skill->getSkillsTree(null, null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);
$html = $skill_visualizer->return_html();

@ -26,6 +26,27 @@ if ($action == 'add_skill') {
$tool_name = get_lang('Add');
}
$gradebook = new Gradebook();
switch ($action) {
case 'display':
$content = $gradebook->returnGrid();
break;
case 'add_skill':
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$gradebook_info = $gradebook->get($id);
$url = api_get_self().'?action='.$action.'&id='.$id;
$form = $gradebook->show_skill_form($id, $url, $gradebook_info['name']);
if ($form->validate()) {
$values = $form->exportValues();
$gradebook->updateSkillsToGradeBook($values['id'], $values['skill']);
Display::addFlash(Display::return_message(get_lang('ItemAdded'), 'confirm'));
header('Location: '.api_get_self());
exit;
}
$content = $form->returnForm();
break;
}
Display::display_header($tool_name);
//jqgrid will use this URL to do the selects
@ -103,25 +124,7 @@ $(function() {
});
</script>
<?php
$gradebook = new Gradebook();
switch ($action) {
case 'display':
$gradebook->display();
break;
case 'add_skill':
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$gradebook_info = $gradebook->get($id);
$url = api_get_self().'?action='.$action.'&id='.$id;
$form = $gradebook->show_skill_form($id, $url, $gradebook_info['name']);
if ($form->validate()) {
$values = $form->exportValues();
$res = $gradebook->update_skills_to_gradebook($values['id'], $values['skill']);
if ($res) {
echo Display::return_message(get_lang('ItemAdded'), 'confirm');
}
}
$form->display();
break;
}
echo $content;
Display::display_footer();

@ -56,8 +56,7 @@ if ($form->validate()) {
$user_list = array();
$count_skills = count($skills);
$users = $skill_rel_user->get_user_by_skills($skills);
$users = $skill_rel_user->getUserBySkills($skills);
if (!empty($users)) {
foreach ($users as $user) {
@ -108,7 +107,7 @@ if (!empty($skills)) {
}
}
$total_skills_to_search = $skill->get_skills_info($total_skills_to_search);
$total_skills_to_search = $skill->getSkillsInfo($total_skills_to_search);
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
@ -125,8 +124,8 @@ switch ($action) {
break;
case 'load_profile':
$skill_profile = new SkillRelProfile();
$skills = $skill_profile->get_skills_by_profile($id);
$total_skills_to_search = $skill->get_skills_info($skills);
$skills = $skill_profile->getSkillsByProfile($id);
$total_skills_to_search = $skill->getSkillsInfo($skills);
break;
}

@ -3542,7 +3542,9 @@ class Exercise
);
}
if ($debug) error_log('Start answer loop ');
if ($debug) {
error_log('Start answer loop ');
}
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
@ -3656,7 +3658,9 @@ class Exercise
}
$totalScore += $answerWeighting;
if ($debug) error_log("studentChoice: $studentChoice");
if ($debug) {
error_log("studentChoice: $studentChoice");
}
break;
case GLOBAL_MULTIPLE_ANSWER:
if ($from_database) {
@ -3681,7 +3685,9 @@ class Exercise
$real_answers[$answerId] = (bool) $studentChoice;
}
$totalScore += $answerWeighting;
if ($debug) error_log("studentChoice: $studentChoice");
if ($debug) {
error_log("studentChoice: $studentChoice");
}
break;
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
if ($from_database) {

@ -671,7 +671,7 @@ class Category implements GradebookItem
}
$gradebook = new Gradebook();
$gradebook->update_skills_to_gradebook(
$gradebook->updateSkillsToGradeBook(
$this->id,
$this->get_skills(false)
);
@ -749,7 +749,7 @@ class Category implements GradebookItem
}
$gradebook = new Gradebook();
$gradebook->update_skills_to_gradebook(
$gradebook->updateSkillsToGradeBook(
$this->id,
$this->get_skills(false),
true

@ -427,7 +427,7 @@ switch ($action) {
break;
case 'get_user_skill_ranking':
$skill = new Skill();
$count = $skill->get_user_list_skill_ranking_count();
$count = $skill->getUserListSkillRankingCount();
break;
case 'get_course_announcements':
$count = AnnouncementManager::getAnnouncements(null, null, true);
@ -942,7 +942,7 @@ switch ($action) {
'currently_learning',
'rank'
);
$result = $skill->get_user_list_skill_ranking(
$result = $skill->getUserListSkillRanking(
$start,
$limit,
$sidx,
@ -961,7 +961,7 @@ switch ($action) {
$count_skill_by_course = array();
foreach ($personal_course_list as $course_item) {
if (!isset($skills_in_course[$course_item['code']])) {
$count_skill_by_course[$course_item['code']] = $skill->get_count_skills_by_course($course_item['code']);
$count_skill_by_course[$course_item['code']] = $skill->getCountSkillsByCourse($course_item['code']);
$skills_in_course[$course_item['code']] = $count_skill_by_course[$course_item['code']];
} else {
$count_skill_by_course[$course_item['code']] = $skills_in_course[$course_item['code']];

@ -98,7 +98,7 @@ switch ($action) {
case 'get_skills_by_profile':
$skill_rel_profile = new SkillRelProfile();
$profile_id = isset($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : null;
$skills = $skill_rel_profile->get_skills_by_profile($profile_id);
$skills = $skill_rel_profile->getSkillsByProfile($profile_id);
echo json_encode($skills);
break;
case 'get_saved_profiles':
@ -117,13 +117,13 @@ switch ($action) {
break;
case 'get_skill_info':
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$skill_info = $skill->get_skill_info($id);
$skill_info = $skill->getSkillInfo($id);
echo json_encode($skill_info);
break;
case 'get_skill_course_info':
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$skill_info = $skill->get_skill_info($id);
$courses = $skill->get_courses_by_skill($id);
$skill_info = $skill->getSkillInfo($id);
$courses = $skill->getCoursesBySkill($id);
$sessions = $skill->getSessionsBySkill($id);
$html = '';
if (!empty($courses) || !empty($sessions)) {
@ -141,7 +141,7 @@ switch ($action) {
$userId = isset($_REQUEST['load_user']) && $_REQUEST['load_user'] == 1 ? api_get_user_id() : 0;
$skill_id = isset($_REQUEST['skill_id']) ? intval($_REQUEST['skill_id']) : 0;
$depth = isset($_REQUEST['main_depth']) ? intval($_REQUEST['main_depth']) : 2;
$all = $skill->get_skills_tree_json($userId, $skill_id, false, $depth);
$all = $skill->getSkillsTreeToJson($userId, $skill_id, false, $depth);
echo $all;
break;
case 'get_user_skill':
@ -172,7 +172,7 @@ switch ($action) {
case 'load_children':
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$load_user_data = isset($_REQUEST['load_user_data']) ? $_REQUEST['load_user_data'] : null;
$skills = $skill->get_children($id, $load_user_data);
$skills = $skill->getChildren($id, $load_user_data);
$return = array();
foreach ($skills as $skill) {
@ -197,7 +197,7 @@ switch ($action) {
break;
case 'load_direct_parents':
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$skills = $skill->get_direct_parents($id);
$skills = $skill->getDirectParents($id);
$return = array();
foreach ($skills as $skill) {
$return [$skill['data']['id']] = array(
@ -211,9 +211,8 @@ switch ($action) {
case 'profile_matches':
$skill_rel_user = new SkillRelUser();
$skills = (!empty($_REQUEST['skill_id']) ? $_REQUEST['skill_id'] : array());
$total_skills_to_search = $skills;
$users = $skill_rel_user->get_user_by_skills($skills);
$users = $skill_rel_user->getUserBySkills($skills);
$user_list = array();
$count_skills = count($skills);
$ordered_user_list = null;
@ -270,7 +269,7 @@ switch ($action) {
$skill_list = array();
if (!empty($total_skills_to_search)) {
$total_skills_to_search = $skill->get_skills_info($total_skills_to_search);
$total_skills_to_search = $skill->getSkillsInfo($total_skills_to_search);
foreach ($total_skills_to_search as $skill_info) {
$skill_list[$skill_info['id']] = $skill_info;
@ -285,7 +284,7 @@ switch ($action) {
case 'remove_skill':
if (api_is_platform_admin() || api_is_drh()) {
if (!empty($_REQUEST['skill_id']) && !empty($_REQUEST['gradebook_id'])) {
$skill_item = $skill_gradebook->get_skill_info(
$skill_item = $skill_gradebook->getSkillInfo(
$_REQUEST['skill_id'],
$_REQUEST['gradebook_id']
);
@ -314,11 +313,12 @@ switch ($action) {
$params['skills'] = $params['skill_id'];
$profileId = isset($_REQUEST['profile']) ? intval($_REQUEST['profile']) : null;
if ($profileId > 0) {
$skill_data = $skill_profile->updateProfileInfo(
$skill_profile->updateProfileInfo(
$profileId,
$params['name'],
$params['description']
);
$skill_data = 1;
} else {
$skill_data = $skill_profile->save($params);
}

@ -100,9 +100,10 @@ class Gradebook extends Model
/**
* @param int $gradebook_id
* @param array $skill_list
* @param bool $deleteSkillNotInList
* @return bool
*/
public function update_skills_to_gradebook(
public function updateSkillsToGradeBook(
$gradebook_id,
$skill_list,
$deleteSkillNotInList = true
@ -134,7 +135,7 @@ class Gradebook extends Model
$params = array();
$params['gradebook_id'] = $gradebook_id;
$params['skill_id'] = $skill_id;
if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) {
if (!$skill_gradebook->existsGradeBookSkill($gradebook_id, $skill_id)) {
$skill_gradebook->save($params);
}
}
@ -145,7 +146,7 @@ class Gradebook extends Model
if ($deleteSkillNotInList) {
if (!empty($skill_to_remove)) {
foreach ($skill_to_remove as $remove) {
$skill_item = $skill_gradebook->get_skill_info(
$skill_item = $skill_gradebook->getSkillInfo(
$remove,
$gradebook_id
);
@ -162,7 +163,7 @@ class Gradebook extends Model
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
* @return FormValidator
*/
public function show_skill_form($gradebook_id, $url, $header = null)
{
@ -228,6 +229,15 @@ class Gradebook extends Model
public function display()
{
// action links
echo Display::grid_html('gradebooks');
echo self::returnGrid();
}
/**
* Displays the title + grid
*/
public function returnGrid()
{
// action links
return Display::grid_html('gradebooks');
}
}

@ -24,7 +24,7 @@ class SkillProfile extends Model
/**
* @return array
*/
public function get_profiles()
public function getProfiles()
{
$sql = "SELECT * FROM $this->table p
INNER JOIN $this->table_rel_profile sp
@ -40,24 +40,29 @@ class SkillProfile extends Model
* @param int $profileId
* @param string $name
* @param string $description
* @return bool
*/
public function updateProfileInfo($profileId, $name, $description)
{
$profileId = intval($profileId);
$name = Database::escape_string($name);
$description = Database::escape_string($description);
$sql = "UPDATE $this->table SET
name = '$name',
description = '$description'
WHERE id = $profileId ";
$result = Database::query($sql);
Database::query($sql);
return $result;
return true;
}
/**
* Call the save method of the parent class and the SkillRelProfile object
* @param array $params
* @param bool $show_query Whether to show the query in parent save() method
*
*
* @return mixed Profile ID or false if incomplete params
*/
public function save($params, $show_query = false)
@ -120,7 +125,7 @@ class SkillRelProfile extends Model
* @param int $profileId
* @return array
*/
public function get_skills_by_profile($profileId)
public function getSkillsByProfile($profileId)
{
$profileId = intval($profileId);
$skills = $this->get_all(array('where' => array('profile_id = ? ' => $profileId)));
@ -172,7 +177,7 @@ class SkillRelSkill extends Model
* @param int $id
* @return array
*/
public function get_skill_info($id)
public function getSkillInfo($id)
{
if (empty($id)) {
return array();
@ -192,7 +197,7 @@ class SkillRelSkill extends Model
* @param bool $add_child_info
* @return array
*/
public function get_skill_parents($skill_id, $add_child_info = true)
public function getSkillParents($skill_id, $add_child_info = true)
{
$skill_id = intval($skill_id);
$sql = 'SELECT child.* FROM '.$this->table.' child
@ -206,7 +211,7 @@ class SkillRelSkill extends Model
$parents = array();
if (!empty($skill)) {
if ($skill['parent_id'] != null) {
$parents = self::get_skill_parents($skill['parent_id']);
$parents = self::getSkillParents($skill['parent_id']);
}
if ($add_child_info) {
$parents[] = $skill;
@ -219,7 +224,7 @@ class SkillRelSkill extends Model
* @param int $skill_id
* @return array
*/
public function get_direct_parents($skill_id)
public function getDirectParents($skill_id)
{
$skill_id = intval($skill_id);
$sql = 'SELECT parent_id as skill_id
@ -242,7 +247,7 @@ class SkillRelSkill extends Model
* @param bool $user_id
* @return array
*/
public function get_children(
public function getChildren(
$skill_id,
$load_user_data = false,
$user_id = false
@ -285,7 +290,7 @@ class SkillRelSkill extends Model
* @param array $params
* @return bool
*/
public function update_by_skill($params)
public function updateBySkill($params)
{
$result = Database::update(
$this->table,
@ -304,7 +309,7 @@ class SkillRelSkill extends Model
* @param int $parent_id
* @return bool
*/
public function relation_exists($skill_id, $parent_id)
public function relationExists($skill_id, $parent_id)
{
$result = $this->find(
'all',
@ -345,7 +350,7 @@ class SkillRelGradebook extends Model
* @param int $skill_id
* @return bool
*/
public function exists_gradebook_skill($gradebook_id, $skill_id)
public function existsGradeBookSkill($gradebook_id, $skill_id)
{
$result = $this->find(
'all',
@ -367,7 +372,7 @@ class SkillRelGradebook extends Model
/**
* Gets an element
*/
public function get_skill_info($skill_id, $gradebook_id)
public function getSkillInfo($skill_id, $gradebook_id)
{
if (empty($skill_id)) {
return array();
@ -442,9 +447,9 @@ class SkillRelGradebook extends Model
* @param array $params
* @return bool|void
*/
public function update_by_skill($params)
public function updateBySkill($params)
{
$skill_info = $this->exists_gradebook_skill(
$skill_info = $this->existsGradeBookSkill(
$params['gradebook_id'],
$params['skill_id']
);
@ -488,7 +493,7 @@ class SkillRelUser extends Model
* @param array $skill_list
* @return array
*/
public function get_user_by_skills($skill_list)
public function getUserBySkills($skill_list)
{
$users = array();
if (!empty($skill_list)) {
@ -627,13 +632,13 @@ class Skill extends Model
* @param int $id
* @return array
*/
public function get_skill_info($id)
public function getSkillInfo($id)
{
$skill_rel_skill = new SkillRelSkill();
$skill_info = $this->get($id);
if (!empty($skill_info)) {
$skill_info['extra'] = $skill_rel_skill->get_skill_info($id);
$skill_info['gradebooks'] = self::get_gradebooks_by_skill($id);
$skill_info['extra'] = $skill_rel_skill->getSkillInfo($id);
$skill_info['gradebooks'] = self::getGradebooksBySkill($id);
}
return $skill_info;
}
@ -642,7 +647,7 @@ class Skill extends Model
* @param array $skill_list
* @return array
*/
public function get_skills_info($skill_list)
public function getSkillsInfo($skill_list)
{
$skill_list = array_map('intval', $skill_list);
$skill_list = implode("', '", $skill_list);
@ -715,9 +720,9 @@ class Skill extends Model
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$skill_rel_skill = new SkillRelSkill();
$parents = $skill_rel_skill->get_skill_parents($row['id']);
$parents = $skill_rel_skill->getSkillParents($row['id']);
$row['level'] = count($parents) - 1;
$row['gradebooks'] = self::get_gradebooks_by_skill($row['id']);
$row['gradebooks'] = self::getGradebooksBySkill($row['id']);
$row['web_icon_path'] = $webPath.'badges/'.$row['icon'];
$skills[$row['id']] = $row;
}
@ -740,7 +745,7 @@ class Skill extends Model
* @param int $skill_id
* @return array|resource
*/
public function get_gradebooks_by_skill($skill_id)
public function getGradebooksBySkill($skill_id)
{
$skill_id = intval($skill_id);
$sql = "SELECT g.* FROM {$this->table_gradebook} g
@ -753,20 +758,20 @@ class Skill extends Model
}
/**
* Get one level childrens
* Get one level children
*
* @param int $skill_id
* @param bool $load_user_data
* @return array
*/
public function get_children($skill_id, $load_user_data = false)
public function getChildren($skill_id, $load_user_data = false)
{
$skill_rel_skill = new SkillRelSkill();
if ($load_user_data) {
$user_id = api_get_user_id();
$skills = $skill_rel_skill->get_children($skill_id, true, $user_id);
$skills = $skill_rel_skill->getChildren($skill_id, true, $user_id);
} else {
$skills = $skill_rel_skill->get_children($skill_id);
$skills = $skill_rel_skill->getChildren($skill_id);
}
return $skills;
}
@ -776,12 +781,12 @@ class Skill extends Model
* @param int $skillId
* @return array
*/
public function get_all_children($skillId)
public function getAllChildren($skillId)
{
$skill_rel_skill = new SkillRelSkill();
$children = $skill_rel_skill->get_children($skillId);
$children = $skill_rel_skill->getChildren($skillId);
foreach ($children as $child) {
$subChildren = $this->get_all_children($child['skill_id']);
$subChildren = $this->getAllChildren($child['skill_id']);
}
if (!empty($subChildren)) {
@ -797,7 +802,7 @@ class Skill extends Model
public function get_parents($skill_id)
{
$skill_rel_skill = new SkillRelSkill();
$skills = $skill_rel_skill->get_skill_parents($skill_id, true);
$skills = $skill_rel_skill->getSkillParents($skill_id, true);
foreach ($skills as &$skill) {
$skill['data'] = self::get($skill['skill_id']);
}
@ -807,13 +812,13 @@ class Skill extends Model
/**
* All direct parents
*/
public function get_direct_parents($skill_id)
public function getDirectParents($skill_id)
{
$skill_rel_skill = new SkillRelSkill();
$skills = $skill_rel_skill->get_direct_parents($skill_id, true);
$skills = $skill_rel_skill->getDirectParents($skill_id, true);
foreach ($skills as &$skill) {
$skill['data'] = self::get($skill['skill_id']);
$skill_info2 = $skill_rel_skill->get_skill_info($skill['skill_id']);
$skill_info2 = $skill_rel_skill->getSkillInfo($skill['skill_id']);
$skill['data']['parent_id'] = $skill_info2['parent_id'];
}
return $skills;
@ -842,7 +847,7 @@ class Skill extends Model
if ($skill_id) {
//Saving skill_rel_skill (parent_id, relation_type)
foreach ($params['parent_id'] as $parent_id) {
$relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);
$relation_exists = $skill_rel_skill->relationExists($skill_id, $parent_id);
if (!$relation_exists) {
$attributes = array(
'skill_id' => $skill_id,
@ -950,7 +955,7 @@ class Skill extends Model
}
foreach ($params['parent_id'] as $parent_id) {
$relation_exists = $skill_rel_skill->relation_exists($skill_id, $parent_id);
$relation_exists = $skill_rel_skill->relationExists($skill_id, $parent_id);
if (!$relation_exists) {
$attributes = array(
'skill_id' => $skill_id,
@ -958,7 +963,7 @@ class Skill extends Model
'relation_type' => $params['relation_type'],
//'level' => $params['level'],
);
$skill_rel_skill->update_by_skill($attributes);
$skill_rel_skill->updateBySkill($attributes);
}
}
@ -1032,7 +1037,7 @@ class Skill extends Model
* @param bool $add_root
* @return array|null
*/
public function get_skills_tree(
public function getSkillsTree(
$user_id = null,
$skill_id = null,
$return_flat_array = false,
@ -1059,7 +1064,7 @@ class Skill extends Model
'name' => get_lang('Root'),
'parent_id' => '0'
);
$skill_info = $this->get_skill_info($skill_id);
$skill_info = $this->getSkillInfo($skill_id);
// 2nd node
$skills[$skill_id] = $skill_info;
@ -1100,11 +1105,11 @@ class Skill extends Model
// In order to paint all members of a family with the same color
if (empty($skill_id)) {
if ($skill['parent_id'] == 1) {
$family[$skill['id']] = $this->get_all_children($skill['id']);
$family[$skill['id']] = $this->getAllChildren($skill['id']);
}
} else {
if ($skill['parent_id'] == $skill_id) {
$family[$skill['id']] = $this->get_all_children($skill['id']);
$family[$skill['id']] = $this->getAllChildren($skill['id']);
}
/*if ($skill_id == $skill['id']) {
$skill['parent_id'] = 1;
@ -1186,15 +1191,15 @@ class Skill extends Model
* @param int skill id
* @param bool return a flat array or not
* @param int depth of the skills
* @return json
* @return string json
*/
public function get_skills_tree_json(
public function getSkillsTreeToJson(
$user_id = null,
$skill_id = null,
$return_flat_array = false,
$main_depth = 2
) {
$tree = $this->get_skills_tree(
$tree = $this->getSkillsTree(
$user_id,
$skill_id,
$return_flat_array,
@ -1205,7 +1210,7 @@ class Skill extends Model
foreach ($tree['children'] as $element) {
$children = [];
if (isset($element['children'])) {
$children = $this->get_skill_json($element['children'], 1, $main_depth);
$children = $this->getSkillToJson($element['children'], 1, $main_depth);
}
$simple_tree[] = array(
'name' => $element['name'],
@ -1224,7 +1229,7 @@ class Skill extends Model
* @param int $max_depth
* @return array|null
*/
public function get_skill_json($subtree, $depth = 1, $max_depth = 2)
public function getSkillToJson($subtree, $depth = 1, $max_depth = 2)
{
$simple_sub_tree = array();
if (is_array($subtree)) {
@ -1236,7 +1241,7 @@ class Skill extends Model
$tmp['isSearched'] = self::isSearched($elem['id']);
if (isset($elem['children']) && is_array($elem['children'])) {
$tmp['children'] = $this->get_skill_json(
$tmp['children'] = $this->getSkillToJson(
$elem['children'],
$depth + 1,
$max_depth
@ -1269,7 +1274,7 @@ class Skill extends Model
* @param int $user_id
* @return bool
*/
public function get_user_skill_ranking($user_id)
public function getUserSkillRanking($user_id)
{
$user_id = intval($user_id);
$sql = "SELECT count(skill_id) count FROM {$this->table} s
@ -1292,7 +1297,7 @@ class Skill extends Model
* @param $where_condition
* @return array
*/
public function get_user_list_skill_ranking(
public function getUserListSkillRanking(
$start,
$limit,
$sidx,
@ -1321,7 +1326,7 @@ class Skill extends Model
/**
* @return int
*/
public function get_user_list_skill_ranking_count()
public function getUserListSkillRankingCount()
{
$sql = "SELECT count(*) FROM (
SELECT count(distinct 1)
@ -1346,7 +1351,7 @@ class Skill extends Model
* @param string $courseCode
* @return int
*/
public function get_count_skills_by_course($courseCode)
public function getCountSkillsByCourse($courseCode)
{
$courseCode = Database::escape_string($courseCode);
$sql = "SELECT count(skill_id) as count
@ -1367,7 +1372,7 @@ class Skill extends Model
* @param int $skill_id
* @return array
*/
public function get_courses_by_skill($skill_id)
public function getCoursesBySkill($skill_id)
{
$skill_id = intval($skill_id);
$sql = "SELECT c.title, c.code
@ -1520,7 +1525,6 @@ class Skill extends Model
}
$list = array();
$sql = "SELECT
course.id c_id,
course.title c_name,
@ -1711,4 +1715,22 @@ class Skill extends Model
return false;
}
/**
* Get skills
* @param int $userId
* @return array
*/
public function getStudentSkills($userId)
{
$sql = "SELECT s.name, sru.acquired_skill_at
FROM {$this->table} s
INNER JOIN {$this->table_skill_rel_user} sru
ON s.id = sru.skill_id
WHERE sru.user_id = $userId";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
}

@ -2137,7 +2137,7 @@ class SocialManager extends UserManager
}
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId);
$ranking = $skill->getUserSkillRanking($userId);
$skills = $skill->getUserSkills($userId, true);
$template = new Template(null, false, false, false, false, false);

@ -21,7 +21,7 @@ $htmlHeadXtra[] = api_get_js('skills.js');
$skill = new Skill();
$type = 'read'; //edit
$tree = $skill->get_skills_tree(api_get_user_id(), null, true);
$tree = $skill->getSkillsTree(api_get_user_id(), null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);
$url = api_get_path(WEB_AJAX_PATH).'skill.ajax.php?1=1';
$tpl = new Template(null, false, false);

@ -26,7 +26,7 @@ $userId = api_get_user_id();
$userInfo = api_get_user_info();
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking($userId);
$ranking = $skill->getUserSkillRanking($userId);
$skills = $skill->getUserSkills($userId, true);
$dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']);
@ -59,7 +59,7 @@ $dialogForm->addLabel(
);
$type = 'read';
$tree = $skill->get_skills_tree($userId, null, true);
$tree = $skill->getSkillsTree($userId, null, true);
$skill_visualizer = new SkillVisualizer($tree, $type);
$tpl->assign('skill_visualizer', $skill_visualizer);
$tpl->assign('dialogForm', $dialogForm->returnForm());

@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ 'Certificate' | get_lang }}</title>
</head>
<body>
<table border="0" bgcolor="#92c647" cellpadding="0" cellspacing="0" align="center" width="80%">
<tr>
<td bgcolor="#92c647"><img src="{{ _p.web_css_theme }}images/header_top.png" style="display: block;"></td>
</tr>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td bgcolor="#92c647" width=58 height=91>
<img src="{{ _p.web_css_theme }}images/lado-b.png" style="display:block;">
</td>
<td bgcolor="#92c647" width=700 height=91 style="font-family:CourierSans-Light; font-weight: bold; line-height: 47px; color:#FFF; padding-bottom: 10px; font-size: 45px;">
{{ 'CertificateHeader' | get_lang }}
</td>
<td bgcolor="#92c647" width=58 height=91>
<img src="{{ _p.web_css_theme }}images/lado-header.png" style="display:block;">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="0" width="100%" height=900>
<tr>
<td bgcolor="#92c647" height=755><img src="{{ _p.web_css_theme }}images/lado-a.png" style="display:block;"></td>
<td height=755 style="font-family:CourierSans-Light; line-height: 22px; color:#40ad49; padding: 40px; font-size: 18px;" valign="top">
<h3 style="color: #672290; font-size: 24px;">
{{ complete_name }}
</h3>
<p style="font-size: 16px;">
{{ 'UserHasParticipateDansDePlatformeXTheContratDateXCertificateDateXTimeX' | get_lang | format(_s.site_name, certificate_generated_date_no_time, terms_validation_date_no_time, time_in_platform_in_hours)}}
</p>
<br />
<p style="font-size: 16px;">{{ 'ThisTrainingHasXHours' | get_lang | format(time_in_platform_in_hours)}}</p><br />
<p style="font-size: 16px;">{{ 'TheContentsAreValidated' | get_lang }}:</p>
{% if sessions %}
<ul style="color: #672290; font-size: 16px;">
{% for session in sessions %}
<li> {{ session.session_name }}</li>
{% endfor %}
</ul>
{% endif %}<br />
<h4 style="color: #672290; font-size: 16px;">{{ complete_name }}</h4>
<p style="color:#40ad49; font-size: 16px;">{{ 'SkillsValidated' | get_lang }}:</p>
{% if skills %}
<ul style="color: #672290; font-size: 16px;">
{% for skill in skills %}
<li>{{ skill.name }}</li>
{% endfor %}
</ul>
{% endif %}
<br />
<p style="color:#40ad49; font-size: 16px;">Berlin/Paris, {{ 'The' | get_lang }} <span style="font-weight: bold; color: #672290;">{{ certificate_generated_date_no_time }}</span><br />
{{ 'ThePlatformTeam' | get_lang }}</p>
<br />
</td>
<td height=755 bgcolor="#92c647">
<img src="{{ _p.web_css_theme }}images/lado-b.png" style="display:block;">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height=91>
<tr>
<td bgcolor="#92c647" width=58 height=91><img src="{{ _p.web_css_theme }}images/lado-b.png" style="display:block;"></td>
<td bgcolor="#92c647" width=500 height=91 style="font-family:CourierSans-Light; line-height: 18px; color:#FFF;">
{{ 'CertificateFooter' | get_lang }}
</td>
<td bgcolor="#92c647" width=245 height=91><img src="{{ _p.web_css_theme }}images/lado-footer.png" style="display:block;"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Loading…
Cancel
Save