function search_courses($needle, $type)
{
    global $tbl_course, $tbl_course_rel_access_url, $user_id;
    $xajax_response = new xajaxResponse();
    $return = '';
    if (!empty($needle) && !empty($type)) {
        // xajax send utf8 datas... datas in db can be non-utf8 datas
        $needle = Database::escape_string($needle);
        $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id);
        $assigned_courses_code = array_keys($assigned_courses_to_hrm);
        foreach ($assigned_courses_code as &$value) {
            $value = "'" . $value . "'";
        }
        $without_assigned_courses = '';
        if (count($assigned_courses_code) > 0) {
            $without_assigned_courses = " AND c.code NOT IN(" . implode(',', $assigned_courses_code) . ")";
        }
        if (api_is_multiple_url_enabled()) {
            $sql = "SELECT c.code, c.title\n                    FROM {$tbl_course} c\n\t\t\t\t\tLEFT JOIN {$tbl_course_rel_access_url} a\n                    ON (a.c_id = c.id)\n                \tWHERE\n                \t\tc.code LIKE '{$needle}%' {$without_assigned_courses} AND\n                \t\taccess_url_id = " . api_get_current_access_url_id();
        } else {
            $sql = "SELECT c.code, c.title\n            \t\tFROM {$tbl_course} c\n                \tWHERE\n                \t\tc.code LIKE '{$needle}%'\n                \t\t{$without_assigned_courses} ";
        }
        $rs = Database::query($sql);
        $return .= '<select id="origin" name="NoAssignedCoursesList[]" multiple="multiple" size="20" style="width:340px;">';
        while ($course = Database::fetch_array($rs)) {
            $return .= '<option value="' . $course['code'] . '" title="' . htmlspecialchars($course['title'], ENT_QUOTES) . '">' . $course['title'] . ' (' . $course['code'] . ')</option>';
        }
        $return .= '</select>';
        $xajax_response->addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
    }
    return $xajax_response;
}
 /**
  * Constructor
  */
 public function __construct($user_id)
 {
     $this->user_id = $user_id;
     $this->path = 'block_daily';
     if ($this->is_block_visible_for_user($user_id)) {
         $this->courses = CourseManager::get_courses_followed_by_drh($user_id);
     }
 }
 /**
  * Constructor
  */
 public function __construct($user_id)
 {
     $this->user_id = $user_id;
     $this->path = 'block_course';
     if ($this->is_block_visible_for_user($user_id)) {
         /*if (api_is_platform_admin()) {
         			$this->courses = CourseManager::get_real_course_list();
         		} else  {*/
         $this->courses = CourseManager::get_courses_followed_by_drh($user_id);
         //}
     }
 }
	/**
	 * Constructor
	 */
    public function __construct($user_id)
    {
    	$this->path = 'block_evaluation_graph';
    	$this->user_id 	= $user_id;
    	$this->bg_width = 450;
    	$this->bg_height = 350;
    	if ($this->is_block_visible_for_user($user_id)) {
            if (!api_is_session_admin()) {
                $this->courses  = CourseManager::get_courses_followed_by_drh($user_id);
            }
            $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
    	}
    }
Esempio n. 5
0
        if (!empty($coursesFromSession)) {
            $coursesFromSession = array_keys($coursesFromSession);
        }

        $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
        if (!empty($coursesFollowedList)) {
            $coursesFollowedList = array_keys($coursesFollowedList);
        }
        if (!in_array($courseCode, $coursesFollowedList)) {
            if (!in_array($courseCode, $coursesFromSession)) {
                api_not_allowed();
            }
        }
    } else {
        // If the drh has *not* been configured to be allowed to see all session content, then check if he has also been given access to the corresponding courses
        $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
        $coursesFollowedList = array_keys($coursesFollowedList);
        if (!in_array(api_get_course_id(), $coursesFollowedList)) {
            api_not_allowed(true);
            exit;
        }
    }
}

// Including additional libraries.

require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/scorm.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/scormItem.class.php';
Esempio n. 6
0
        }
    }
}
Display::display_header($nameTools);
$a_courses = array();
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
    $title = '';
    if (empty($id_session)) {
        if (isset($_GET['user_id'])) {
            $user_id = intval($_GET['user_id']);
            $user_info = api_get_user_info($user_id);
            $title = get_lang('AssignedCoursesTo') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname']);
            $courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
        } else {
            $title = get_lang('YourCourseList');
            $courses = CourseManager::get_courses_followed_by_drh($_user['user_id']);
        }
    } else {
        $session_name = api_get_session_name($id_session);
        $title = api_htmlentities($session_name, ENT_QUOTES, $charset) . ' : ' . get_lang('CourseListInSession');
        $courses = Tracking::get_courses_list_from_session($id_session);
    }
    $a_courses = array_keys($courses);
    if (!api_is_session_admin()) {
        $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::url(Display::return_icon('user.png', get_lang('Students'), array(), 32), "index.php?view=drh_students&amp;display=yourstudents");
        $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), 32), 'teachers.php');
        $menu_items[] = Display::return_icon('course_na.png', get_lang('Courses'), array(), 32);
        $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php');
    }
    echo '<div class="actions">';
Esempio n. 7
0
        $avg_courses_per_student = null;
        $avg_time_spent = null;
        $nb_assignments = null;
        $nb_posts = null;
    }
} else {
    // Sessions.
    $visibility = api_get_session_visibility($session_id);
    if ($visibility == SESSION_INVISIBLE) {
        Display::display_warning_message(get_lang('NotAvailable'));
        Display::display_footer();
    }
    $courses = Tracking::get_courses_followed_by_coach($user_id, $session_id);
    //If is drh
    if ($is_drh) {
        $courses_of_the_platform = CourseManager::get_courses_followed_by_drh($user_id);
        $courses = array();
        $courses_from_session = SessionManager::get_course_list_by_session_id($session_id);
        foreach ($courses_from_session as $course_item) {
            if (isset($courses_of_the_platform[$course_item['code']])) {
                $courses[$course_item['code']] = $course_item['code'];
            }
        }
        if (empty($courses)) {
            Display::display_warning_message(get_lang('NoResults'));
        }
    }
    //Courses for the user
    $count_courses = count($courses);
    //Sessions for the user
    $count_sessions = count($sessions);
 /**
  * It's used for listing courses with categories,
  * render to courses_categories view
  * @param string   	action
  * @param string    Category code (optional)
  */
 public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null)
 {
     $data = array();
     $browse_course_categories = $this->model->browse_course_categories();
     if ($action == 'display_random_courses') {
         $data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 10);
     } else {
         if (!isset($category_code)) {
             $category_code = $browse_course_categories[0][1]['code'];
             // by default first category
         }
         $data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code);
     }
     $data['search_form'] = $this->getSearchForm();
     $data['browse_course_categories'] = $browse_course_categories;
     $data['code'] = Security::remove_XSS($category_code);
     // getting all the courses to which the user is subscribed to
     $curr_user_id = api_get_user_id();
     $user_courses = $this->model->get_courses_of_user($curr_user_id);
     $user_coursecodes = array();
     // we need only the course codes as these will be used to match against the courses of the category
     if ($user_courses != '') {
         foreach ($user_courses as $key => $value) {
             $user_coursecodes[] = $value['code'];
         }
     }
     if (api_is_drh()) {
         $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
         foreach ($courses as $course) {
             $user_coursecodes[] = $course['code'];
         }
     }
     $data['user_coursecodes'] = $user_coursecodes;
     $data['action'] = $action;
     $data['message'] = $message;
     $data['content'] = $content;
     $data['error'] = $error;
     // render to the view
     $this->view->set_data($data);
     $this->view->set_layout('layout');
     $this->view->set_template('courses_categories');
     $this->view->render();
 }
 /**
  * It's used for listing courses with categories,
  * render to courses_categories view
  * @param $action
  * @param string $category_code
  * @param string $message
  * @param string $error
  * @param string $content
  * @param array $limit will be used if $random_value is not set.
  * This array should contains 'start' and 'length' keys
  * @internal param \action $string
  * @internal param \Category $string code (optional)
  */
 public function courses_categories($action, $category_code = null, $message = '', $error = '', $content = null, $limit = array())
 {
     $data = array();
     $browse_course_categories = $this->model->browse_course_categories();
     $data['countCoursesInCategory'] = $this->model->count_courses_in_category($category_code);
     if ($action == 'display_random_courses') {
         // Random value is used instead limit filter
         $data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 10);
         $data['countCoursesInCategory'] = count($data['browse_courses_in_category']);
     } else {
         if (!isset($category_code)) {
             $category_code = $browse_course_categories[0][1]['code'];
             // by default first category
         }
         $limit = isset($limit) ? $limit : CourseCategoryManager::getLimitArray();
         $data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code, null, $limit);
     }
     $data['browse_course_categories'] = $browse_course_categories;
     $data['code'] = Security::remove_XSS($category_code);
     // getting all the courses to which the user is subscribed to
     $curr_user_id = api_get_user_id();
     $user_courses = $this->model->get_courses_of_user($curr_user_id);
     $user_coursecodes = array();
     // we need only the course codes as these will be used to match against the courses of the category
     if ($user_courses != '') {
         foreach ($user_courses as $key => $value) {
             $user_coursecodes[] = $value['code'];
         }
     }
     if (api_is_drh()) {
         $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
         foreach ($courses as $course) {
             $user_coursecodes[] = $course['code'];
         }
     }
     $data['user_coursecodes'] = $user_coursecodes;
     $data['action'] = $action;
     $data['message'] = $message;
     $data['content'] = $content;
     $data['error'] = $error;
     $data['catalogShowCoursesSessions'] = 0;
     $showCoursesSessions = intval('catalog_show_courses_sessions');
     if ($showCoursesSessions > 0) {
         $data['catalogShowCoursesSessions'] = $showCoursesSessions;
     }
     // render to the view
     $this->view->set_data($data);
     $this->view->set_layout('catalog_layout');
     $this->view->set_template('courses_categories');
     $this->view->render();
 }
Esempio n. 10
0
 /**
  * Returns an array with the hottest courses
  * @param   int number of days
  * @param   int number of hottest courses
  */
 public static function returnHotCourses($days = 30, $limit = 5)
 {
     $urlId = api_get_current_access_url_id();
     $limit = intval($limit);
     // Getting my courses
     $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id());
     $my_course_code_list = array();
     foreach ($my_course_list as $course) {
         $my_course_code_list[$course['real_id']] = $course['real_id'];
     }
     if (api_is_drh()) {
         $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
         foreach ($courses as $course) {
             $my_course_code_list[$course['real_id']] = $course['real_id'];
         }
     }
     $table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
     $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $table_course_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     //@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC
     /*
             $today                    = api_get_utc_datetime();
             $today_diff                = time() -intval($days)*24*60*60;
             $today_diff                = api_get_utc_datetime($today_diff);
              * */
     $sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility " . "FROM {$table_course} c INNER JOIN {$table_course_access} a " . "  ON (c.id = a.c_id) INNER JOIN {$table_course_url} u ON u.c_id = c.id " . "  WHERE   u.access_url_id = " . $urlId . " AND" . "          login_course_date <= now() AND " . "          login_course_date > DATE_SUB(now(), INTERVAL {$days} DAY) AND" . "          visibility <> '" . COURSE_VISIBILITY_CLOSED . "'" . "  GROUP BY a.c_id" . "  ORDER BY course_count DESC" . "  LIMIT {$limit}";
     $result = Database::query($sql);
     $courses = array();
     if (Database::num_rows($result)) {
         $courses = Database::store_result($result, 'ASSOC');
         $courses = self::process_hot_course_item($courses, $my_course_code_list);
     }
     return $courses;
 }
Esempio n. 11
0
 /**
  * Returns an array with the hottest courses
  * @param   int $days number of days
  * @param   int $limit number of hottest courses
  * @return array
  */
 public static function return_hot_courses($days = 30, $limit = 5)
 {
     global $_configuration;
     if (api_is_invitee()) {
         return array();
     }
     $limit = intval($limit);
     // Getting my courses
     $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id());
     $my_course_code_list = array();
     foreach ($my_course_list as $course) {
         $my_course_code_list[$course['real_id']] = $course['real_id'];
     }
     if (api_is_drh()) {
         $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
         foreach ($courses as $course) {
             $my_course_code_list[$course['real_id']] = $course['real_id'];
         }
     }
     $table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
     $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $table_course_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     //@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC
     /*
             $today                    = api_get_utc_datetime();
             $today_diff                = time() -intval($days)*24*60*60;
             $today_diff                = api_get_utc_datetime($today_diff);
              * */
     //WHERE login_course_date <= '$today' AND login_course_date >= '$today_diff'
     //$table_course_access table uses the now() and interval ...
     $now = api_get_utc_datetime(time());
     $sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility\n                FROM {$table_course} c\n                INNER JOIN {$table_course_access} a\n                ON (c.id = a.c_id)\n                INNER JOIN {$table_course_url} u\n                ON u.c_id = c.id\n                WHERE\n                    u.access_url_id = " . api_get_current_access_url_id() . " AND\n                    login_course_date <= '{$now}' AND\n                    login_course_date > DATE_SUB(now(), INTERVAL {$days} DAY) AND\n                    visibility <> '" . COURSE_VISIBILITY_CLOSED . "' AND visibility <> '" . COURSE_VISIBILITY_HIDDEN . "'\n                GROUP BY a.c_id\n                ORDER BY course_count DESC\n                LIMIT {$limit}\n            ";
     $result = Database::query($sql);
     $courses = array();
     if (Database::num_rows($result)) {
         $courses = Database::store_result($result, 'ASSOC');
         $courses = self::process_hot_course_item($courses, $my_course_code_list);
     }
     return $courses;
 }