Ejemplo n.º 1
0
    $nb_menu_items = count($menu_items);
    if ($nb_menu_items > 1) {
        foreach ($menu_items as $key => $item) {
            $actionsLeft .= $item;
        }
    }
    $actionsRight = '';
    if (count($a_sessions) > 0) {
        $actionsRight = Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), 32), 'javascript: void(0);', array('onclick' => 'javascript: window.print();'));
        $actionsRight .= Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self() . '?export=csv');
    }
    $toolbar = Display::toolbarAction('toolbar-session', $content = array(0 => $actionsLeft, 1 => $actionsRight));
    echo $toolbar;
    echo Display::page_header(get_lang('YourSessionsList'));
} else {
    $a_sessions = Tracking::get_sessions_coached_by_user($id_coach);
}
$form = new FormValidator('search_course', 'get', api_get_path(WEB_CODE_PATH) . 'mySpace/session.php');
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addButtonSearch(get_lang('Search'));
$keyword = '';
if ($form->validate()) {
    $keyword = $form->getSubmitValue('keyword');
}
$form->setDefaults(array('keyword' => $keyword));
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_sessions_tracking&keyword=' . Security::remove_XSS($keyword);
$columns = array(get_lang('Title'), get_lang('Date'), get_lang('NbCoursesPerSession'), get_lang('NbStudentPerSession'), get_lang('Details'));
// Column config
$columnModel = array(array('name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'), array('name' => 'date', 'index' => 'date', 'width' => '150', 'align' => 'left', 'sortable' => 'false'), array('name' => 'course_per_session', 'index' => 'course_per_session', 'width' => '150', 'sortable' => 'false'), array('name' => 'student_per_session', 'index' => 'student_per_session', 'width' => '100', 'sortable' => 'false'), array('name' => 'details', 'index' => 'details', 'width' => '100', 'sortable' => 'false'));
$extraParams = array('autowidth' => 'true', 'height' => 'auto');
$js = '<script>
Ejemplo n.º 2
0
 case 'get_hotpotatoes_exercise_results':
     $course = api_get_course_info();
     $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
     if (api_is_allowed_to_edit(null, true) || api_is_drh()) {
         $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions');
     } else {
         $columns = array('exe_date', 'score', 'actions');
     }
     $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $whereCondition);
     break;
 case 'get_sessions_tracking':
     if (api_is_drh()) {
         $sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id(), $start, $limit, false, false, false, null, $keyword, $description);
     } else {
         // Sessions for the coach
         $sessions = Tracking::get_sessions_coached_by_user(api_get_user_id(), $start, $limit, false, $keyword, $description);
     }
     $columns = array('name', 'date', 'course_per_session', 'student_per_session', 'details');
     $result = array();
     if (!empty($sessions)) {
         foreach ($sessions as $session) {
             if (api_drh_can_access_all_session_content()) {
                 $count_courses_in_session = count(SessionManager::get_course_list_by_session_id($session['id']));
             } else {
                 $count_courses_in_session = count(Tracking::get_courses_followed_by_coach($user_id, $session['id']));
             }
             $count_users_in_session = count(SessionManager::get_users_by_session($session['id'], 0));
             $session_date = array();
             if (!empty($session['access_start_date']) && $session['access_start_date'] != '0000-00-00') {
                 $session_date[] = get_lang('From') . ' ' . api_format_date($session['access_start_date'], DATE_FORMAT_SHORT);
             }
Ejemplo n.º 3
0
 /**
  * Get course list as coach
  *
  * @param int $user_id
  * @param bool $include_courses_in_sessions
  * @return array Course list
  *
  **/
 public static function get_course_list_as_coach($user_id, $include_courses_in_sessions = false)
 {
     // 1. Getting courses as teacher (No session)
     $courses_temp = CourseManager::get_course_list_of_user_as_course_admin($user_id);
     $courseList = array();
     if (!empty($courses_temp)) {
         foreach ($courses_temp as $course_item) {
             $courseList[0][$course_item['code']] = $course_item['code'];
         }
     }
     //2. Include courses in sessions
     if ($include_courses_in_sessions) {
         $sessions = Tracking::get_sessions_coached_by_user($user_id);
         if (!empty($sessions)) {
             foreach ($sessions as $session_item) {
                 $courses = Tracking::get_courses_followed_by_coach($user_id, $session_item['id']);
                 if (is_array($courses)) {
                     foreach ($courses as $course_item) {
                         $courseList[$session_item['id']][$course_item] = $course_item;
                     }
                 }
             }
         }
     }
     return $courseList;
 }
Ejemplo n.º 4
0
					GROUP BY user_id
					ORDER BY login_date ' . $tracking_direction;
                    }
                }
                $result_sessions_coach = Database::query($sql_session_coach);
                $total_no_coaches += Database::num_rows($result_sessions_coach);
                while ($coach = Database::fetch_array($result_sessions_coach)) {
                    $global_coaches[$coach['user_id']] = $coach;
                }
                $all_datas = array();
                foreach ($global_coaches as $id_coach => $coaches) {
                    $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($coaches['user_id']));
                    $last_connection = Tracking::get_last_connection_date($coaches['user_id']);
                    $nb_students = count(Tracking::get_student_followed_by_coach($coaches['user_id']));
                    $nb_courses = count(Tracking::get_courses_followed_by_coach($coaches['user_id']));
                    $nb_sessions = count(Tracking::get_sessions_coached_by_user($coaches['user_id']));
                    $table_row = array();
                    if ($is_western_name_order) {
                        $table_row[] = $coaches['firstname'];
                        $table_row[] = $coaches['lastname'];
                    } else {
                        $table_row[] = $coaches['lastname'];
                        $table_row[] = $coaches['firstname'];
                    }
                    $table_row[] = $time_on_platform;
                    $table_row[] = $last_connection;
                    $table_row[] = $nb_students;
                    $table_row[] = $nb_courses;
                    $table_row[] = $nb_sessions;
                    $table_row[] = '<a href="session.php?id_coach=' . $coaches['user_id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>';
                    $all_datas[] = $table_row;
Ejemplo n.º 5
0
    public static function display_tracking_coach_overview($export_csv)
    {
        global $charset;
        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();
        $tracking_column = isset($_GET['tracking_list_coaches_column']) ? $_GET['tracking_list_coaches_column'] : ($is_western_name_order xor $sort_by_first_name) ? 1 : 0;
        $tracking_direction = isset($_GET['tracking_list_coaches_direction']) && in_array(strtoupper($_GET['tracking_list_coaches_direction']), array('ASC', 'DESC', 'ASCENDING', 'DESCENDING', '0', '1')) ? $_GET['tracking_list_coaches_direction'] : 'DESC';
        // Prepare array for column order - when impossible, use some of user names.
        if ($is_western_name_order) {
            $order = array(0 => 'firstname', 1 => 'lastname', 2 => $sort_by_first_name ? 'firstname' : 'lastname', 3 => 'login_date', 4 => $sort_by_first_name ? 'firstname' : 'lastname', 5 => $sort_by_first_name ? 'firstname' : 'lastname');
        } else {
            $order = array(0 => 'lastname', 1 => 'firstname', 2 => $sort_by_first_name ? 'firstname' : 'lastname', 3 => 'login_date', 4 => $sort_by_first_name ? 'firstname' : 'lastname', 5 => $sort_by_first_name ? 'firstname' : 'lastname');
        }
        $table = new SortableTable('tracking_list_coaches_myspace', array('MySpace', 'count_coaches'), null, ($is_western_name_order xor $sort_by_first_name) ? 1 : 0);
        $parameters['view'] = 'admin';
        $table->set_additional_parameters($parameters);
        if ($is_western_name_order) {
            $table->set_header(0, get_lang('FirstName'), true);
            $table->set_header(1, get_lang('LastName'), true);
        } else {
            $table->set_header(0, get_lang('LastName'), true);
            $table->set_header(1, get_lang('FirstName'), true);
        }
        $table->set_header(2, get_lang('TimeSpentOnThePlatform'), false);
        $table->set_header(3, get_lang('LastConnexion'), false);
        $table->set_header(4, get_lang('NbStudents'), false);
        $table->set_header(5, get_lang('CountCours'), false);
        $table->set_header(6, get_lang('NumberOfSessions'), false);
        $table->set_header(7, get_lang('Sessions'), false);
        if ($is_western_name_order) {
            $csv_header[] = array(get_lang('FirstName', ''), get_lang('LastName', ''), get_lang('TimeSpentOnThePlatform', ''), get_lang('LastConnexion', ''), get_lang('NbStudents', ''), get_lang('CountCours', ''), get_lang('NumberOfSessions', ''));
        } else {
            $csv_header[] = array(get_lang('LastName', ''), get_lang('FirstName', ''), get_lang('TimeSpentOnThePlatform', ''), get_lang('LastConnexion', ''), get_lang('NbStudents', ''), get_lang('CountCours', ''), get_lang('NumberOfSessions', ''));
        }
        $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
        $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
        $tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
        $sqlCoachs = "SELECT DISTINCT\n                        scu.user_id as id_coach,\n                        u.id as user_id,\n                        lastname,\n                        firstname,\n                        MAX(login_date) as login_date\n                        FROM {$tbl_user} u, {$tbl_session_course_user} scu, {$tbl_track_login}\n                        WHERE\n                            scu.user_id = u.id AND scu.status=2 AND login_user_id=u.id\n                        GROUP BY user_id ";
        if (api_is_multiple_url_enabled()) {
            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                $sqlCoachs = "SELECT DISTINCT\n                                    scu.user_id as id_coach,\n                                    u.id as user_id,\n                                    lastname,\n                                    firstname,\n                                    MAX(login_date) as login_date\n                                FROM {$tbl_user} u,\n                                {$tbl_session_course_user} scu,\n                                {$tbl_track_login} ,\n                                {$tbl_session_rel_access_url} session_rel_url\n                                WHERE\n                                    scu.user_id = u.id AND\n                                    scu.status = 2 AND\n                                    login_user_id = u.id AND\n                                    access_url_id = {$access_url_id} AND\n                                    session_rel_url.session_id = scu.session_id\n                                GROUP BY u.id";
            }
        }
        if (!empty($order[$tracking_column])) {
            $sqlCoachs .= "ORDER BY " . $order[$tracking_column] . " " . $tracking_direction;
        }
        $result_coaches = Database::query($sqlCoachs);
        $total_no_coaches = Database::num_rows($result_coaches);
        $global_coaches = array();
        while ($coach = Database::fetch_array($result_coaches)) {
            $global_coaches[$coach['user_id']] = $coach;
        }
        $sql_session_coach = 'SELECT session.id_coach, u.id as user_id, lastname, firstname, MAX(login_date) as login_date
                                FROM ' . $tbl_user . ' u ,' . $tbl_sessions . ' as session,' . $tbl_track_login . '
                                WHERE id_coach = u.id AND login_user_id = u.id
                                GROUP BY u.id
                                ORDER BY login_date ' . $tracking_direction;
        if (api_is_multiple_url_enabled()) {
            $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
            $access_url_id = api_get_current_access_url_id();
            if ($access_url_id != -1) {
                $sql_session_coach = 'SELECT session.id_coach, u.id as user_id, lastname, firstname, MAX(login_date) as login_date
					FROM ' . $tbl_user . ' u ,' . $tbl_sessions . ' as session, ' . $tbl_track_login . ' , ' . $tbl_session_rel_access_url . ' as session_rel_url
					WHERE
					    id_coach = u.id AND
					    login_user_id = u.id  AND
					    access_url_id = ' . $access_url_id . ' AND
					    session_rel_url.session_id = session.id
					GROUP BY  u.id
					ORDER BY login_date ' . $tracking_direction;
            }
        }
        $result_sessions_coach = Database::query($sql_session_coach);
        $total_no_coaches += Database::num_rows($result_sessions_coach);
        while ($coach = Database::fetch_array($result_sessions_coach)) {
            $global_coaches[$coach['user_id']] = $coach;
        }
        $all_datas = array();
        foreach ($global_coaches as $id_coach => $coaches) {
            $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($coaches['user_id']));
            $last_connection = Tracking::get_last_connection_date($coaches['user_id']);
            $nb_students = count(Tracking::get_student_followed_by_coach($coaches['user_id']));
            $nb_courses = count(Tracking::get_courses_followed_by_coach($coaches['user_id']));
            $nb_sessions = count(Tracking::get_sessions_coached_by_user($coaches['user_id']));
            $table_row = array();
            if ($is_western_name_order) {
                $table_row[] = $coaches['firstname'];
                $table_row[] = $coaches['lastname'];
            } else {
                $table_row[] = $coaches['lastname'];
                $table_row[] = $coaches['firstname'];
            }
            $table_row[] = $time_on_platform;
            $table_row[] = $last_connection;
            $table_row[] = $nb_students;
            $table_row[] = $nb_courses;
            $table_row[] = $nb_sessions;
            $table_row[] = '<a href="session.php?id_coach=' . $coaches['user_id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . 'icons/22/2rightarrow.png" border="0" /></a>';
            $all_datas[] = $table_row;
            if ($is_western_name_order) {
                $csv_content[] = array(api_html_entity_decode($coaches['firstname'], ENT_QUOTES), api_html_entity_decode($coaches['lastname'], ENT_QUOTES), $time_on_platform, $last_connection, $nb_students, $nb_courses, $nb_sessions);
            } else {
                $csv_content[] = array(api_html_entity_decode($coaches['lastname'], ENT_QUOTES), api_html_entity_decode($coaches['firstname'], ENT_QUOTES), $time_on_platform, $last_connection, $nb_students, $nb_courses, $nb_sessions);
            }
        }
        if ($tracking_column != 3) {
            if ($tracking_direction == 'DESC') {
                usort($all_datas, array('MySpace', 'rsort_users'));
            } else {
                usort($all_datas, array('MySpace', 'sort_users'));
            }
        }
        if ($export_csv && $tracking_column != 3) {
            usort($csv_content, 'sort_users');
        }
        if ($export_csv) {
            $csv_content = array_merge($csv_header, $csv_content);
        }
        foreach ($all_datas as $row) {
            $table->addRow($row, 'align="right"');
        }
        $table->display();
    }
Ejemplo n.º 6
0
        default:
            break;
    }
    Security::clear_token();
}
// user info
$user_info = api_get_user_info($student_id);
$courses_in_session = array();
//See #4676
$drh_can_access_all_courses = false;
if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) {
    $drh_can_access_all_courses = true;
}
$courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
$courses_in_session_by_coach = array();
$sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
// RRHH or session admin
if (api_is_session_admin() || api_is_drh()) {
    $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
    $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
    if (!empty($session_by_session_admin)) {
        foreach ($session_by_session_admin as $session_coached_by_user) {
            $courses_followed_by_coach = Tracking::get_courses_list_from_session($session_coached_by_user['id']);
            $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
        }
    }
}
// Teacher or admin
if (!empty($sessions_coached_by_user)) {
    foreach ($sessions_coached_by_user as $session_coached_by_user) {
        $sid = intval($session_coached_by_user['id']);