Пример #1
0
 /**
  *
  * @return string
  */
 public function indexAction(Application $app, $id)
 {
     $actions = null;
     if (api_is_platform_admin()) {
         $actions = '<a href="' . api_get_path(WEB_PATH) . 'main/admin/system_announcements.php">' . \Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32) . '</a>';
     }
     if (api_is_anonymous()) {
         $visibility = \SystemAnnouncementManager::VISIBLE_GUEST;
     } else {
         $visibility = api_is_allowed_to_create_course() ? \SystemAnnouncementManager::VISIBLE_TEACHER : \SystemAnnouncementManager::VISIBLE_STUDENT;
     }
     $content = \SystemAnnouncementManager::display_announcements_slider($visibility, $id);
     $app['template']->assign('content', $content);
     $app['template']->assign('actions', $actions);
     $response = $app['template']->renderLayout('layout_1_col.tpl');
     return new Response($response, 200, array());
 }
Пример #2
0
    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;
    }
Пример #3
0
<?php

/* For licensing terms, see /license.txt */
/**
 * Implements the tracking of students in the Reporting pages
 * @package chamilo.reporting
 */
//require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh() && !api_is_student_boss()) {
    // Check if the user is tutor of the course
    $user_course_status = CourseManager::get_tutor_in_course_status(api_get_user_id(), api_get_course_id());
    if ($user_course_status != 1) {
        api_not_allowed(true);
    }
}
$alloAssignSkill = api_is_platform_admin(false, true);
$htmlHeadXtra[] = '<script>
function show_image(image,width,height) {
	width = parseInt(width) + 20;
	height = parseInt(height) + 20;
	window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
}
</script>';
$export = isset($_GET['export']) ? $_GET['export'] : false;
$sessionId = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0;
$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
if (empty($sessionId)) {
    $sessionId = api_get_session_id();
}
if ($export) {
Пример #4
0
 /**
  * @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;
 }
				</tr>
				<tr>
					<td>
						' . get_lang('NbCoursesPerSession') . '
					</td>
					<td align="right">
						' . $nb_courses_per_session . '
					</td>
				</tr>
			</table>
			<a href="session.php">' . get_lang('SeeSessionList') . '</a>
		 </div>';
    }
}
echo '<div class="clear">&nbsp;</div>';
if (api_is_allowed_to_create_course() && $view == 'teacher') {
    if ($nb_teacher_courses) {
        $table = new SortableTable('tracking_list_course', 'count_teacher_courses');
        $parameters['view'] = 'teacher';
        $parameters['class'] = 'data_table';
        $table->set_additional_parameters($parameters);
        $table->set_header(0, get_lang('CourseTitle'), false, 'align="center"');
        $table->set_header(1, get_lang('NbStudents'), false);
        $table->set_header(2, get_lang('AvgTimeSpentInTheCourse') . Display::return_icon('info3.gif', get_lang('TimeOfActiveByTraining'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(3, get_lang('AvgStudentsProgress') . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(4, get_lang('AvgCourseScore') . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(5, get_lang('AvgExercisesScore') . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(6, get_lang('AvgMessages'), false);
        $table->set_header(7, get_lang('AvgAssignments'), false);
        $table->set_header(8, get_lang('Details'), false);
        $csv_content[] = array(get_lang('CourseTitle'), get_lang('NbStudents'), get_lang('AvgTimeSpentInTheCourse'), get_lang('AvgStudentsProgress'), get_lang('AvgCourseScore'), get_lang('AvgExercisesScore'), get_lang('AvgMessages'), get_lang('AvgAssignments'));
 */
$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
// Including the global initialization file
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$course_info = api_get_course_info();
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
if ($from == 'myspace') {
    $from_myspace = true;
    $this_section = "session_my_space";
} else {
    $this_section = SECTION_COURSES;
}
// Access restrictions.
$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
if (!$is_allowedToTrack) {
    api_not_allowed();
    exit;
}
// Including additional libraries.
require_once api_get_path(SYS_CODE_PATH) . 'resourcelinker/resourcelinker.inc.php';
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($export_csv) {
    ob_start();
}
if (empty($session_id)) {
    $session_id = api_get_session_id();
}
 /**
  * @param int $start
  * @param string $user_id
  * @return int
  */
 public static function count_nb_announcement($start = 0, $user_id = '')
 {
     $start = intval($start);
     $visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT;
     $user_selected_language = api_get_interface_language();
     $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
     $sql = 'SELECT id FROM ' . $db_table . ' WHERE (lang="' . $user_selected_language . '" OR lang IS NULL) ';
     if (isset($user_id)) {
         switch ($visibility) {
             case self::VISIBLE_GUEST:
                 $sql .= " AND visible_guest = 1 ";
                 break;
             case self::VISIBLE_STUDENT:
                 $sql .= " AND visible_student = 1 ";
                 break;
             case self::VISIBLE_TEACHER:
                 $sql .= " AND visible_teacher = 1 ";
                 break;
         }
     }
     $current_access_url_id = 1;
     if (api_is_multiple_url_enabled()) {
         $current_access_url_id = api_get_current_access_url_id();
     }
     $sql .= " AND access_url_id = '{$current_access_url_id}' ";
     $sql .= 'LIMIT ' . $start . ', 21';
     $announcements = Database::query($sql);
     $i = 0;
     while ($rows = Database::fetch_array($announcements)) {
         $i++;
     }
     return $i;
 }
Пример #8
0
     if (api_is_platform_admin()) {
         $user_id = intval($_POST['user_id']);
         $list_course_all_info = CourseManager::get_courses_list_by_user_id($user_id, false);
         if (!empty($list_course_all_info)) {
             foreach ($list_course_all_info as $course_item) {
                 $course_info = api_get_course_info($course_item['code']);
                 echo $course_info['title'] . '<br />';
             }
         } else {
             echo get_lang('UserHasNoCourse');
         }
     }
     break;
 case 'search_category':
     require_once api_get_path(LIBRARY_PATH) . 'course_category.lib.php';
     if (api_is_platform_admin() || api_is_allowed_to_create_course()) {
         $results = searchCategoryByKeyword($_REQUEST['q']);
         if (!empty($results)) {
             foreach ($results as &$item) {
                 $item['id'] = $item['code'];
                 $item['text'] = '(' . $item['code'] . ') ' . $item['name'];
             }
             echo json_encode($results);
         } else {
             echo json_encode(array());
         }
     }
     break;
 case 'search_course':
     if (api_is_platform_admin()) {
         if (!empty($_GET['session_id']) && intval($_GET['session_id'])) {
Пример #9
0
 /**
  * Determines the possible tabs (=sections) that are available.
  * This function is used when creating the tabs in the third header line and
  * all the sections that do not appear there (as determined by the
  * platform admin on the Chamilo configuration settings page)
  * will appear in the right hand menu that appears on several other pages
  * @return array containing all the possible tabs
  * @author Patrick Cool <*****@*****.**>, Ghent University
  */
 public function getTabs()
 {
     $_course = api_get_course_info();
     $navigation = array();
     // Campus Homepage
     $navigation[SECTION_CAMPUS]['url'] = $this->urlGenerator->generate('index');
     $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
     // My Courses
     $navigation['mycourses']['url'] = $this->urlGenerator->generate('userportal');
     $navigation['mycourses']['title'] = get_lang('MyCourses');
     $webCodePath = $this->urlGenerator->generate('root') . '/main/';
     // My Profile
     if (api_is_profile_readable()) {
         $navigation['myprofile']['url'] = $webCodePath . 'auth/profile.php' . (!empty($_course['path']) ? '?coursePath=' . $_course['path'] . '&amp;courseCode=' . $_course['official_code'] : '');
         $navigation['myprofile']['title'] = get_lang('ModifyProfile');
     }
     // Link to my agenda
     $navigation['myagenda']['url'] = $webCodePath . 'calendar/agenda_js.php?type=personal';
     $navigation['myagenda']['title'] = get_lang('MyAgenda');
     // Gradebook
     if (api_get_setting('gradebook_enable') == 'true') {
         $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH) . 'gradebook/gradebook.php' . (!empty($_course['path']) ? '?coursePath=' . $_course['path'] . '&amp;courseCode=' . $_course['official_code'] : '');
         $navigation['mygradebook']['title'] = get_lang('MyGradebook');
     }
     // Reporting
     if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
         // Link to my space
         $navigation['session_my_space']['url'] = $webCodePath . 'mySpace/index.php';
         $navigation['session_my_space']['title'] = get_lang('MySpace');
     } else {
         // Link to my progress
         $navigation['session_my_progress']['url'] = $webCodePath . 'auth/my_progress.php';
         $navigation['session_my_progress']['title'] = get_lang('MyProgress');
     }
     // Social
     if (api_get_setting('social.allow_social_tool') == 'true') {
         $navigation['social']['url'] = $webCodePath . 'social/home.php';
         $navigation['social']['title'] = get_lang('SocialNetwork');
     }
     // Dashboard
     if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
         $navigation['dashboard']['url'] = $webCodePath . 'dashboard/index.php';
         $navigation['dashboard']['title'] = get_lang('Dashboard');
     }
     // Custom tabs
     for ($i = 1; $i <= 3; $i++) {
         if (api_get_setting('custom_tab_' . $i . '_name') && api_get_setting('custom_tab_' . $i . '_url')) {
             $navigation['custom_tab_' . $i]['url'] = api_get_setting('custom_tab_' . $i . '_url');
             $navigation['custom_tab_' . $i]['title'] = api_get_setting('custom_tab_' . $i . '_name');
         }
     }
     // Adding block settings for each role
     if (isset($this->app['allow_admin_toolbar'])) {
         $roleTemplate = array();
         foreach ($this->app['allow_admin_toolbar'] as $role) {
             if ($this->security->getToken() && $this->security->isGranted($role)) {
                 // Fixes in order to match the templates
                 if ($role == 'ROLE_ADMIN') {
                     $role = 'administrator';
                 }
                 if ($role == 'ROLE_QUESTION_MANAGER') {
                     $role = 'QUESTION_MANAGER';
                 }
                 $stripRole = strtolower(str_replace('ROLE_', '', $role));
                 $roleTemplate[] = $stripRole;
             }
         }
         if (!empty($roleTemplate)) {
             if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
                 //$navigation['admin']['url'] = api_get_path(WEB_PUBLIC_PATH).'admin';
                 //$navigation['admin']['title'] = get_lang('PlatformAdmin');
             }
         }
         $this->app['admin_toolbar_roles'] = $roleTemplate;
     }
     return $navigation;
 }
Пример #10
0
 /**
  * Gets the main menu
  *
  * @return array
  */
 public function returnNavigationArray()
 {
     $navigation = array();
     $menu_navigation = array();
     $possible_tabs = $this->getTabs();
     // Campus Homepage
     if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
         $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
     } else {
         $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
     }
     if (api_get_user_id() && !api_is_anonymous()) {
         // My Courses
         if (api_get_setting('show_tabs', 'my_courses') == 'true') {
             $navigation['mycourses'] = $possible_tabs['mycourses'];
         } else {
             $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
         }
         // My Profile
         if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
             if (isset($possible_tabs['myprofile'])) {
                 $navigation['myprofile'] = $possible_tabs['myprofile'];
             }
         } else {
             if (isset($possible_tabs['myprofile'])) {
                 $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
             }
         }
         // My Agenda
         if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
             $navigation['myagenda'] = $possible_tabs['myagenda'];
         } else {
             $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
         }
         // Gradebook
         if (api_get_setting('gradebook_enable') == 'true') {
             if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
                 $navigation['mygradebook'] = $possible_tabs['mygradebook'];
             } else {
                 $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
             }
         }
         // Reporting
         if (api_get_setting('show_tabs', 'reporting') == 'true') {
             if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
                 $navigation['session_my_space'] = $possible_tabs['session_my_space'];
             } else {
                 $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
             }
         } else {
             if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
                 $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
             } else {
                 $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
             }
         }
         // Social Networking
         if (api_get_setting('show_tabs', 'social') == 'true') {
             if (api_get_setting('allow_social_tool') == 'true') {
                 $navigation['social'] = $possible_tabs['social'];
             }
         } else {
             $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
         }
         // Dashboard
         if (api_get_setting('show_tabs', 'dashboard') == 'true') {
             if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
                 $navigation['dashboard'] = $possible_tabs['dashboard'];
             }
         } else {
             $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
         }
         if (isset($possible_tabs['admin'])) {
             $navigation['platform_admin'] = $possible_tabs['admin'];
             $navigation['platform_admin'] = $possible_tabs['admin'];
         }
         // Reports
         if (!empty($possible_tabs['reports'])) {
             if (api_get_setting('show_tabs', 'reports') == 'true') {
                 if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
                     $navigation['reports'] = $possible_tabs['reports'];
                 }
             } else {
                 $menu_navigation['reports'] = $possible_tabs['reports'];
             }
         }
         // Custom tabs
         for ($i = 1; $i <= 3; $i++) {
             if (api_get_setting('show_tabs', 'custom_tab_' . $i) == 'true') {
                 if (isset($possible_tabs['custom_tab_' . $i])) {
                     $navigation['custom_tab_' . $i] = $possible_tabs['custom_tab_' . $i];
                 }
             } else {
                 if (isset($possible_tabs['custom_tab_' . $i])) {
                     $menu_navigation['custom_tab_' . $i] = $possible_tabs['custom_tab_' . $i];
                 }
             }
         }
     }
     $return = array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs);
     return $return;
 }
Пример #11
0
    } else {
        return -1;
    }
}
function rsort_users($a, $b)
{
    global $tracking_column;
    if ($b[$tracking_column] > $a[$tracking_column]) {
        return 1;
    } else {
        return -1;
    }
}
/* MAIN CODE	 */
//if ($isCoach || api_is_platform_admin() || api_is_drh()) {
if (api_is_allowed_to_create_course() || api_is_drh()) {
    if ($export_csv) {
        $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
    } else {
        $is_western_name_order = api_is_western_name_order();
    }
    $sort_by_first_name = api_sort_by_first_name();
    if (api_is_drh()) {
        $menu_items = array();
        $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php");
        $menu_items[] = Display::return_icon('user_na.png', get_lang('Students'), array(), 32);
        $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), 32), 'teachers.php');
        $menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), 32), 'course.php');
        $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php');
        echo '<div class="actions">';
        $nb_menu_items = count($menu_items);
Пример #12
0
 /**
  * Gives a list of courses for the given user in the given session
  * @param integer $user_id
  * @return array  list of statuses (session_id-course_code => status)
  */
 public static function get_courses_list_by_session($user_id, $session_id)
 {
     // Database Table Definitions
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $user_id = intval($user_id);
     $session_id = intval($session_id);
     //we filter the courses from the URL
     $join_access_url = $where_access_url = '';
     if (api_get_multiple_access_url()) {
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
             $join_access_url = " ,  {$tbl_url_session} url_rel_session ";
             $where_access_url = " AND access_url_id = {$access_url_id} AND url_rel_session.session_id = {$session_id} ";
         }
     }
     $personal_course_list = array();
     $courses = array();
     // this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
     $personal_course_list_sql = "SELECT DISTINCT scu.c_id as id\n                                    FROM {$tbl_session_course_user} as scu {$join_access_url}\n                                    WHERE scu.id_user = {$user_id} AND scu.id_session = {$session_id} {$where_access_url}\n                                    ORDER BY c_id";
     $course_list_sql_result = Database::query($personal_course_list_sql);
     if (Database::num_rows($course_list_sql_result) > 0) {
         while ($result_row = Database::fetch_array($course_list_sql_result)) {
             $result_row['status'] = 5;
             if (!in_array($result_row['id'], $courses)) {
                 $personal_course_list[] = $result_row;
                 $courses[] = $result_row['id'];
             }
         }
     }
     if (api_is_allowed_to_create_course()) {
         $personal_course_list_sql = "SELECT DISTINCT scu.c_id as id\n                                        FROM {$tbl_session_course_user} as scu, {$tbl_session} as s {$join_access_url}\n                                        WHERE s.id = {$session_id} AND scu.id_session = s.id AND ((scu.id_user={$user_id} AND scu.status=2) OR s.id_coach = {$user_id})\n                                        {$where_access_url}\n                                        ORDER BY c_id";
         $course_list_sql_result = Database::query($personal_course_list_sql);
         if (Database::num_rows($course_list_sql_result) > 0) {
             while ($result_row = Database::fetch_array($course_list_sql_result)) {
                 $result_row['status'] = 2;
                 if (!in_array($result_row['id'], $courses)) {
                     $personal_course_list[] = $result_row;
                     $courses[] = $result_row['id'];
                 }
             }
         }
     }
     if (api_is_drh()) {
         $session_list = SessionManager::get_sessions_followed_by_drh($user_id);
         $session_list = array_keys($session_list);
         if (in_array($session_id, $session_list)) {
             $course_list = SessionManager::get_course_list_by_session_id($session_id);
             if (!empty($course_list)) {
                 foreach ($course_list as $course) {
                     $personal_course_list[] = $course;
                 }
             }
         }
     } else {
         //check if user is general coach for this session
         $s = api_get_session_info($session_id);
         if ($s['id_coach'] == $user_id) {
             $course_list = SessionManager::get_course_list_by_session_id($session_id);
             if (!empty($course_list)) {
                 foreach ($course_list as $course) {
                     if (!in_array($course['id'], $courses)) {
                         $personal_course_list[] = $course;
                     }
                 }
             }
         }
     }
     return $personal_course_list;
 }
Пример #13
0
<?php

/* For licensing terms, see /license.txt */
// including necessary files
require_once 'main/inc/global.inc.php';
$tool_name = get_lang('SystemAnnouncements');
$actions = '';
if (api_is_platform_admin()) {
    $actions = '<a href="' . api_get_path(WEB_PATH) . 'main/admin/system_announcements.php">' . Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32) . '</a>';
}
if (api_is_anonymous()) {
    $visibility = SystemAnnouncementManager::VISIBLE_GUEST;
} else {
    $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
}
if (!isset($_GET['id']) || empty($_GET['id'])) {
    $content = SystemAnnouncementManager::display_announcements_slider($visibility, $_GET['id']);
} else {
    $content = SystemAnnouncementManager::displayAnnouncement($_GET['id'], $visibility);
}
$tpl = new Template($tool_name);
$tpl->assign('actions', $actions);
//$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
Пример #14
0
    $count_sessions = count($sessions);
}
if ($count_courses || $count_sessions) {
    // If we are in course.
    if (empty($session_id)) {
        if ($count_courses) {
            $title = '<img src="' . api_get_path(WEB_IMG_PATH) . 'course.gif"> ' . get_lang('Courses') . ' (' . $count_courses . ') ';
        }
    } else {
        //If we are in Course Session
        $session_name = api_get_session_name($session_id);
        $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL) . ' ' . $session_name;
        $menu_items[] = '<a href="' . api_get_self() . '?view=teacher">' . get_lang('TeacherInterface') . '</a>';
    }
}
if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array('teacher', 'drh'))) {
    //Courses
    if ($count_courses) {
        echo Display::page_subheader($title);
        $data = MySpace::get_course_data(null, null, null, null, $courses, $csv_content, $charset);
        $table = new SortableTable('courses_my_space', 'get_number_of_courses');
        $parameters['view'] = 'teacher';
        $parameters['class'] = 'data_table';
        $table->set_additional_parameters($parameters);
        $table->set_header(0, get_lang('CourseTitle'), false);
        $table->set_header(1, get_lang('NbStudents'), false);
        $table->set_header(2, get_lang('AvgTimeSpentInTheCourse') . ' ' . Display::return_icon('info3.gif', get_lang('TimeOfActiveByTraining'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(3, get_lang('AvgStudentsProgress') . ' ' . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(4, get_lang('AvgCourseScore') . ' ' . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(5, get_lang('AvgExercisesScore') . ' ' . Display::return_icon('info3.gif', get_lang('AvgAllUsersInAllCourses'), array('align' => 'absmiddle', 'hspace' => '3px')), false);
        $table->set_header(6, get_lang('AvgMessages'), false);
Пример #15
0
 /**
  * Add a "Videocast" entry to the main menu under conditions
  *
  * @param string $content
  *
  * @return string|false String if the content has been altered, FALSE otherwise
  */
 protected function injectMainMenuEntry($content)
 {
     global $this_section;
     // The user must be authenticated
     if (!api_get_user_id()) {
         return false;
     }
     // The user must be able to create courses to access its briefcase
     if (!api_is_allowed_to_create_course() and !api_is_session_admin()) {
         return false;
     }
     return preg_replace('/(<ul id="dokeostabs">.+)<\\/ul>/m', sprintf('${1}<a href="%s" target="_top"><li class="tab_libcast%s"><div><span>Videocast</span></div></li></a></ul>', $this->getHomeUrl() . '/briefcase.php', $this_section == 'libcast' ? '_current' : ''), $content);
 }
Пример #16
0
 /**
  * Returns links to teachers tools (create course, etc) based on the user
  * in the active session
  * @return string HTML <div> block
  * @assert () == ''
  */
 public function return_teacher_link()
 {
     $user_id = api_get_user_id();
     if (!empty($user_id)) {
         // tabs that are deactivated are added here
         $show_menu = false;
         $show_create_link = false;
         $show_course_link = false;
         if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
             $show_menu = true;
             $show_course_link = true;
         } else {
             if (api_get_setting('allow_students_to_browse_courses') == 'true') {
                 $show_menu = true;
                 $show_course_link = true;
             }
         }
         if ($show_menu && ($show_create_link || $show_course_link)) {
             $show_menu = true;
         } else {
             $show_menu = false;
         }
     }
     // My Account section
     $elements = array();
     if ($show_menu) {
         if ($show_create_link) {
             $elements[] = array('href' => api_get_path(WEB_CODE_PATH) . 'create_course/add_course.php', 'title' => api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate'));
         }
         if ($show_course_link) {
             if (!api_is_drh() && !api_is_session_admin()) {
                 $elements[] = array('href' => api_get_path(WEB_CODE_PATH) . 'auth/courses.php', 'title' => get_lang('CourseCatalog'));
             } else {
                 $elements[] = array('href' => api_get_path(WEB_CODE_PATH) . 'dashboard/index.php', 'title' => get_lang('Dashboard'));
             }
         }
     }
     $this->show_right_block(get_lang('Courses'), $elements, 'teacher_block');
 }
Пример #17
0
 /**
  * @Route("/add_course", name="add_course")
  * @Method({"GET|POST"})
  * @Security("has_role('ROLE_USER')")
  *
  * @return Response
  */
 public function addCourseAction()
 {
     // "Course validation" feature. This value affects the way of a new course creation:
     // true  - the new course is requested only and it is created after approval;
     // false - the new course is created immediately, after filling this form.
     $courseValidation = false;
     if (api_get_setting('course.course_validation') == 'true' && !api_is_platform_admin()) {
         $courseValidation = true;
     }
     // Displaying the header.
     $tool_name = $courseValidation ? get_lang('CreateCourseRequest') : get_lang('CreateSite');
     if (api_get_setting('course.allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) {
         api_not_allowed(true);
     }
     // Check access rights.
     if (!api_is_allowed_to_create_course()) {
         api_not_allowed(true);
     }
     $url = $this->generateUrl('add_course');
     // Build the form.
     $form = new \FormValidator('add_course', 'post', $url);
     // Form title
     $form->addElement('header', $tool_name);
     // Title
     $form->addElement('text', 'title', array(get_lang('CourseName'), get_lang('Ex')), array('id' => 'title'));
     $form->applyFilter('title', 'html_filter');
     $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
     $form->addButtonAdvancedSettings('advanced_params');
     $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
     // Category category.
     $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
     $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url));
     // Course code
     $form->addText('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('maxlength' => \CourseManager::MAX_COURSE_LENGTH_CODE, 'pattern' => '[a-zA-Z0-9]+', 'title' => get_lang('OnlyLettersAndNumbers')));
     $form->applyFilter('wanted_code', 'html_filter');
     $form->addRule('wanted_code', get_lang('Max'), 'maxlength', \CourseManager::MAX_COURSE_LENGTH_CODE);
     // The teacher
     //array(get_lang('Professor'), null), null, array('size' => '60', 'disabled' => 'disabled'));
     $titular =& $form->addElement('hidden', 'tutor_name', '');
     if ($courseValidation) {
         // Description of the requested course.
         $form->addElement('textarea', 'description', get_lang('Description'), array('rows' => '3'));
         // Objectives of the requested course.
         $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('rows' => '3'));
         // Target audience of the requested course.
         $form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('rows' => '3'));
     }
     // Course language.
     $form->addElement('select_language', 'course_language', get_lang('Ln'), array(), array('style' => 'width:150px'));
     $form->applyFilter('select_language', 'html_filter');
     // Exemplary content checkbox.
     $form->addElement('checkbox', 'exemplary_content', null, get_lang('FillWithExemplaryContent'));
     if ($courseValidation) {
         // A special URL to terms and conditions that is set
         // in the platform settings page.
         $terms_and_conditions_url = trim(api_get_setting('course_validation_terms_and_conditions_url'));
         // If the special setting is empty,
         // then we may get the URL from Chamilo's module "Terms and conditions",
         // if it is activated.
         if (empty($terms_and_conditions_url)) {
             if (api_get_setting('registration.allow_terms_conditions') == 'true') {
                 $terms_and_conditions_url = api_get_path(WEB_CODE_PATH);
                 $terms_and_conditions_url .= 'auth/inscription.php?legal';
             }
         }
         if (!empty($terms_and_conditions_url)) {
             // Terms and conditions to be accepted before sending a course request.
             $form->addElement('checkbox', 'legal', null, get_lang('IAcceptTermsAndConditions'), 1);
             $form->addRule('legal', get_lang('YouHaveToAcceptTermsAndConditions'), 'required');
             // Link to terms and conditions.
             $link_terms_and_conditions = '
                 <script>
                 function MM_openBrWindow(theURL, winName, features) { //v2.0
                     window.open(theURL,winName,features);
                 }
                 </script>
             ';
             $link_terms_and_conditions .= \Display::url(get_lang('ReadTermsAndConditions'), '#', ['onclick' => "javascript:MM_openBrWindow('{$terms_and_conditions_url}', 'Conditions', 'scrollbars=yes, width=800');"]);
             $form->addElement('label', null, $link_terms_and_conditions);
         }
     }
     $obj = new \GradeModel();
     $obj->fill_grade_model_select_in_form($form);
     $form->addElement('html', '</div>');
     // Submit button.
     $form->addButtonCreate($courseValidation ? get_lang('CreateThisCourseRequest') : get_lang('CreateCourseArea'));
     // Set default values.
     if (isset($_user['language']) && $_user['language'] != '') {
         $values['course_language'] = $_user['language'];
     } else {
         $values['course_language'] = api_get_setting('language.platform_language');
     }
     $form->setDefaults($values);
     $message = null;
     $content = null;
     // Validate the form.
     if ($form->validate()) {
         $course_values = $form->exportValues();
         $wanted_code = $course_values['wanted_code'];
         //$category_code = $course_values['category_code'];
         $category_code = '';
         $title = $course_values['title'];
         $course_language = $course_values['course_language'];
         $exemplary_content = !empty($course_values['exemplary_content']);
         if ($courseValidation) {
             $description = $course_values['description'];
             $objetives = $course_values['objetives'];
             $target_audience = $course_values['target_audience'];
         }
         if ($wanted_code == '') {
             $wanted_code = \CourseManager::generate_course_code(api_substr($title, 0, \CourseManager::MAX_COURSE_LENGTH_CODE));
         }
         // Check whether the requested course code has already been occupied.
         if (!$courseValidation) {
             $course_code_ok = !\CourseManager::course_code_exists($wanted_code);
         } else {
             $course_code_ok = !\CourseRequestManager::course_code_exists($wanted_code);
         }
         if ($course_code_ok) {
             if (!$courseValidation) {
                 $params = array();
                 $params['title'] = $title;
                 $params['exemplary_content'] = $exemplary_content;
                 $params['wanted_code'] = $wanted_code;
                 $params['course_category'] = $category_code;
                 $params['course_language'] = $course_language;
                 $params['gradebook_model_id'] = isset($course_values['gradebook_model_id']) ? $course_values['gradebook_model_id'] : null;
                 $course_info = \CourseManager::create_course($params);
                 if (!empty($course_info)) {
                     $url = api_get_path(WEB_CODE_PATH);
                     $url .= 'course_info/start.php?cidReq=';
                     $url .= $course_info['code'];
                     $url .= '&first=1';
                     header('Location: ' . $url);
                     exit;
                 } else {
                     $this->addFlash('error', $this->trans('CourseCreationFailed'));
                     // Display the form.
                     $content = $form->returnForm();
                 }
             } else {
                 // Create a request for a new course.
                 $request_id = \CourseRequestManager::create_course_request($wanted_code, $title, $description, $category_code, $course_language, $objetives, $target_audience, api_get_user_id(), $exemplary_content);
                 if ($request_id) {
                     $course_request_info = \CourseRequestManager::get_course_request_info($request_id);
                     $message = (is_array($course_request_info) ? '<strong>' . $course_request_info['code'] . '</strong> : ' : '') . get_lang('CourseRequestCreated');
                     \Display::return_message($message, 'confirmation', false);
                     \Display::return_message('div', \Display::url(get_lang('Enter'), api_get_path(WEB_PATH) . 'user_portal.php', ['class' => 'btn btn-default']), ['style' => 'float: left; margin:0px; padding: 0px;']);
                 } else {
                     \Display::return_message(get_lang('CourseRequestCreationFailed'), 'error', false);
                     // Display the form.
                     $content = $form->returnForm();
                 }
             }
         } else {
             \Display::return_message(get_lang('CourseCodeAlreadyExists'), 'error', false);
             // Display the form.
             $content = $form->returnForm();
         }
     } else {
         if (!$courseValidation) {
             $this->addFlash('warning', get_lang('Explanation'));
         }
         // Display the form.
         $content = $form->returnForm();
     }
     return $this->render('ChamiloCoreBundle:Index:userportal.html.twig', array('content' => $content));
 }
Пример #18
0
 /**
  * Gives a list of courses for the given user in the given session
  * @param integer $user_id
  * @param integer $session_id
  * @return array  list of statuses (session_id-course_code => status)
  */
 public static function get_courses_list_by_session($user_id, $session_id)
 {
     // Database Table Definitions
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
     $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
     $user_id = intval($user_id);
     $session_id = intval($session_id);
     //we filter the courses from the URL
     $join_access_url = $where_access_url = '';
     if (api_get_multiple_access_url()) {
         $urlId = api_get_current_access_url_id();
         if ($urlId != -1) {
             $tbl_url_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
             $join_access_url = " ,  {$tbl_url_session} url_rel_session ";
             $where_access_url = " AND access_url_id = {$urlId} AND url_rel_session.session_id = {$session_id} ";
         }
     }
     $personal_course_list = array();
     $courses = array();
     /* This query is very similar to the query below, but it will check the
        session_rel_course_user table if there are courses registered
        to our user or not */
     $sql = "SELECT DISTINCT\n                    c.visibility,\n                    c.id as real_id\n                FROM {$tbl_session_course_user} as scu\n                INNER JOIN {$tbl_session_course} sc\n                ON (scu.session_id = sc.session_id AND scu.c_id = sc.c_id)\n                INNER JOIN {$tableCourse} as c\n                ON (scu.c_id = c.id)\n                {$join_access_url}\n                WHERE\n                    scu.user_id = {$user_id} AND\n                    scu.session_id = {$session_id}\n                    {$where_access_url}\n                ORDER BY sc.position ASC";
     $result = Database::query($sql);
     if (Database::num_rows($result) > 0) {
         while ($result_row = Database::fetch_array($result, 'ASSOC')) {
             $result_row['status'] = 5;
             if (!in_array($result_row['real_id'], $courses)) {
                 $personal_course_list[] = $result_row;
                 $courses[] = $result_row['real_id'];
             }
         }
     }
     if (api_is_allowed_to_create_course()) {
         $sql = "SELECT DISTINCT\n                        c.visibility, c.id as real_id\n                    FROM {$tbl_session_course_user} as scu\n                    INNER JOIN {$tbl_session} as s\n                    ON (scu.session_id = s.id)\n                    INNER JOIN {$tbl_session_course} sc\n                    ON (scu.session_id = sc.session_id AND scu.c_id = sc.c_id)\n                    INNER JOIN {$tableCourse} as c\n                    ON (scu.c_id = c.id)\n                    {$join_access_url}\n                    WHERE\n                      s.id = {$session_id} AND\n                      (\n                        (scu.user_id={$user_id} AND scu.status=2) OR\n                        s.id_coach = {$user_id}\n                      )\n                    {$where_access_url}\n                    ORDER BY sc.position ASC";
         $result = Database::query($sql);
         if (Database::num_rows($result) > 0) {
             while ($result_row = Database::fetch_array($result, 'ASSOC')) {
                 $result_row['status'] = 2;
                 if (!in_array($result_row['real_id'], $courses)) {
                     $personal_course_list[] = $result_row;
                     $courses[] = $result_row['real_id'];
                 }
             }
         }
     }
     if (api_is_drh()) {
         $session_list = SessionManager::get_sessions_followed_by_drh($user_id);
         $session_list = array_keys($session_list);
         if (in_array($session_id, $session_list)) {
             $course_list = SessionManager::get_course_list_by_session_id($session_id);
             if (!empty($course_list)) {
                 foreach ($course_list as $course) {
                     $personal_course_list[] = $course;
                 }
             }
         }
     } else {
         //check if user is general coach for this session
         $s = api_get_session_info($session_id);
         if ($s['id_coach'] == $user_id) {
             $course_list = SessionManager::get_course_list_by_session_id($session_id);
             if (!empty($course_list)) {
                 foreach ($course_list as $course) {
                     if (!in_array($course['id'], $courses)) {
                         $personal_course_list[] = $course;
                     }
                 }
             }
         }
     }
     return $personal_course_list;
 }
Пример #19
0
<?php

/* For licensing terms, see /license.txt */
/**
 * Report for current courses followed by the user
 * @package chamilo.reporting
 */
$cidReset = true;
//require_once '../inc/global.inc.php';
$this_section = SECTION_TRACKING;
$filename = 'reporting.xls';
if (!api_is_allowed_to_create_course()) {
    api_not_allowed(true);
}
$user_id = api_get_user_id();
$my_courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
$array = array();
$i = 0;
$session_id = 0;
if (!empty($my_courses)) {
    foreach ($my_courses as $course) {
        $course_code = $course['code'];
        $course_id = $course['real_id'];
        $course_info = api_get_course_info($course_code);
        //Only show open courses
        if ($course_info['visibility'] == 0) {
            continue;
        }
        $teachers = CourseManager::getTeacherListFromCourse($course_id);
        $teacher_list = array();
        if (!empty($teachers)) {
Пример #20
0
 /**
  * Find evaluations by name
  * @param string $name_mask search string
  * @return array evaluation objects matching the search criterium
  * @todo can be written more efficiently using a new (but very complex) sql query
  */
 public function find_evaluations($name_mask, $selectcat)
 {
     $rootcat = Category::load($selectcat);
     $evals = $rootcat[0]->get_evaluations(api_is_allowed_to_create_course() ? null : api_get_user_id(), true);
     $foundevals = array();
     foreach ($evals as $eval) {
         if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
             $foundevals[] = $eval;
         }
     }
     return $foundevals;
 }
Пример #21
0
function return_navigation_array()
{
    $navigation = array();
    $menu_navigation = array();
    $possible_tabs = get_tabs();
    // Campus Homepage
    if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
        $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
    } else {
        $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
    }
    if (api_get_user_id() && !api_is_anonymous()) {
        // My Courses
        if (api_get_setting('show_tabs', 'my_courses') == 'true') {
            $navigation['mycourses'] = $possible_tabs['mycourses'];
        } else {
            $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
        }
        // My Profile
        if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
            $navigation['myprofile'] = $possible_tabs['myprofile'];
        } else {
            $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
        }
        // My Agenda
        if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
            $navigation['myagenda'] = $possible_tabs['myagenda'];
        } else {
            $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
        }
        // Gradebook
        if (api_get_setting('gradebook_enable') == 'true') {
            if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
                $navigation['mygradebook'] = $possible_tabs['mygradebook'];
            } else {
                $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
            }
        }
        // Reporting
        if (api_get_setting('show_tabs', 'reporting') == 'true') {
            if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
                $navigation['session_my_space'] = $possible_tabs['session_my_space'];
            } else {
                $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
            }
        } else {
            if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
                $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
            } else {
                $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
            }
        }
        // Social Networking
        if (api_get_setting('show_tabs', 'social') == 'true') {
            if (api_get_setting('allow_social_tool') == 'true') {
                $navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
            }
        } else {
            $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
        }
        // Dashboard
        if (api_get_setting('show_tabs', 'dashboard') == 'true') {
            if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
                $navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
            }
        } else {
            $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
        }
        // Administration
        if (api_is_platform_admin(true)) {
            if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
                $navigation['platform_admin'] = $possible_tabs['platform_admin'];
            } else {
                $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
            }
        }
        // Reports
        if (!empty($possible_tabs['reports'])) {
            if (api_get_setting('show_tabs', 'reports') == 'true') {
                if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
                    $navigation['reports'] = $possible_tabs['reports'];
                }
            } else {
                $menu_navigation['reports'] = $possible_tabs['reports'];
            }
        }
        // Custom tabs
        $customTabs = getCustomTabs();
        if (!empty($customTabs)) {
            foreach ($customTabs as $tab) {
                if (api_get_setting($tab['variable'], $tab['subkey']) == 'true' && isset($possible_tabs[$tab['subkey']])) {
                    $possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH) . $possible_tabs[$tab['subkey']]['url'];
                    $navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
                } else {
                    if (isset($possible_tabs[$tab['subkey']])) {
                        $possible_tabs[$tab['subkey']]['url'] = api_get_path(WEB_PATH) . $possible_tabs[$tab['subkey']]['url'];
                        $menu_navigation[$tab['subkey']] = $possible_tabs[$tab['subkey']];
                    }
                }
            }
        }
    }
    return array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs);
}
Пример #22
0
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);

if ($from == 'myspace') {
    $from_myspace = true;
    $this_section = "session_my_space";
} else {
    $this_section = SECTION_COURSES;
}

// Access restrictions.
$is_allowedToTrack =
    api_is_platform_admin() ||
    api_is_allowed_to_create_course() ||
    api_is_session_admin() ||
    api_is_drh() ||
    api_is_course_tutor() ||
    api_is_course_admin();

if (!$is_allowedToTrack) {
    api_not_allowed(true);
    exit;
}

// If the user is a HR director (drh)
if (api_is_drh()) {
    // Blocking course for drh
    if (api_drh_can_access_all_session_content()) {
        // If the drh has been configured to be allowed to see all session content, give him access to the session courses
Пример #23
0
    /**
     * Gives a list of courses for the given user in the given session
     * @param integer $user_id
     * @param integer $session_id
     * @return array  list of statuses (session_id-course_code => status)
     */
    public static function get_courses_list_by_session($user_id, $session_id)
    {
        // Database Table Definitions
        $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
        $tableCourse = Database :: get_main_table(TABLE_MAIN_COURSE);
        $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
        $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);

        $user_id = intval($user_id);
        $session_id = intval($session_id);
        //we filter the courses from the URL
        $join_access_url = $where_access_url = '';

        if (api_get_multiple_access_url()) {
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                $tbl_url_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
                $join_access_url = " ,  $tbl_url_session url_rel_session ";
                $where_access_url = " AND access_url_id = $access_url_id AND url_rel_session.session_id = $session_id ";
            }
        }

        $personal_course_list = array();
        $courses = array();

        /* This query is very similar to the above query,but it will check the
        session_rel_course_user table if there are courses registered
        to our user or not*/

        $sql = "SELECT DISTINCT
                    scu.course_code as code, c.visibility, c.id as real_id
                FROM $tbl_session_course_user as scu
                INNER JOIN $tbl_session_course sc
                ON (scu.id_session = sc.id_session AND scu.course_code = sc.course_code)
                INNER JOIN $tableCourse as c
                ON (scu.course_code = c.code)
                $join_access_url
                WHERE
                    scu.id_user = $user_id AND
                    scu.id_session = $session_id
                    $where_access_url";

        $orderBy = " ORDER BY code ";
        if (SessionManager::orderCourseIsEnabled()) {
            $orderBy =  ' ORDER BY position';
        }
        $sql .= $orderBy;

        $result = Database::query($sql);

        if (Database::num_rows($result) > 0) {
            while ($result_row = Database::fetch_array($result)) {
                $result_row['status'] = 5;
                if (!in_array($result_row['code'], $courses)) {
                    $personal_course_list[] = $result_row;
                    $courses[] = $result_row['code'];
                }
            }
        }

        if (api_is_allowed_to_create_course()) {
            $sql = "SELECT DISTINCT
                        scu.course_code as code, c.visibility, c.id as real_id
                    FROM $tbl_session_course_user as scu
                    INNER JOIN $tbl_session as s
                    ON (scu.id_session = s.id)
                    INNER JOIN $tbl_session_course sc
                    ON (scu.id_session = sc.id_session AND scu.course_code = sc.course_code)
                    INNER JOIN $tableCourse as c
                    ON (scu.course_code = c.code)
                    $join_access_url
                    WHERE
                      s.id = $session_id AND
                      (
                        (scu.id_user=$user_id AND scu.status=2) OR
                        s.id_coach = $user_id
                      )
                    $where_access_url
                    $orderBy";
            $result = Database::query($sql);

            if (Database::num_rows($result) > 0) {
                while ($result_row = Database::fetch_array($result)) {
                    $result_row['status'] = 2;
                    if (!in_array($result_row['code'], $courses)) {
                        $personal_course_list[] = $result_row;
                        $courses[] = $result_row['code'];
                    }
                }
            }
        }

        if (api_is_drh()) {
            $session_list = SessionManager::get_sessions_followed_by_drh($user_id);
            $session_list = array_keys($session_list);
            if (in_array($session_id, $session_list)) {
                $course_list = SessionManager::get_course_list_by_session_id($session_id);
                if (!empty($course_list)) {
                    foreach ($course_list as $course) {
                        $personal_course_list[] = $course;
                    }
                }
            }
        } else {
            //check if user is general coach for this session
            $s = api_get_session_info($session_id);
            if ($s['id_coach'] == $user_id) {
                $course_list = SessionManager::get_course_list_by_session_id($session_id);
                if (!empty($course_list)) {
                    foreach ($course_list as $course) {
                        if (!in_array($course['code'], $courses)) {
                            $personal_course_list[] = $course;
                        }
                    }
                }
            }
        }

        return $personal_course_list;
    }