$course_name = get_lang('Course').' '.$courseInfo['name']; if ($session_id) { echo Display::page_subheader( Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.api_get_session_name($session_id).' '. Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$course_name ); } else { echo Display::page_subheader( Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$courseInfo['name'] ); } $teacherList = CourseManager::get_teacher_list_from_course_code_to_string( $courseInfo['code'], ',', false ); $coaches = null; if (!empty($session_id)) { $coaches = CourseManager::get_coachs_from_course_to_string( $session_id, $courseInfo['code'], ',', false ); } if (!empty($teacherList)) { echo Display::page_subheader2(get_lang('Teachers'));
/** * Export the given HTML to PDF, using a global template * @param string $content the HTML content * * @uses export/table_pdf.tpl */ public function html_to_pdf_with_template($content) { global $_configuration; Display :: display_no_header(); // Assignments Display::$global_template->assign('pdf_content', $content); $organization = api_get_setting('Institution'); $img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png'; // Search for classic logo if (file_exists($img)) { $img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png'; $organization = "<img src='$img'>"; } else { // Just use the platform title. if (!empty($organization)) { $organization = '<h2 align="left">'.$organization.'</h2>'; } } // Use custom logo image. if (isset($_configuration['pdf_logo_header']) && $_configuration['pdf_logo_header'] ) { $img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/pdf_logo_header.png'; if (file_exists($img)) { $img = api_get_path(WEB_CODE_PATH) . 'css/' . api_get_visual_theme() . '/images/pdf_logo_header.png'; $organization = "<img src='$img'>"; } } Display::$global_template->assign('organization', $organization); //Showing only the current teacher/admin instead the all teacher list name see BT#4080 if (isset($this->params['show_real_course_teachers']) && $this->params['show_real_course_teachers'] ) { if (isset($this->params['session_info']) && !empty($this->params['session_info']) ) { $teacher_list = SessionManager::getCoachesByCourseSessionToString( $this->params['session_info']['id'], $this->params['course_code'] ); } else { $teacher_list = CourseManager::get_teacher_list_from_course_code_to_string( $this->params['course_code'] ); } } else { $user_info = api_get_user_info(); $teacher_list = $user_info['complete_name']; } Display::$global_template->assign('pdf_course', $this->params['course_code']); Display::$global_template->assign('pdf_course_info', $this->params['course_info']); Display::$global_template->assign('pdf_session_info', $this->params['session_info']); Display::$global_template->assign('pdf_date', api_format_date(api_get_local_time(), DATE_TIME_FORMAT_LONG)); Display::$global_template->assign('pdf_teachers', $teacher_list); Display::$global_template->assign('pdf_title', $this->params['pdf_title']); Display::$global_template->assign('add_signatures', $this->params['add_signatures']); // Getting template $tpl = Display::$global_template->get_template('export/table_pdf.tpl'); $html = Display::$global_template->fetch($tpl); $html = api_utf8_encode($html); $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).'/print.css'; $css = file_exists($css_file) ? @file_get_contents($css_file) : ''; self::content_to_pdf($html, $css, $this->params['filename'], $this->params['course_code']); }
case 'pdf': $description = '<table class="data_table_no_border">'; if (api_get_session_id()) { $description .= '<tr><td>' . get_lang('Session') . ': </td><td class="highlight">' . api_get_session_name(api_get_session_id()) . '</td>'; } $description .= '<tr><td>' . get_lang('Course') . ': </td><td class="highlight">' . $course_info['name'] . '</td>'; $teachers = CourseManager::get_teacher_list_from_course_code($course_info['real_id']); //If I'm a teacher in this course show just my name if (isset($teachers[$user_id])) { if (!empty($teachers)) { $teacher_info = $teachers[$user_id]; $description .= '<tr><td>' . get_lang('Teacher') . ': </td><td class="highlight">' . api_get_person_name($teacher_info['firstname'], $teacher_info['lastname']) . '</td>'; } } else { //If not show all teachers $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['real_id']); if (!empty($teachers)) { $description .= '<tr><td>' . get_lang('Teachers') . ': </td><td class="highlight">' . $teachers . '</td>'; } } if (!empty($session_id)) { //If I'm a coach $coaches = CourseManager::get_coach_list_from_course_code($course_info['real_id'], $session_id); if (isset($coaches) && isset($coaches[$user_id])) { $user_info = api_get_user_info($user_id); $description .= '<tr><td>' . get_lang('Coach') . ': </td><td class="highlight">' . $user_info['complete_name'] . '</td>'; } else { //If not show everything $teachers = CourseManager::get_coach_list_from_course_code_to_string($course_info['real_id'], $session_id); if (!empty($teachers)) { $description .= '<tr><td>' . get_lang('Coachs') . ': </td><td class="highlight">' . $coaches . '</td>';
/** * Display list of courses in a category. * (for anonymous users) * * @version 1.1 * @author Patrick Cool <*****@*****.**>, Ghent University - refactoring and code cleaning * @author Julio Montoya <*****@*****.**>, Beeznest template modifs */ function return_courses_in_categories() { $result = ''; $stok = Security::get_token(); // Initialization. $user_identified = (api_get_user_id() > 0 && !api_is_anonymous()); $web_course_path = api_get_path(WEB_COURSE_PATH); $category = Database::escape_string($_GET['category']); $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; // Database table definitions. $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY); // Get list of courses in category $category. $sql_get_course_list = "SELECT * FROM $main_course_table cours WHERE category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)"; // Showing only the courses of the current access_url_id. global $_configuration; if ($_configuration['multiple_access_urls']) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql_get_course_list = "SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course ON (url_rel_course.course_code=course.code) WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)"; } } // Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' $sql_result_courses = Database::query($sql_get_course_list); while ($course_result = Database::fetch_array($sql_result_courses)) { $course_list[] = $course_result; } // $setting_show_also_closed_courses if ($user_identified) { if ($setting_show_also_closed_courses) { $platform_visible_courses = ''; } else { $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )"; } } else { if ($setting_show_also_closed_courses) { $platform_visible_courses = ''; } else { $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )"; } } $sqlGetSubCatList = " SELECT t1.name, t1.code, t1.parent_id, t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse FROM $main_category_table t1 LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id LEFT JOIN $main_course_table t3 ON (t3.category_code = t1.code $platform_visible_courses) WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; // Showing only the category of courses of the current access_url_id if (api_is_multiple_url_enabled()) { require_once api_get_path(LIBRARY_PATH).'course_category.lib.php'; $courseCategoryCondition = null; if (isMultipleUrlSupport()) { $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY); $courseCategoryCondition = " INNER JOIN $table a ON (t1.id = a.course_category_id)"; } $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sqlGetSubCatList = " SELECT t1.name, t1.code, t1.parent_id, t1.children_count, COUNT(DISTINCT t3.code) AS nbCourse FROM $main_category_table t1 $courseCategoryCondition LEFT JOIN $main_category_table t2 ON t1.code = t2.parent_id LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) INNER JOIN $tbl_url_rel_course as url_rel_course ON (url_rel_course.course_code=t3.code) WHERE url_rel_course.access_url_id = $url_access_id AND t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; } } $resCats = Database::query($sqlGetSubCatList); $thereIsSubCat = false; if (Database::num_rows($resCats) > 0) { $htmlListCat = Display::page_header(get_lang('CatList')); $htmlListCat .= '<ul>'; $htmlTitre = ''; while ($catLine = Database::fetch_array($resCats)) { $category_has_open_courses = self::category_has_open_courses($catLine['code']); if ($category_has_open_courses) { // The category contains courses accessible to anonymous visitors. $htmlListCat .= '<li>'; $htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>'; if (api_get_setting('show_number_of_courses') == 'true') { $htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')'; } $htmlListCat .= "</li>"; $thereIsSubCat = true; } elseif ($catLine['children_count'] > 0) { // The category has children, subcategories. $htmlListCat .= '<li>'; $htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>'; $htmlListCat .= "</li>"; $thereIsSubCat = true; } elseif (api_get_setting('show_empty_course_categories') == 'true') { /* End changed code to eliminate the (0 courses) after empty categories. */ $htmlListCat .= '<li>'; $htmlListCat .= $catLine['name']; $htmlListCat .= "</li>"; $thereIsSubCat = true; } // Else don't set thereIsSubCat to true to avoid printing things if not requested. // TODO: deprecate this useless feature - this includes removing system variable if (empty($htmlTitre)) { $htmlTitre = '<p>'; if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { $htmlTitre .= '<a href="'.api_get_self().'"><< '.get_lang('BackToHomePage').'</a>'; } $htmlTitre .= "</p>"; } } $htmlListCat .= "</ul>"; } $result .= $htmlTitre; if ($thereIsSubCat) { $result .= $htmlListCat; } while ($categoryName = Database::fetch_array($resCats)) { $result .= '<h3>' . $categoryName['name'] . "</h3>\n"; } $numrows = Database::num_rows($sql_result_courses); $courses_list_string = ''; $courses_shown = 0; if ($numrows > 0) { $courses_list_string .= Display::page_header(get_lang('CourseList')); $courses_list_string .= "<ul>"; if (api_get_user_id()) { $courses_of_user = self::get_courses_of_user(api_get_user_id()); } foreach ($course_list as $course) { // $setting_show_also_closed_courses if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) { continue; } if (!$setting_show_also_closed_courses) { // If we do not show the closed courses // we only show the courses that are open to the world (to everybody) // and the courses that are open to the platform (if the current user is a registered user. if (($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { $courses_shown++; $courses_list_string .= "<li>"; $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />'; $course_details = array(); if (api_get_setting('display_coursecode_in_courselist') == 'true') { $course_details[] = $course['visual_code']; } if (api_get_setting('display_teacher_in_courselist') == 'true') { $course_details[] = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); } if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { $course_details[] = $course['course_language']; } $courses_list_string .= implode(' - ', $course_details); $courses_list_string .= "</li>"; } } else { // We DO show the closed courses. // The course is accessible if (link to the course homepage): // 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); // 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); // 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED; // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting); // 5. the user is the platform admin api_is_platform_admin(). // $courses_shown++; $courses_list_string .= "<li>"; if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($user_identified && array_key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) || $courses_of_user[$course['code']]['status'] == '1' || api_is_platform_admin()) { $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'; } $courses_list_string .= $course['title']; if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($user_identified && array_key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) || $courses_of_user[$course['code']]['status'] == '1' || api_is_platform_admin()) { $courses_list_string .= '</a><br />'; } $course_details = array(); if (api_get_setting('display_coursecode_in_courselist') == 'true') { $course_details[] = $course['visual_code']; } // if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { // $courses_list_string .= ' - '; // } if (api_get_setting('display_teacher_in_courselist') == 'true') { if (!empty($course['tutor_name'])) { $course_details[] = $course['tutor_name']; } } if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { $course_details[] = $course['course_language']; } $courses_list_string .= implode(' - ', $course_details); // We display a subscription link if: // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied // 2. if ($user_identified && !array_key_exists($course['code'], $courses_of_user)) { if ($course['subscribe'] == '1') { /*$courses_list_string .= '<form action="main/auth/courses.php?action=subscribe&category='.Security::remove_XSS($_GET['category']).'" method="post">'; $courses_list_string .= '<input type="hidden" name="sec_token" value="'.$stok.'">'; $courses_list_string .= '<input type="hidden" name="subscribe" value="'.$course['code'].'" />'; $courses_list_string .= '<input type="image" name="unsub" src="main/img/enroll.gif" alt="'.get_lang('Subscribe').'" />'.get_lang('Subscribe').'</form>'; */ $courses_list_string .= ' <a class="btn btn-primary" href="main/auth/courses.php?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&category_code='.Security::remove_XSS($_GET['category']).'">'.get_lang('Subscribe').'</a><br />'; } else { $courses_list_string .= '<br />'.get_lang('SubscribingNotAllowed'); } } $courses_list_string .= "</li>"; } //end else } // end foreach $courses_list_string .= "</ul>"; } if ($courses_shown > 0) { // Only display the list of courses and categories if there was more than // 0 courses visible to the world (we're in the anonymous list here). $result .= $courses_list_string; } if ($category != '') { $result .= '<p><a href="'.api_get_self().'"> ' . Display :: return_icon('back.png', get_lang('BackToHomePage')) . get_lang('BackToHomePage') . '</a></p>'; } return $result; }
/** * Display the title of a course in course catalog * @param $course */ function return_title($course) { $html = ''; $linkCourse = api_get_course_url($course['code']); $title = cut($course['title'], 70); $ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote'; $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); $rating = Display::return_rating_system('star_' . $course['real_id'], $ajax_url . '&course_id=' . $course['real_id'], $course['point_info']); $html .= '<h4 class="title"><a href="' . $linkCourse . '">' . cut($title, 60) . '</a></h4>'; $html .= '<div class="teachers">' . $teachers . '</div>'; $html .= '<div class="ranking">' . $rating . '</div>'; return $html; }
/** * Export the given HTML to PDF, using a global template * * @uses export/table_pdf.tpl * @param $content * @param bool|false $saveToFile * @param bool|false $returnHtml * * @return string */ public function html_to_pdf_with_template($content, $saveToFile = false, $returnHtml = false) { if (empty($this->template)) { $tpl = new Template('', false, false, false); } else { $tpl = $this->template; } // Assignments // Assignments $tpl->assign('pdf_content', $content); $organization = api_get_setting('Institution'); $img = api_get_path(SYS_CSS_PATH) . 'themes/' . api_get_visual_theme() . '/images/header-logo.png'; // Search for classic logo if (file_exists($img)) { $img = api_get_path(WEB_CSS_PATH) . 'themes/' . api_get_visual_theme() . '/images/header-logo.png'; $organization = "<img src='{$img}'>"; } else { // Just use the platform title. if (!empty($organization)) { $organization = '<h2 align="left">' . $organization . '</h2>'; } } // Use custom logo image. $pdfLogo = api_get_setting('pdf_logo_header'); if ($pdfLogo === 'true') { $visualTheme = api_get_visual_theme(); $img = api_get_path(SYS_CSS_PATH) . 'themes/' . $visualTheme . '/images/pdf_logo_header.png'; if (file_exists($img)) { $img = api_get_path(WEB_CSS_PATH) . 'themes/' . $visualTheme . '/images/pdf_logo_header.png'; $organization = "<img src='{$img}'>"; } } $tpl->assign('organization', $organization); //Showing only the current teacher/admin instead the all teacher list name see BT#4080 if (isset($this->params['show_real_course_teachers']) && $this->params['show_real_course_teachers']) { if (isset($this->params['session_info']) && !empty($this->params['session_info'])) { $teacher_list = SessionManager::getCoachesByCourseSessionToString($this->params['session_info']['id'], $this->params['course_info']['real_id']); } else { $teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($this->params['course_code']); } } else { $user_info = api_get_user_info(); if ($this->params['show_teacher_as_myself']) { $teacher_list = $user_info['complete_name']; } } $tpl->assign('pdf_course', $this->params['course_code']); $tpl->assign('pdf_course_info', $this->params['course_info']); $tpl->assign('pdf_session_info', $this->params['session_info']); $tpl->assign('pdf_date', $this->params['pdf_date']); $tpl->assign('pdf_teachers', $teacher_list); $tpl->assign('pdf_title', $this->params['pdf_title']); $tpl->assign('pdf_student_info', $this->params['student_info']); $tpl->assign('show_grade_generated_date', $this->params['show_grade_generated_date']); $tpl->assign('add_signatures', $this->params['add_signatures']); // Getting template $tableTemplate = $tpl->get_template('export/table_pdf.tpl'); $html = $tpl->fetch($tableTemplate); $html = api_utf8_encode($html); $css_file = api_get_path(TO_SYS, WEB_CSS_PATH) . '/print.css'; $css = file_exists($css_file) ? @file_get_contents($css_file) : ''; $html = self::content_to_pdf($html, $css, $this->params['filename'], $this->params['course_code'], 'D', $saveToFile, null, $returnHtml); if ($returnHtml) { return $html; } }
/** * @param int $workId * @param array $courseInfo * @param int $sessionId * @param string $format * @return bool */ function exportAllStudentWorkFromPublication( $workId, $courseInfo, $sessionId, $format = 'pdf' ) { if (empty($courseInfo)) { return false; } $workData = get_work_data_by_id($workId); if (empty($workData)) { return false; } $assignment = get_work_assignment_by_id($workId); $courseCode = $courseInfo['code']; $header = get_lang('Course').': '.$courseInfo['title']; $teachers = CourseManager::get_teacher_list_from_course_code_to_string( $courseCode ); if (!empty($sessionId)) { $sessionInfo = api_get_session_info($sessionId); if (!empty($sessionInfo)) { $header .= ' - ' . $sessionInfo['name']; $header .= '<br />' . $sessionInfo['description']; $teachers = SessionManager::getCoachesByCourseSessionToString( $sessionId, $courseCode ); } } $header .= '<br />'.get_lang('Teachers').': '.$teachers.'<br />'; $header .= '<br />'.get_lang('Date').': '.api_get_local_time().'<br />'; $header .= '<br />'.get_lang('StudentPublication').': '.$workData['title'].'<br />'; $content = null; $expiresOn = null; if (!empty($assignment) && isset($assignment['expires_on'])) { $content .= '<br /><strong>' . get_lang('ExpiryDate') . '</strong>: ' . api_get_local_time($assignment['expires_on']); $expiresOn = api_get_local_time($assignment['expires_on']); } if (!empty($workData['description'])) { $content .= '<br /><strong>' . get_lang('Description') . '</strong>: ' . $workData['description']; } $workList = get_work_user_list(null, null, null, null, $workId); switch ($format) { case 'pdf': if (!empty($workList)) { require_once api_get_path(LIBRARY_PATH).'pdf.lib.php'; $table = new HTML_Table(array('class' => 'data_table')); $headers = array( get_lang('Name'), get_lang('User'), get_lang('HandOutDateLimit'), get_lang('SentDate'), get_lang('Filename'), get_lang('Score'), get_lang('Feedback') ); $column = 0; foreach($headers as $header) { $table->setHeaderContents(0, $column, $header); $column++; } $row = 1; //$pdf->set_custom_header($header); foreach ($workList as $work) { $content .= '<hr />'; // getWorkComments need c_id $work['c_id'] = $courseInfo['real_id']; //$content .= get_lang('Date').': '.api_get_local_time($work['sent_date_from_db']).'<br />'; $score = null; if (!empty($work['qualification_only'])) { $score = $work['qualification_only']; } //$content .= get_lang('Description').': '.$work['description'].'<br />'; $comments = getWorkComments($work); $feedback = null; if (!empty($comments)) { $content .= '<h4>'.get_lang('Feedback').': </h4>'; foreach ($comments as $comment) { $feedback .= get_lang('User').': '.api_get_person_name( $comment['firstname'], $comment['lastname'] ).'<br />'; $feedback .= $comment['comment'].'<br />'; } } $table->setCellContents($row, 0, strip_tags($workData['title'])); $table->setCellContents($row, 1, api_get_person_name(strip_tags($work['firstname']), strip_tags($work['lastname']))); $table->setCellContents($row, 2, $expiresOn); $table->setCellContents($row, 3, api_get_local_time($work['sent_date_from_db'])); $table->setCellContents($row, 4, strip_tags($work['title'])); $table->setCellContents($row, 5, $score); $table->setCellContents($row, 6, $feedback); $row++; } $content = $table->toHtml(); if (!empty($content)) { $params = array( 'filename' => $workData['title'] . '_' . api_get_local_time(), 'pdf_title' => replace_dangerous_char($workData['title']), 'course_code' => $courseInfo['code'], 'add_signatures' => false ); $pdf = new PDF('A4', null, $params); $pdf->html_to_pdf_with_template($content); } exit; } break; } }
public static function process_hot_course_item($courses, $my_course_code_list = array()) { $ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote'; foreach ($courses as &$my_course) { $course_info = api_get_course_info_by_id($my_course['c_id']); $my_course['extra_info'] = $course_info; $my_course['extra_info']['go_to_course_button'] = ''; $my_course['extra_info']['register_button'] = ''; $access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list); //Course visibility if ($access_link && in_array('register', $access_link)) { $stok = Security::get_token(); $my_course['extra_info']['register_button'] = Display::url(get_lang('Subscribe'), api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?action=subscribe&sec_token=' . $stok, array('class' => 'btn btn-primary')); } if ($access_link && in_array('enter', $access_link)) { $my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php', array('class' => 'btn btn-primary')); } // Description $my_course['extra_info']['description_button'] = ''; if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list)) { $my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH) . 'course_home.ajax.php?a=show_course_information&code=' . $course_info['code'], array('class' => 'ajax btn btn-default')); } $my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['real_id']); $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 . '&course_id=' . $course_info['real_id'], $point_info); } return $courses; }
/** * Display the title of a course in course catalog * @param $course */ function display_title($course) { $title = cut($course['title'], 70); $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code']); $rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $course['point_info']); $teachers = '<h5>'.$teachers.'</h5>'; echo '<div class="categories-course-description">'; echo '<h3>'.cut($title, 60).'</h3>'; echo $teachers; echo $rating; echo '</div>'; // categories-course-description }
/** * Return tab of params to display a course title in the My Courses tab * Check visibility, right, and notification icons, and load_dirs option * @param $courseId * @param bool $loadDirs * @return array */ public static function getCourseParamsForDisplay($courseId, $loadDirs = false) { $user_id = api_get_user_id(); // Table definitions $TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE); $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER); $TABLE_ACCESS_URL_REL_COURSE = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); // Get course list auto-register $special_course_list = self::get_special_course_list(); $without_special_courses = ''; if (!empty($special_course_list)) { $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; } //AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." $sql = "SELECT course.id, course.title, course.code, course.subscribe subscr, course.unsubscribe unsubscr, course_rel_user.status status,\n course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat\n FROM {$TABLECOURS} course,\n {$TABLECOURSUSER} course_rel_user, " . $TABLE_ACCESS_URL_REL_COURSE . " url\n WHERE course.id=" . intval($courseId) . "\n AND course.id = course_rel_user.c_id\n AND url.c_id = course.id\n AND course_rel_user.user_id = " . intval($user_id) . "\n {$without_special_courses} "; // If multiple URL access mode is enabled, only fetch courses // corresponding to the current URL. if (api_get_multiple_access_url() && $current_url_id != -1) { $sql .= " AND url.course_code=course.code AND access_url_id=" . intval($current_url_id); } // Use user's classification for courses (if any). $sql .= " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC"; $result = Database::query($sql); // Browse through all courses. We can only have one course because of the course.id=".intval($courseId) in sql query $course = Database::fetch_array($result); $course_info = api_get_course_info($course['code']); //$course['id_session'] = null; $course_info['id_session'] = null; $course_info['status'] = $course['status']; // For each course, get if there is any notification icon to show // (something that would have changed since the user's last visit). $show_notification = Display::show_notification($course_info); // New code displaying the user's status in respect to this course. $status_icon = Display::return_icon('blackboard.png', $course_info['title'], array(), ICON_SIZE_LARGE); $params = array(); $params['right_actions'] = ''; if (api_is_platform_admin()) { if ($loadDirs) { $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; $params['right_actions'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container')); } else { $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; } if ($course_info['status'] == COURSEMANAGER) { //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;')); } } else { if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { if ($loadDirs) { $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; $params['right_actions'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container')); } else { if ($course_info['status'] == COURSEMANAGER) { $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; } } } } $course_title_url = ''; if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) { $course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/?id_session=0'; $course_title = Display::url($course_info['title'], $course_title_url); } else { $course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'), array('class' => 'item_closed')); } // Start displaying the course block itself if (api_get_setting('display_coursecode_in_courselist') == 'true') { $course_title .= ' (' . $course_info['visual_code'] . ') '; } $teachers = ''; if (api_get_setting('display_teacher_in_courselist') == 'true') { $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['code'], self::USER_SEPARATOR, true); } $params['link'] = $course_title_url; $params['icon'] = $status_icon; $params['title'] = $course_title; $params['teachers'] = $teachers; if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { $params['notifications'] = $show_notification; } return $params; }