/** * Get a list of courses (code, url, title, teacher, language) for a specific * user and return to caller * Function registered as service. Returns strings in UTF-8. * @param string User name in Chamilo * @param string Signature (composed of the sha1(username+apikey) * @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...) */ function WSCourseListOfUser($username, $signature) { if (empty($username) or empty($signature)) { return -1; } global $_configuration; $info = api_get_user_info_from_username($username); $user_id = $info['user_id']; $list = UserManager::get_api_keys($user_id, 'dokeos'); $key = ''; foreach ($list as $key) { break; } $local_key = $username . $key; if (!api_is_valid_secret_key($signature, $local_key)) { return -1; // The secret key is incorrect. } $courses_list = array(); $courses_list_tmp = CourseManager::get_courses_list_by_user_id($user_id); foreach ($courses_list_tmp as $index => $course) { $course_info = CourseManager::get_course_information($course['code']); $courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']); } return $courses_list; }
function get_user_courses() { if (!is_null($this->_get_user_courses)) { return $this->_get_user_courses; } $user_id = $this->user_id; return $this->_get_user_courses = CourseManager::get_courses_list_by_user_id($user_id); }
/** * @param integer * @return void */ function exit_of_chat($user_id) { $user_id = intval($user_id); $list_course = CourseManager::get_courses_list_by_user_id($user_id); $tbl_chat_connected = Database::get_course_table(TABLE_CHAT_CONNECTED); foreach ($list_course as $course) { $response = user_connected_in_chat($user_id); $sql = 'DELETE FROM ' . $tbl_chat_connected . ' WHERE c_id = ' . $course['real_id'] . ' AND user_id = ' . $user_id; Database::query($sql); } }
/** * Get agenda events * @param int $start * @param int $end * @param int $course_id * @param int $groupId * @param int $user_id * @param string $format * * @return array|string */ public function getEvents($start, $end, $course_id = null, $groupId = null, $user_id = 0, $format = 'json') { switch ($this->type) { case 'admin': $this->getPlatformEvents($start, $end); break; case 'course': $session_id = $this->sessionId; $courseInfo = api_get_course_info_by_id($course_id); // Session coach can see all events inside a session. if (api_is_coach()) { // Own course $this->getCourseEvents($start, $end, $courseInfo, $groupId, $session_id, $user_id); // Others $this->getSessionEvents($start, $end, api_get_session_id(), $user_id, $this->eventOtherSessionColor); } else { $this->getCourseEvents($start, $end, $courseInfo, $groupId, $session_id, $user_id); } break; case 'personal': default: $sessionFilterActive = false; if (!empty($this->sessionId)) { $sessionFilterActive = true; } if ($sessionFilterActive == false) { // Getting personal events $this->getPersonalEvents($start, $end); // Getting platform/admin events $this->getPlatformEvents($start, $end); } // Getting course events $my_course_list = array(); if (!api_is_anonymous()) { $session_list = SessionManager::get_sessions_by_user(api_get_user_id()); $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), false); } if (api_is_drh()) { if (api_drh_can_access_all_session_content()) { $session_list = array(); $sessionList = SessionManager::get_sessions_followed_by_drh(api_get_user_id(), null, null, null, true, false); if (!empty($sessionList)) { foreach ($sessionList as $sessionItem) { $sessionId = $sessionItem['id']; $courses = SessionManager::get_course_list_by_session_id($sessionId); $sessionInfo = array('session_id' => $sessionId, 'courses' => $courses); $session_list[] = $sessionInfo; } } } } if (!empty($session_list)) { foreach ($session_list as $session_item) { if ($sessionFilterActive) { if ($this->sessionId != $session_item['session_id']) { continue; } } $my_courses = $session_item['courses']; $my_session_id = $session_item['session_id']; if (!empty($my_courses)) { foreach ($my_courses as $course_item) { $courseInfo = api_get_course_info_by_id($course_item['real_id']); $this->getCourseEvents($start, $end, $courseInfo, 0, $my_session_id); } } $this->getSessionEvents($start, $end, $my_session_id, $user_id, $this->eventOtherSessionColor); } } if (!empty($my_course_list) && $sessionFilterActive == false) { foreach ($my_course_list as $courseInfoItem) { $courseInfo = api_get_course_info_by_id($courseInfoItem['real_id']); if (isset($course_id) && !empty($course_id)) { if ($courseInfo['real_id'] == $course_id) { $this->getCourseEvents($start, $end, $courseInfo); } } else { $this->getCourseEvents($start, $end, $courseInfo); } } } break; } if (!empty($this->events)) { switch ($format) { case 'json': return json_encode($this->events); break; case 'array': return $this->events; break; } } return ''; }
/** * * Get agenda events * @param int start tms * @param int end tms * @param int course id *integer* not the course code * @param int user id * */ public function get_events($start, $end, $course_id = null, $group_id = null, $user_id = 0) { switch ($this->type) { case 'admin': $this->get_platform_events($start, $end); break; case 'course': $session_id = api_get_session_id(); $course_info = api_get_course_info_by_id($course_id); $this->get_course_events($start, $end, $course_info, $group_id, $session_id, $user_id); break; case 'personal': default: //Getting personal events $this->get_personal_events($start, $end); //Getting platform/admin events $this->get_platform_events($start, $end); //Getting course events $my_course_list = array(); if (!api_is_anonymous()) { $session_list = SessionManager::get_sessions_by_user(api_get_user_id()); $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true); } if (!empty($session_list)) { foreach ($session_list as $session_item) { $my_courses = $session_item['courses']; $my_session_id = $session_item['session_id']; if (!empty($my_courses)) { foreach ($my_courses as $course_item) { $course_info = api_get_course_info_by_id($course_item['id']); $this->get_course_events($start, $end, $course_info, 0, $my_session_id); } } } } if (!empty($my_course_list)) { foreach ($my_course_list as $course_info_item) { if (isset($course_id) && !empty($course_id)) { if ($course_info_item['real_id'] == $course_id) { $this->get_course_events($start, $end, $course_info_item); } } else { $this->get_course_events($start, $end, $course_info_item); } } } break; } if (!empty($this->events)) { return json_encode($this->events); } return ''; }
/** * Return a link to go to the course, validating the visibility of the * course and the user status * @param int User ID * @param array Course details array * @param array List of courses to which the user is subscribed (if not provided, will be generated) * @return mixed 'enter' for a link to go to the course or 'register' for a link to subscribe, or false if no access */ static function get_access_link_by_user($uid, $course, $user_courses = array()) { if (empty($uid) or empty($course)) { return false; } if (empty($user_courses)) { // get the array of courses to which the user is subscribed $user_courses = CourseManager::get_courses_list_by_user_id($uid); foreach ($user_courses as $k => $v) { $user_courses[$k] = $v['real_id']; } } if (!isset($course['real_id']) && empty($course['real_id'])) { $course = api_get_course_info($course['code']); } if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) { return array(); } $is_admin = api_is_platform_admin_by_id($uid); $options = array(); // Register button if (!api_is_anonymous($uid) && ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) && $course['subscribe'] == SUBSCRIBE_ALLOWED && (!in_array($course['real_id'], $user_courses) || empty($user_courses))) { $options[] = 'register'; } // Go To Course button (only if admin, if course public or if student already subscribed) if ($is_admin || $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD && empty($course['registration_code']) || api_user_is_login($uid) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && empty($course['registration_code']) || in_array($course['real_id'], $user_courses) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) { $options[] = 'enter'; } if ($is_admin || $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD && empty($course['registration_code']) || api_user_is_login($uid) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && empty($course['registration_code']) || in_array($course['real_id'], $user_courses) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) { $options[] = 'enter'; } if ($course['visibility'] != COURSE_VISIBILITY_HIDDEN && empty($course['registration_code']) && $course['unsubscribe'] == UNSUBSCRIBE_ALLOWED && api_user_is_login($uid) && in_array($course['real_id'], $user_courses)) { $options[] = 'unsubscribe'; } return $options; }
function show_form() { global $types; global $tools; echo '<div class="formulario">'; echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket" onsubmit="return validate()" style="width:100%">'; $courses_list = CourseManager::get_courses_list_by_user_id($user_id, false, true); $select_course = '<div id="user_request" > </div>'; echo $select_course; //select status $select_tool = '<div class="row" > <div class="label2" >Herramienta:</div> <div class="formw2">'; $select_tool .= '<select style="width: 95%; " name = "tool" id="tool" >'; $status = TicketManager::get_all_tickets_status(); foreach ($tools as $tool) { $select_tool .= "<option value = '" . $tool['id'] . "' selected >" . $tool['name'] . "</option>"; } $select_tool .= "</select>"; $select_tool .= '</div></div>'; echo $select_tool; echo '<div class="row"> <div class="label2">Desde:</div> <div class="formw2"><input id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div> </div> <div class="row"> <div class="label2">Hasta</div> <div class="formw2"><input id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div> </div>'; echo '</div>'; echo '<div class="row"> <div class="label2"> </div> <div class="formw2"> <button class="save" name="report" type="submit" id="btnsubmit" disabled="disabled">Generar Reporte</button> </div> </div>'; }
} echo $navigation; $user_list = UserManager::get_user_list(array(), array(), $begin, $default); $session_list = SessionManager::get_sessions_list(array(), array('name')); $options = ''; $options .= '<option value="0">--' . get_lang('SelectASession') . '--</option>'; foreach ($session_list as $session_data) { $my_session_list[$session_data['id']] = $session_data['name']; $options .= '<option value="' . $session_data['id'] . '">' . $session_data['name'] . '</option>'; } $combinations = array(); if (!empty($user_list)) { foreach ($user_list as $user) { $user_id = $user['user_id']; $name = $user['firstname'] . ' ' . $user['lastname']; $course_list_registered = CourseManager::get_courses_list_by_user_id($user_id, true, false); $new_course_list = array(); foreach ($course_list_registered as $course_reg) { if (empty($course_reg['session_id'])) { $course_reg['session_id'] = 0; } // Recover the code for historical reasons. If it can be proven // that the code can be safely replaced by c_id in the following // PHP code, feel free to do so $courseInfo = api_get_course_info_by_id($course_reg['real_id']); $course_reg['code'] = $courseInfo['code']; $new_course_list[] = $course_reg['code'] . '_' . $course_reg['session_id']; } $course_list = get_courses_list_by_user_id_based_in_exercises($user_id); if (is_array($course_list) && !empty($course_list)) { foreach ($course_list as $my_course) {
$coaches = CourseManager::get_coachs_from_course($selectedSession, $course['id']); if ($coaches) { foreach ($coaches as $coach) { $totalTime = UserManager::getTimeSpentInCourses($coach['user_id'], $course['id'], $selectedSession, $selectedFrom, $selectedUntil); $formattedTime = api_format_time($totalTime); $timeReport->data[] = array('session' => $sessionData, 'course' => $courseData, 'coach' => array('userId' => $coach['user_id'], 'lastname' => $coach['lastname'], 'firstname' => $coach['firstname'], 'username' => $coach['username'], 'completeName' => api_get_person_name($coach['firstname'], $coach['lastname'])), 'totalTime' => $formattedTime); } } } } if (!empty($selectedTeacher)) { $withFilter = true; $teacher = api_get_user_info(); $teacherData = array('userId' => $teacher['user_id'], 'lastname' => $teacher['lastname'], 'firstname' => $teacher['firstname'], 'username' => $teacher['username'], 'completeName' => $teacher['complete_name']); $reportTitle = sprintf(get_lang('TimeReportForTeacherX'), $teacher['complete_name']); $courses = CourseManager::get_courses_list_by_user_id($selectedTeacher, false); if (!empty($courses)) { foreach ($courses as $course) { $courseInfo = api_get_course_info_by_id($course['real_id']); $totalTime = UserManager::getTimeSpentInCourses($selectedTeacher, $course['real_id'], 0, $selectedFrom, $selectedUntil); $formattedTime = api_format_time($totalTime); $timeReport->data[] = array('session' => null, 'course' => array('id' => $courseInfo['real_id'], 'name' => $courseInfo['title']), 'coach' => $teacherData, 'totalTime' => $formattedTime); } } $coursesInSession = SessionManager::getCoursesListByCourseCoach($selectedTeacher); foreach ($coursesInSession as $userCourseSubscription) { $course = $userCourseSubscription->getCourse(); $session = $userCourseSubscription->getSession(); $totalTime = UserManager::getTimeSpentInCourses($selectedTeacher, $course->getId(), $session->getId(), $selectedFrom, $selectedUntil); $formattedTime = api_format_time($totalTime); $timeReport->data[] = array('session' => ['id' => $session->getId(), 'name' => $session->getName()], 'course' => array('id' => $course->getId(), 'name' => $course->getTitle()), 'coach' => $teacherData, 'totalTime' => $formattedTime);
if (!SessionManager::isValidId($selectedSession)) { Session::write('reportErrorMessage', get_lang('NoSession')); header("Location: {$selfUrl}"); exit; } $coursesList = SessionManager::get_course_list_by_session_id($selectedSession); if (is_array($coursesList)) { foreach ($coursesList as &$course) { $course['real_id'] = $course['id']; } } } else { if (api_is_student_boss()) { $coursesList = CourseManager::getCoursesFollowedByGroupAdmin($userId); } else { $coursesList = CourseManager::get_courses_list_by_user_id($userId, false, true); if (is_array($coursesList)) { foreach ($coursesList as &$course) { $courseInfo = api_get_course_info_by_id($course['real_id']); $course = array_merge($course, $courseInfo); } } } } foreach ($coursesList as $course) { if (isset($course['real_id'])) { $courses[$course['real_id']] = $course['title']; } else { $courses[$course['id']] = $course['title']; } }
function show_form_send_ticket() { global $types, $plugin; echo '<div class="divTicket">'; echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket" onsubmit="return validate()" style="width:100%">'; echo '<input name="user_id_request" id="user_id_request" type="hidden" value="">'; // Category $select_types = '<div class="row"> <div class="label2">' . get_lang('Category') . ': </div> <div class="formw2">'; $select_types .= '<select style="width: 95%; " name = "category_id" id="category_id" onChange="changeType();">'; $select_types .= '<option value="0">---' . get_lang('Select') . '---</option>'; foreach ($types as $type) { $select_types .= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . ": <br/>" . $type['description'] . "</option>"; } $select_types .= "</select>"; $select_types .= '</div></div>'; echo $select_types; // Course $courses_list = CourseManager::get_courses_list_by_user_id($user_id, false, true); $select_course = '<div id="user_request" > </div>'; echo $select_course; // Status $status = array(); $status[NEWTCK] = $plugin->get_lang('StsNew'); $status[PENDING] = $plugin->get_lang('StsPending'); $status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed'); $status[CLOSE] = $plugin->get_lang('StsClose'); $status[REENVIADO] = $plugin->get_lang('StsReenviado'); $select_status = ' <div class="row" > <div class="label2" >' . get_lang('Status') . ': </div> <div class="formw2"> <select style="width: 95%; " name = "status_id" id="status_id">'; //$status = TicketManager::get_all_tickets_status(); foreach ($status as $sts_key => $sts_name) { if ($sts_key == 'PND') { $select_status .= "<option value = '" . $sts_key . "' selected >" . $sts_name . "</option>"; } else { $select_status .= "<option value = '" . $sts_key . "'>" . $sts_name . "</option>"; } } $select_status .= ' </select> </div> </div>'; echo $select_status; // Source $source = array(); $source[SRC_EMAIL] = $plugin->get_lang('SrcEmail'); $source[SRC_PHONE] = $plugin->get_lang('SrcPhone'); $source[SRC_PRESC] = $plugin->get_lang('SrcPresential'); $select_source = ' <div class="row"> <div class="label2">' . $plugin->get_lang('Source') . ':</div> <div class="formw2"> <select style="width: 95%; " name="source_id" id="source_id" >'; foreach ($source as $src_key => $src_name) { $select_source .= "<option value = '" . $src_key . "'>" . $src_name . "</option>"; } $select_source .= ' </select> </div> </div>'; echo $select_source; // Subject echo '<div class="row" ><div class ="label2">' . get_lang('Subject') . ':</div> <div class="formw2"><input type = "text" id ="subject" name="subject" value="" required ="" style="width:94%"/></div> </div>'; // Email echo '<div class="row" id="divEmail" ><div class ="label2">' . $plugin->get_lang('PersonalEmail') . ':</div> <div class="formw2"><input type = "email" id ="personal_email" name="personal_email" value="" style="width:94%"/></div> </div>'; echo '<input name="project_id" id="project_id" type="hidden" value="">'; echo '<input name="other_area" id="other_area" type="hidden" value="">'; echo '<input name="email" id="email" type="hidden" value="">'; // Message echo '<div class="row"> <div class="label2">' . get_lang('Message') . '</div> <div class="formw2"> <input type="hidden" id="content" name="content" value="" style="display:none"> <input type="hidden" id="content___Config" value="ToolbarSet=Messages&Width=95%25&Height=250&ToolbarSets={ %22Messages%22: [ [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [ ] }&LoadPlugin=[%22customizations%22]&EditorAreaStyles=body { background: #ffffff; }&ToolbarStartExpanded=false&CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&EditorAreaCSS=/main/css/chamilo/default.css&ToolbarComboPreviewCSS=/main/css/chamilo/default.css&DefaultLanguage=es&ContentLangDirection=ltr&AdvancedFileManager=true&BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&&UserIsCourseAdmin=true&UserIsPlatformAdmin=true" style="display:none"> <iframe id="content___Frame" src="/main/inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;"> </iframe> </div> </div>'; // Phone echo '<div class="row" ><div class ="label2">' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):</div> <div class="formw2"><input type = "text" id ="phone" name="phone" value="" onkeyup="valid(this,' . "'allowspace'" . ')" onblur="valid(this,' . "'allowspace'" . ')" style="width:94%"/></div> </div>'; // Priority $select_priority = '<div class="row" > <div class="label2" >' . $plugin->get_lang('Priority') . ': </div> <div class="formw2">'; $priority = array(); $priority[NORMAL] = $plugin->get_lang('PriorityNormal'); $priority[HIGH] = $plugin->get_lang('PriorityHigh'); $priority[LOW] = $plugin->get_lang('PriorityLow'); $select_priority .= '<select style="width: 85px; " name = "priority_id" id="priority_id">'; foreach ($priority as $prty_key => $prty_name) { if ($sts_key == NORMAL) { $select_priority .= "<option value = '" . $prty_key . "' selected >" . $prty_name . "</option>"; } else { $select_priority .= "<option value = '" . $prty_key . "'>" . $prty_name . "</option>"; } } $select_priority .= "</select>"; $select_priority .= '</div></div>'; echo $select_priority; // Input file attach echo '<div class="row"> <div class="label2">' . get_lang('FilesAttachment') . '</div> <div class="formw2"> <span id="filepaths"> <div id="filepath_1"> <input type="file" name="attach_1" id="attach_1" size="20" style="width:94%;"/> </div></span> </div> </div>'; echo '<div class="row"> <div class="formw2"> <span id="link-more-attach"> <a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ') </div> </div>'; echo '<div class="row"> <div class="label2"> </div> <div class="formw2"><button class="save" name="compose" type="submit" id="btnsubmit">' . get_lang('SendMessage') . '</button> </div> </div>'; echo '</form></div>'; }
$end = isset($_REQUEST['end']) ? api_strtotime($_REQUEST['end']) : null; if ($type == 'personal' && !empty($sessionId)) { $agenda->setSessionId($sessionId); } $events = $agenda->getEvents($start, $end, api_get_course_int_id(), $groupId, $userId); echo $events; break; case 'get_user_agenda': //Used in the admin user list api_protect_admin_script(); if (api_is_allowed_to_edit(null, true)) { //@todo move this in the agenda class $DaysShort = api_get_week_days_short(); $MonthsLong = api_get_months_long(); $user_id = intval($_REQUEST['user_id']); $my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true); if (!is_array($my_course_list)) { // this is for the special case if the user has no courses (otherwise you get an error) $my_course_list = array(); } $today = getdate(); $year = !empty($_GET['year']) ? (int) $_GET['year'] : null; if ($year == null) { $year = $today['year']; } $month = !empty($_GET['month']) ? (int) $_GET['month'] : null; if ($month == null) { $month = $today['mon']; } $day = !empty($_GET['day']) ? (int) $_GET['day'] : null; if ($day == null) {
/** * * @global array $types * @global object $plugin */ function show_form_send_ticket() { global $types, $plugin; $courses_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), false, true); echo '<div class="divTicket">'; echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket" onsubmit="return validate()" style="width:100%">'; $select_types = '<div class="row"> <div class="label2">' . get_lang('Category') . ': </div> <div class="formw2">'; $select_types .= '<select style="width: 95%; " name = "category_id" id="category_id" onChange="changeType();">'; $select_types .= '<option value="0">---' . get_lang('Select') . '---</option>'; foreach ($types as $type) { $select_types.= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . ": <br/>" . $type['description'] . "</option>"; } $select_types .= "</select>"; $select_types .= '</div></div>'; echo $select_types; $select_course = '<div class="row" id="divCourse" > <div class="label2" >' . get_lang('Course') . ':</div> <div class="formw2">'; $select_course .= '<select class="chzn-select" name = "course_id" id="course_id" style="width: 40%; display:none;">'; $select_course .= '<option value="0">---' . get_lang('Select') . '---</option>'; foreach ($courses_list as $course) { $select_course.= "<option value = '" . $course['course_id'] . "'>" . $course['title'] . "</option>"; } $select_course .= "</select>"; $select_course .= '</div></div>'; echo $select_course; echo '<div class="row" ><div class ="label2">' . get_lang('Subject') . ':</div> <div class="formw2"><input type = "text" id ="subject" name="subject" value="" required ="" style="width:94%"/></div> </div>'; echo '<div class="row" id="divEmail" ><div class ="label2">' . $plugin->get_lang('PersonalEmail') . ':</div> <div class="formw2"><input type = "email" id ="personal_email" name="personal_email" value="" style="width:94%"/></div> </div>'; echo '<input name="project_id" id="project_id" type="hidden" value="">'; echo '<input name="other_area" id="other_area" type="hidden" value="">'; echo '<input name="email" id="email" type="hidden" value="">'; echo '<div class="row"> <div class="label2">' . get_lang('Message') . '</div> <div class="formw2"> <input type="hidden" id="content" name="content" value="" style="display:none"> <input type="hidden" id="content___Config" value="ToolbarSet=Messages&Width=95%25&Height=250&ToolbarSets={ %22Messages%22: [ [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [ ] }&LoadPlugin=[%22customizations%22]&EditorAreaStyles=body { background: #ffffff; }&ToolbarStartExpanded=false&CustomConfigurationsPath='.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/myconfig.js&EditorAreaCSS='.api_get_path(WEB_PATH).'main/css/chamilo/default.css&ToolbarComboPreviewCSS='.api_get_path(WEB_CODE_PATH).'css/chamilo/default.css&DefaultLanguage=es&ContentLangDirection=ltr&AdvancedFileManager=true&BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&&UserIsCourseAdmin=true&UserIsPlatformAdmin=true" style="display:none"> <iframe id="content___Frame" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;"> </iframe> </div> </div>'; echo '<div class="row" ><div class ="label2">' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):</div> <div class="formw2"><input type = "text" id ="phone" name="phone" value="" onkeyup="valid(this,' . "'allowspace'" . ')" onblur="valid(this,' . "'allowspace'" . ')" style="width:94%"/></div> </div>'; echo '<div class="row"> <div class="label2">' . get_lang('FilesAttachment') . '</div> <div class="formw2"> <span id="filepaths"> <div id="filepath_1"> <input type="file" name="attach_1" id="attach_1" size="20" style="width:94%;"/> </div></span> </div> </div>'; echo '<div class="row"> <div class="formw2"> <span id="link-more-attach"> <a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ') </div> </div>'; echo '<div class="row"> <div class="label2"> </div> <div class="formw2"><button class="save" name="compose" type="submit" id="btnsubmit">' . get_lang('SendMessage') . '</button> </div> </div>'; echo '</form></div>'; }
// 5. edit personal agenda if (!empty($_GET['action']) && $_GET['action'] == 'edit_personal_agenda_item' and !$_POST['Submit']) { $process = "edit_personal_agenda_item"; } if (!empty($_GET['action']) && $_GET['action'] == 'edit_personal_agenda_item' and $_POST['Submit']) { $process = "store_personal_agenda_item"; } // 6. delete personal agenda if (!empty($_GET['action']) && $_GET['action'] == "delete" and $_GET['id']) { $process = "delete_personal_agenda_item"; } // OUTPUT if (isset($_user['user_id'])) { // getting all the courses that this user is subscribed to //$courses_dbs = get_all_courses_of_user(); $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true); if (!is_array($my_course_list)) { // this is for the special case if the user has no courses (otherwise you get an error) $my_course_list = array(); } // setting and/or getting the year, month, day, week $today = getdate(); $year = !empty($_GET['year']) ? (int) $_GET['year'] : NULL; if ($year == NULL) { $year = $today['year']; } $month = !empty($_GET['month']) ? (int) $_GET['month'] : NULL; if ($month == NULL) { $month = $today['mon']; } $day = !empty($_GET['day']) ? (int) $_GET['day'] : NULL;
switch ($action) { case 'add_course_vote': $course_id = intval($_REQUEST['course_id']); $star = intval($_REQUEST['star']); if (!api_is_anonymous()) { CourseManager::add_course_vote($user_id, $star, $course_id, 0); } $point_info = CourseManager::get_course_ranking($course_id, 0); $ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote'; $rating = Display::return_rating_system('star_' . $course_id, $ajax_url . '&course_id=' . $course_id, $point_info, false); echo $rating; break; case 'get_user_courses': 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)) {
/** * Get results of faults average for all courses by user * @param int $user_id * @return array results containing number of faults, total done attendance, * percentage of faults and color depend on result (red, orange) */ public function get_faults_average_inside_courses($user_id) { // get all courses of current user $courses = CourseManager::get_courses_list_by_user_id($user_id, true); $user_id = intval($user_id); $results = array(); $total_faults = $total_weight = $porcent = 0; foreach ($courses as $course) { //$course_code = $course['code']; //$course_info = api_get_course_info($course_code); $course_id = $course['real_id']; $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $attendances_by_course = $this->get_attendances_list($course_id); foreach ($attendances_by_course as $attendance) { // get total faults and total weight $total_done_attendance = $attendance['attendance_qualify_max']; $sql = "SELECT score\n\t\t\t\t\t\tFROM {$tbl_attendance_result}\n WHERE\n \tc_id = {$course_id} AND\n \tuser_id = {$user_id} AND\n \tattendance_id = " . $attendance['id']; $rs = Database::query($sql); $score = 0; if (Database::num_rows($rs) > 0) { $row = Database::fetch_array($rs); $score = $row['score']; } $faults = $total_done_attendance - $score; $faults = $faults > 0 ? $faults : 0; $total_faults += $faults; $total_weight += $total_done_attendance; } } $porcent = $total_weight > 0 ? round($total_faults * 100 / $total_weight, 0) : 0; $results['faults'] = $total_faults; $results['total'] = $total_weight; $results['porcent'] = $porcent; return $results; }
/** * UserPortal view for session, return the HTLK of the course list * @param $user_id * @return string */ public function returnCoursesAndSessionsViewBySession($user_id) { $sessionCount = 0; $courseCount = 0; $load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false; if ($load_history) { //Load sessions in category in *history* $session_categories = UserManager::get_sessions_by_category($user_id, true); } else { //Load sessions in category $session_categories = UserManager::get_sessions_by_category($user_id, false); } $html = ''; //Showing history title if ($load_history) { $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); if (empty($session_categories)) { $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); } } $specialCourses = ''; $loadDirs = $this->load_directories_preview; // If we're not in the history view... $listCoursesInfo = array(); if (!isset($_GET['history'])) { // Display special courses $specialCoursesResult = CourseManager::display_special_courses($user_id, $loadDirs); $specialCourses = $specialCoursesResult['html']; // Display courses // [code=>xxx, real_id=>000] $listCourses = CourseManager::get_courses_list_by_user_id($user_id, false); foreach ($listCourses as $i => $listCourseCodeId) { list($userCategoryId, $userCatTitle) = CourseManager::getUserCourseCategoryForCourse($user_id, $listCourseCodeId['real_id']); $listCourse = api_get_course_info_by_id($listCourseCodeId['real_id']); $listCoursesInfo[] = array('course' => $listCourse, 'code' => $listCourseCodeId['code'], 'id' => $listCourseCodeId['real_id'], 'title' => $listCourse['title'], 'userCatId' => $userCategoryId, 'userCatTitle' => $userCatTitle); $courseCount++; } usort($listCoursesInfo, 'self::compareByCourse'); } if (is_array($session_categories)) { // all courses that are in a session $listCoursesInSession = SessionManager::getNamedSessionCourseForCoach($user_id); } // we got all courses // for each user category, sorted alphabetically, display courses $listUserCategories = CourseManager::get_user_course_categories($user_id); $listCoursesAlreadyDisplayed = array(); uasort($listUserCategories, "self::compareListUserCategory"); $listUserCategories[0] = ''; $html = '<div class="session-view-block">'; foreach ($listUserCategories as $userCategoryId => $userCatTitle) { // add user category $userCategoryHtml = ''; if ($userCategoryId != 0) { $userCategoryHtml = '<div class="session-view-well ">'; } $userCategoryHtml .= self::getHtmlForUserCategory($userCategoryId, $userCatTitle); // look for course in this userCat in session courses : $listCoursesInSession $htmlCategory = ''; if (isset($listCoursesInSession[$userCategoryId])) { // list of courses in this user cat foreach ($listCoursesInSession[$userCategoryId]['courseInUserCatList'] as $i => $listCourse) { // add course $listCoursesAlreadyDisplayed[$listCourse['courseId']] = 1; if ($userCategoryId == 0) { $htmlCategory .= '<div class="session-view-well session-view-row well" >'; } else { $htmlCategory .= '<div class="session-view-row" >'; } $coursesInfo = $listCourse['course']; $htmlCategory .= self::getHtmlForCourse($coursesInfo, $userCategoryId, 1, $loadDirs); // list of session category $htmlSessionCategory = '<div class="session-view-row" style="display:none;" id="courseblock-' . $coursesInfo['real_id'] . '">'; foreach ($listCourse['sessionCatList'] as $j => $listCategorySession) { // add session category $htmlSessionCategory .= self::getHtmlSessionCategory($listCategorySession['catSessionId'], $listCategorySession['catSessionName']); // list of session $htmlSession = ''; // start foreach ($listCategorySession['sessionList'] as $k => $listSession) { // add session $htmlSession .= '<div class="session-view-row">'; $htmlSession .= self::getHtmlForSession($listSession['sessionId'], $listSession['sessionName'], $listCategorySession['catSessionId'], $coursesInfo); $htmlSession .= '</div>'; $sessionCount++; } $htmlSession .= ''; // end session block $htmlSessionCategory .= $htmlSession; } $htmlSessionCategory .= '</div>'; // end session cat block $htmlCategory .= $htmlSessionCategory . '</div>'; $htmlCategory .= ''; // end course block } $userCategoryHtml .= $htmlCategory; } // look for courses in this userCat in not in session courses : $listCoursesInfo // if course not already added $htmlCategory = ''; foreach ($listCoursesInfo as $i => $listCourse) { if ($listCourse['userCatId'] == $userCategoryId && !isset($listCoursesAlreadyDisplayed[$listCourse['id']])) { if ($userCategoryId != 0) { $htmlCategory .= '<div class="session-view-row" >'; } else { $htmlCategory .= '<div class="session-view-well well">'; } $htmlCategory .= self::getHtmlForCourse($listCourse['course'], $userCategoryId, 0, $loadDirs); $htmlCategory .= '</div>'; } } $htmlCategory .= ''; $userCategoryHtml .= $htmlCategory; // end user cat block if ($userCategoryId != 0) { $userCategoryHtml .= '</div>'; } $html .= $userCategoryHtml; // } $html .= '</div>'; return ['html' => $html . $specialCourses, 'session_count' => $sessionCount, 'course_count' => $courseCount]; }
$courseCodeList = array_merge($courseCodeList, array_column($courses, 'code')); } } $searchByGroups = true; } if ($searchByGroups) { $userGroup = new UserGroup(); $userIdList = array_merge($userIdList, $userGroup->getGroupUsersByUser(api_get_user_id())); } if (is_array($userIdList)) { $userIdList = array_unique($userIdList); } if (api_is_student_boss()) { $userCourses = []; foreach ($userIdList as $userId) { $userCourses = array_merge($userCourses, CourseManager::get_courses_list_by_user_id($userId, true)); $userSessions = SessionManager::getSessionsFollowedByUser($userId); $sessionIdList = array_merge($sessionIdList, array_column($userSessions, 'id')); } $courseCodeList = array_column($userCourses, 'code'); } if (!empty($courseCodeList)) { $courseCodeList = array_unique($courseCodeList); } if (!empty($sessionIdList)) { $sessionIdList = array_unique($sessionIdList); } if (api_is_student_boss() && empty($userIdList)) { $count = 0; break; }
* @package chamilo.tracking */ $cidReset = true; require_once '../inc/global.inc.php'; $this_section = SECTION_TRACKING; $nameTools = get_lang('MyProgress'); api_block_anonymous_users(); $htmlHeadXtra[] = api_get_js('jquery.timelinr-0.9.5.js'); $htmlHeadXtra[] = ' <script language="javascript"> $(function() { $().timelinr(); }); </script>'; $user_id = api_get_user_id(); $course_user_list = CourseManager::get_courses_list_by_user_id($user_id); $dates = $issues = ''; $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; if (!empty($course_user_list)) { $items = MySpace::get_connections_from_course_list($user_id, $course_user_list); $first = null; $last = null; $last_item = count($items); $count = 1; foreach ($items as $result) { $login = $result['login']; $courseId = $result['c_id']; $courseInfo = api_get_course_info_by_id($courseId); if ($count == 1) { $first = '<a href="#' . $login . '">' . get_lang('First') . '</a>';
public function get_students_content_html_for_drh() { $attendance = new Attendance(); $students = $this->students; $content = '<div style="margin:5px;">'; $content .= '<h3><font color="#000">' . get_lang('YourStudents') . '</font></h3>'; $students_table = null; if (count($students) > 0) { $students_table .= '<table class="data_table">'; $students_table .= '<tr> <th>' . get_lang('User') . '</th> <th>' . get_lang('AttendancesFaults') . '</th> <th>' . get_lang('Evaluations') . '</th> </tr>'; $i = 1; foreach ($students as $student) { $student_id = $student['user_id']; $firstname = $student['firstname']; $lastname = $student['lastname']; $username = $student['username']; // get average of faults in attendances by student $results_faults_avg = $attendance->get_faults_average_inside_courses($student_id); if (!empty($results_faults_avg)) { $attendances_faults_avg = '<a title="' . get_lang('GoToStudentDetails') . '" href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id . '">' . $results_faults_avg['faults'] . '/' . $results_faults_avg['total'] . ' (' . $results_faults_avg['porcent'] . '%)</a>'; } else { $attendances_faults_avg = '0%'; } $courses_by_user = CourseManager::get_courses_list_by_user_id($student_id, true); $evaluations_avg = 0; $score = $weight = 0; foreach ($courses_by_user as $course) { $course_code = $course['code']; $cats = Category::load(null, null, $course_code, null, null, null, false); $scoretotal = array(); if (isset($cats) && isset($cats[0])) { $scoretotal = $cats[0]->calc_score($student_id, $course_code); } if (!empty($scoretotal)) { $score += $scoretotal[0]; $weight += $scoretotal[1]; } } if (!empty($weight)) { $evaluations_avg = '<a title="' . get_lang('GoToStudentDetails') . '" href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id . '">' . round($score, 2) . '/' . round($weight, 2) . '(' . round($score / $weight * 100, 2) . ' %)</a>'; } if ($i % 2 == 0) { $class_tr = 'row_odd'; } else { $class_tr = 'row_even'; } $students_table .= '<tr class="' . $class_tr . '"> <td>' . api_get_person_name($firstname, $lastname) . ' (' . $username . ')</td> <td>' . $attendances_faults_avg . '</td> <td>' . $evaluations_avg . '</td> </tr>'; $i++; } $students_table .= '</table>'; } else { $students_table .= get_lang('ThereIsNoInformationAboutYourStudents'); } $content .= $students_table; if (count($students) > 0) { $content .= '<div style="text-align:right;margin-top:10px;"> <a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/index.php?view=admin&display=yourstudents">' . get_lang('SeeMore') . '</a> </div>'; } $content .= '</div>'; return $content; }
/** * * Get the achieved certificates for a user in courses * @param int $userId The user id * @param type $includeNonPublicCertificates Whether include the non-plublic certificates * @return array */ public static function getUserCertificatesInCourses($userId, $includeNonPublicCertificates = true) { $userId = intval($userId); $courseList = []; $courses = CourseManager::get_courses_list_by_user_id($userId); foreach ($courses as $course) { if (!$includeNonPublicCertificates) { $allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course['code']); if (empty($allowPublicCertificates)) { continue; } } $courseGradebookCategory = Category::load(null, null, $course['code']); if (empty($courseGradebookCategory)) { continue; } $courseGradebookId = $courseGradebookCategory[0]->get_id(); $certificateInfo = GradebookUtils::get_certificate_by_user_id($courseGradebookId, $userId); if (empty($certificateInfo)) { continue; } $courseInfo = api_get_course_info_by_id($course['real_id']); $courseList[] = ['course' => $courseInfo['title'], 'score' => $certificateInfo['score_certificate'], 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}"]; } return $courseList; }