if (!empty($total_skills_to_search)) { $total_skills_to_search = $skill->get_skills_info($total_skills_to_search); foreach ($total_skills_to_search as $skill_info) { $skill_list[$skill_info['id']] = $skill_info; } } Display::$global_template->assign('skill_list', $skill_list); echo Display::$global_template->fetch('default/skill/profile.tpl'); break; case 'delete_gradebook_from_skill': 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($_REQUEST['skill_id'], $_REQUEST['gradebook_id']); if (!empty($skill_item)) { $skill_gradebook->delete($skill_item['id']); echo 1; } else { echo 0; } } else { echo 0; } } break; case 'get_profile': $skillRelProfile = new SkillRelProfile(); $profileId = isset($_REQUEST['profile_id']) ? intval($_REQUEST['profile_id']) : null; $profile = $skillRelProfile->getProfileInfo($profileId); echo json_encode($profile); break;
/** * @param int $gradebook_id * @param array $skill_list * @return bool */ public function update_skills_to_gradebook($gradebook_id, $skill_list, $deleteSkillNotInList = true) { $skill_gradebook = new SkillRelGradebook(); $skill_gradebooks_source = $skill_gradebook->get_all(array('where' => array('gradebook_id = ?' => $gradebook_id))); $clean_gradebook = array(); if (!empty($skill_gradebooks_source)) { foreach ($skill_gradebooks_source as $source) { $clean_gradebook[] = $source['skill_id']; } } //Cleaning skills $skill_list = array_map('intval', $skill_list); $skill_list = array_filter($skill_list); if (!empty($skill_list)) { if (!empty($clean_gradebook)) { $skill_to_remove = array_diff($clean_gradebook, $skill_list); } foreach ($skill_list as $skill_id) { $params = array(); $params['gradebook_id'] = $gradebook_id; $params['skill_id'] = $skill_id; if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) { $skill_gradebook->save($params); } } } else { $skill_to_remove = $clean_gradebook; } if ($deleteSkillNotInList) { if (!empty($skill_to_remove)) { foreach ($skill_to_remove as $remove) { $skill_item = $skill_gradebook->get_skill_info($remove, $gradebook_id); $skill_gradebook->delete($skill_item['id']); } } } return false; }