public static function redirect() { global $param; $param = isset($param) ? $param : ''; $redirect_url = ''; /* //If session request url is setted, we go there if (!empty($_SESSION['request_uri'])) { $req = $_SESSION['request_uri']; unset($_SESSION['request_uri']); header('location: '.$req); exit(); } */ if (api_is_student() && !api_get_setting('student_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('student_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_teacher() && !api_get_setting('teacher_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_drh() && !api_get_setting('drh_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('drh_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (!empty($redirect_url)) { header('Location: ' . $redirect_url . $param); exit; } // Custom pages if (CustomPages::enabled()) { CustomPages::display(CustomPages::INDEX_LOGGED); } header('location: ' . api_get_path(WEB_PATH) . api_get_setting('page_after_login') . $param); exit; }
<?php /* For licensing terms, see /license.txt */ /** * Show the skills report * @author Angel Fernando Quiroz Campos <*****@*****.**> * @package chamilo.social.skill */ //require_once '../inc/global.inc.php'; $isStudent = api_is_student(); $isStudentBoss = api_is_student_boss(); $isDRH = api_is_drh(); if (!$isStudent && !$isStudentBoss && !$isDRH) { header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'); exit; } $userId = api_get_user_id(); $skillTable = Database::get_main_table(TABLE_MAIN_SKILL); $skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER); $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $tableRows = array(); //$tpl = new Template(get_lang('Skills')); $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); $tplPath = null; $tpl->addGlobal('allowSkillsTool', api_get_setting('skill.allow_skills_tool') == 'true'); $tpl->addGlobal('allowDrhSkillsManagement', api_get_setting('skill.allow_hr_skills_management') == 'true'); if ($isStudent) { $sql = "SELECT s.name, sru.acquired_skill_at, c.title, c.directory\n FROM {$skillTable} s\n INNER JOIN {$skillRelUserTable} sru\n ON s.id = sru.skill_id\n INNER JOIN {$courseTable} c\n ON sru.course_id = c.id\n WHERE sru.user_id = {$userId}"; $result = Database::query($sql); while ($resultData = Database::fetch_assoc($result)) { $tableRow = array('skillName' => $resultData['name'], 'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER), 'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_MEDIUM, null, true), 'courseName' => $resultData['title']);
function return_course_block() { $html = ''; $show_create_link = false; $show_course_link = false; if ((api_get_setting('allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) || api_is_student()) { $display_add_course_link = false; } else { $display_add_course_link = true; } //$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview'); if ($display_add_course_link) { $show_create_link = true; } if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { $show_course_link = true; } else { if (api_get_setting('allow_students_to_browse_courses') == 'true') { $show_course_link = true; } } // My account section $my_account_content = '<ul class="nav nav-list">'; if ($show_create_link) { $my_account_content .= '<li class="add-course"><a href="main/create_course/add_course.php">'; if (api_get_setting('course_validation') == 'true' && !api_is_platform_admin()) { $my_account_content .= get_lang('CreateCourseRequest'); } else { $my_account_content .= get_lang('CourseCreate'); } $my_account_content .= '</a></li>'; } //Sort courses $url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses'; $my_account_content .= '<li class="order-course">'.Display::url(get_lang('SortMyCourses'), $url, array('class' => 'sort course')).'</li>'; // Session history if (isset($_GET['history']) && intval($_GET['history']) == 1) { $my_account_content .= '<li class="history-course"><a href="user_portal.php">'.get_lang('DisplayTrainingList').'</a></li>'; } else { $my_account_content .= '<li class="history-course"><a href="user_portal.php?history=1" >'.get_lang('HistoryTrainingSessions').'</a></li>'; } // Course catalog if ($show_course_link) { if (!api_is_drh()) { $my_account_content .= '<li class="list-course"><a href="main/auth/courses.php" >'.get_lang('CourseCatalog').'</a></li>'; } else { $my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>'; } } $my_account_content .= '</ul>'; if (!empty($my_account_content)) { $html = self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block'); } return $html; }
/** * @return null|string */ public function return_course_block() { $html = ''; $show_create_link = false; $show_course_link = false; if (api_get_setting('course.allow_users_to_create_courses') == 'false' && !api_is_platform_admin() || api_is_student()) { $display_add_course_link = false; } else { $display_add_course_link = true; } if ($display_add_course_link) { $show_create_link = true; } if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { $show_course_link = true; } else { if (api_get_setting('display.allow_students_to_browse_courses') == 'true') { $show_course_link = true; } } // My account section $my_account_content = '<ul class="nav nav-pills nav-stacked">'; if ($show_create_link) { $my_account_content .= '<li class="add-course"><a href="main/create_course/add_course.php">'; if (api_get_setting('course.course_validation') == 'true' && !api_is_platform_admin()) { $my_account_content .= Display::return_icon('new-course.png', get_lang('CreateCourseRequest'), null, ICON_SIZE_SMALL); $my_account_content .= get_lang('CreateCourseRequest'); } else { $my_account_content .= Display::return_icon('new-course.png', get_lang('CourseCreate'), null, ICON_SIZE_SMALL); $my_account_content .= get_lang('CourseCreate'); } $my_account_content .= '</a></li>'; if (SessionManager::allowToManageSessions()) { $my_account_content .= '<li class="add-course"><a href="main/session/session_add.php">'; $my_account_content .= Display::return_icon('session.png', get_lang('AddSession'), null, ICON_SIZE_SMALL); $my_account_content .= get_lang('AddSession'); $my_account_content .= '</a></li>'; } } //Sort courses $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php?action=sortmycourses'; $img_order = Display::return_icon('order-course.png', get_lang('SortMyCourses'), null, ICON_SIZE_SMALL); $my_account_content .= '<li class="order-course">' . Display::url($img_order . get_lang('SortMyCourses'), $url, array('class' => 'sort course')) . '</li>'; // Session history if (isset($_GET['history']) && intval($_GET['history']) == 1) { $my_account_content .= '<li class="history-course"><a href="user_portal.php">' . Display::return_icon('history-course.png', get_lang('DisplayTrainingList'), null, ICON_SIZE_SMALL) . get_lang('DisplayTrainingList') . '</a></li>'; } else { $my_account_content .= '<li class="history-course"><a href="user_portal.php?history=1" >' . Display::return_icon('history-course.png', get_lang('HistoryTrainingSessions'), null, ICON_SIZE_SMALL) . get_lang('HistoryTrainingSessions') . '</a></li>'; } // Course catalog if ($show_course_link) { if (!api_is_drh()) { $my_account_content .= '<li class="list-course"><a href="main/auth/courses.php" >' . Display::return_icon('catalog-course.png', get_lang('CourseCatalog'), null, ICON_SIZE_SMALL) . get_lang('CourseCatalog') . '</a></li>'; } else { $my_account_content .= '<li><a href="main/dashboard/index.php">' . get_lang('Dashboard') . '</a></li>'; } } $my_account_content .= '</ul>'; if (!empty($my_account_content)) { $html = self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block', null, 'course', 'courseCollapse'); } return $html; }
/** * Get HTML code block for user skills * @param int $userId The user ID * @return string */ public static function getSkillBlock($userId) { if (api_get_setting('skill.allow_skills_tool') !== 'true') { return null; } $skill = new Skill(); $ranking = $skill->get_user_skill_ranking($userId); $skills = $skill->get_user_skills($userId, true); return Container::getTemplating()->render('@template_style/social/skills_block.html.twig', ['ranking' => $ranking, 'skills' => $skills, 'user_id' => $userId, 'show_skills_report_link' => api_is_student() || api_is_student_boss() || api_is_drh()]); }
/** * Get HTML code block for user skills * @param int $userId The user ID * @return string */ public static function getSkillBlock($userId) { if (api_get_setting('allow_skills_tool') !== 'true') { return null; } $entityManager = Database::getManager(); $user = $entityManager->find('ChamiloUserBundle:User', $userId); if (!$user) { return null; } $achievedSkills = $user->getAchievedSkills(); $ranking = $achievedSkills->count(); $skillsInfo = []; foreach ($achievedSkills as $userSkill) { $skillsInfo[] = ['id' => $userSkill->getSkill()->getId(), 'name' => $userSkill->getSkill()->getName(), 'icon' => $userSkill->getSkill()->getWebIconPath(true), 'source_name' => $userSkill->getSourceName(), 'issue_url' => $userSkill->getIssueUrl()]; } $template = new Template(null, false, false, false, false, false); $template->assign('ranking', $ranking); $template->assign('skills', $skillsInfo); $template->assign('show_skills_report_link', api_is_student() || api_is_student_boss() || api_is_drh()); $skillBlock = $template->get_template('social/skills_block.tpl'); return $template->fetch($skillBlock); }
/** * Get HTML code block for user skills * @param int $userId The user ID * @return string */ public static function getSkillBlock($userId) { if (api_get_setting('allow_skills_tool') !== 'true') { return null; } $skill = new Skill(); $ranking = $skill->get_user_skill_ranking($userId); $skills = $skill->get_user_skills($userId, true); $template = new Template(null, false, false, false, false, false); $template->assign('ranking', $ranking); $template->assign('skills', $skills); $template->assign('show_skills_report_link', api_is_student() || api_is_student_boss() || api_is_drh()); $skillBlock = $template->get_template('social/skills_block.tpl'); return $template->fetch($skillBlock); }
<?php /* For licensing terms, see /license.txt */ /** * Show specified user certificate * @package chamilo.certificate */ require_once '../main/inc/global.inc.php'; $action = isset($_GET['action']) ? $_GET['action'] : null; $certificate = new Certificate($_GET['id']); switch ($action) { case 'export': $hideExportLink = api_get_setting('hide_certificate_export_link'); $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students'); if ($hideExportLink === 'true' || api_is_student() && $hideExportLinkStudent === 'true') { api_not_allowed(true); } $certificate->generate(array('hide_print_button' => true)); if ($certificate->html_file_is_generated()) { $certificatePathList[] = $certificate->html_file; $pdfParams = array('orientation' => 'landscape', 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0); $pdfParams['orientation'] = 'landscape'; $pageFormat = $pdfParams['orientation'] == 'landscape' ? 'A4-L' : 'A4'; $userInfo = api_get_user_info($certificate->user_id); $pdfName = api_replace_dangerous_char(get_lang('Certificate') . ' ' . $userInfo['username']); $pdf = new PDF($pageFormat, $pdfParams['orientation'], $pdfParams); $pdf->html_to_pdf($certificatePathList, $pdfName, null, false, false); } break; default: // Show certificate HTML
/** * @param int $category_id * @param int $user_id * @return bool|string */ public static function register_user_certificate($category_id, $user_id) { $courseId = api_get_course_int_id(); $courseCode = api_get_course_id(); $sessionId = api_get_session_id(); // Generating the total score for a course $cats_course = Category::load($category_id, null, null, null, null, $sessionId, false); /** @var Category $category */ $category = $cats_course[0]; //@todo move these in a function $sum_categories_weight_array = array(); if (isset($cats_course) && !empty($cats_course)) { $categories = Category::load(null, null, null, $category_id); if (!empty($categories)) { foreach ($categories as $subCategory) { $sum_categories_weight_array[$subCategory->get_id()] = $subCategory->get_weight(); } } else { $sum_categories_weight_array[$category_id] = $cats_course[0]->get_weight(); } } $main_weight = $cats_course[0]->get_weight(); $cattotal = Category::load($category_id); $scoretotal = $cattotal[0]->calc_score($user_id); // Do not remove this the gradebook/lib/fe/gradebooktable.class.php // file load this variable as a global $scoredisplay = ScoreDisplay::instance(); $my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); // A student always sees only the teacher's repartition $scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT); if (!self::userFinishedCourse($user_id, $cats_course[0], 0, $courseCode, $sessionId, true)) { return false; } $skillToolEnabled = api_get_setting('skill.allow_skills_tool') == 'true'; $userHasSkills = false; if ($skillToolEnabled) { if (!$category->getGenerateCertificates()) { $skill = new Skill(); $skill->add_skill_to_user($user_id, $category_id, $courseId, $sessionId); } $objSkillRelUser = new SkillRelUser(); $userSkills = $objSkillRelUser->get_user_skills($user_id, $courseId, $sessionId); $userHasSkills = !empty($userSkills); if (!$category->getGenerateCertificates() && $userHasSkills) { return ['badge_link' => Display::url(get_lang('DownloadBadges'), api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user={$user_id}", array('target' => '_blank', 'class' => 'btn btn-default'))]; } } $my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); if (empty($my_certificate)) { GradebookUtils::register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime()); $my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); } $html = array(); if (!empty($my_certificate)) { $certificate_obj = new Certificate($my_certificate['id']); $fileWasGenerated = $certificate_obj->html_file_is_generated(); if (!empty($fileWasGenerated)) { $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id']; $certificates = Display::url(Display::returnFontAwesomeIcon('download') . ' ' . get_lang('DownloadCertificate'), $url, array('target' => '_blank', 'class' => 'btn btn-sm btn-primary')); $exportToPDF = Display::url(Display::return_icon('pdf.png', get_lang('ExportToPDF'), array(), ICON_SIZE_MEDIUM), "{$url}&action=export"); $hideExportLink = api_get_setting('hide_certificate_export_link'); $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students'); if ($hideExportLink === 'true' || api_is_student() && $hideExportLinkStudent === 'true') { $exportToPDF = null; } $html = array('certificate_link' => $certificates, 'pdf_link' => $exportToPDF, 'pdf_url' => "{$url}&action=export"); if ($skillToolEnabled && $userHasSkills) { $html['badge_link'] = Display::url(get_lang('DownloadBadges'), api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user={$user_id}", array('target' => '_blank', 'class' => 'btn btn-default')); } } return $html; } }