public function export_kimia($id_analisis) { $this->load->model(['type_pemohon_m', 'lokasi_m', 'conto_m']); $analisis = $this->analisis_m->find($id_analisis); $conto = $this->conto_m->by_analisis($analisis->id); $analisis_parameter = $this->analisis_m->parameter($id_analisis); $pemohon = $this->pemohon_m->find($analisis->id_pemohon); $type_pemohon = $this->type_pemohon_m->find($pemohon->id_type_pemohon); $analisis->nama_lokasi = $this->lokasi_m->detail_by_kabupaten($analisis->lokasi, TRUE); if (!$this->_is_pihak_luar($pemohon->id_type_pemohon)) { $pemohon->nama_sertifikat = 'Kp. ' . $type_pemohon->nama; $pemohon->alamat = 'PSDG'; } foreach ($conto as $key => $row_conto) { $conto[$key]->detail_parameter = $this->conto_m->parameter($row_conto->id); } foreach ($analisis_parameter as $key => $row_parameter) { $parameter = $this->parameter_m->find_type_analisis_parameter($row_parameter->id_type_analisis_parameter); $metoda = $this->metoda_m->find($row_parameter->id_metoda); $analisis_parameter[$key]->nama_parameter = $parameter->nama_parameter; $analisis_parameter[$key]->metoda = !$metoda ? '' : $metoda->nama; } // Memasukkan data hasil analisis ke lembar hasil analisis $tracking = new Tracking(); if (!$tracking->isset_tracking($analisis->id, 9)) { $tracking->add_tracking($analisis->id, 9); } $data = ['analisis' => $analisis, 'conto' => $conto, 'parameter' => $analisis_parameter, 'pemohon' => $pemohon]; $this->load->view('sertifikat/excel_kimia', $data); }
/** * Id tracking 2 preparasi conto */ public function update_to_proses() { $input = $this->input->post(); $this->preparasi_m->update_to_proses($input['id']); $tracking = new Tracking(); $tracking->add_tracking($input['id_analisis'], 3); redirect('preparasi/detail/' . $input['id']); }
public function actionAvtoparkAdd($id = 0) { if (!empty($id)) { $Transport = Transport::model()->findByPk($id); if (!Yii::app()->user->checkAccess('admin') && (Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY || Yii::app()->user->getProfile()->company_id != $Transport->user->company_id) && (Yii::app()->getUser()->getProfile()->modules->avtopark != '1' || $Transport->user_id != Yii::app()->user->id)) { throw new CHttpException(403); } } else { if (!Yii::app()->user->checkAccess('admin') && Yii::app()->getUser()->getProfile()->modules->head != UserModules::DIRECTOR_COMPANY && Yii::app()->getUser()->getProfile()->modules->avtopark != '1') { throw new CHttpException(403); } $Transport = new Transport(); } if (isset($_POST['save'])) { $Transport->setAttributes($_POST['Transport'], false); if ($Transport->validate()) { $Transport->save(); $Transport->setRelations($_POST['Transport']); if (isset($_POST['photos'])) { $Transport->setPhoto($_POST['photos']); } $this->redirect('/cabinet/avtopark/'); } } $track = null; $points = []; Yii::import('application.modules.tracking.models.*'); if ($Transport->tracking_on && $Transport->tracking_password) { $points = Tracking::model()->getDataForCurrentTrack($Transport->transport_id); } $this->render('avtoparkAdd', ['Transport' => $Transport, 'points' => $points]); }
public function actionData() { $transport_id = (int) Yii::app()->request->getPost('id'); $pass = Yii::app()->request->getPost('pass', ''); $dataRequest = Yii::app()->request->getPost('data', ''); $data = json_decode($dataRequest, false); if ($transport_id && $pass && is_array($data)) { Yii::app()->getModule('cabinet'); $transport = Transport::model()->findByPk($transport_id); if (!is_null($transport)) { $tracking = Tracking::model(); $checkPass = $tracking->getPasswordForAPI($transport); if (0 == strcmp($pass, $checkPass)) { $res = $tracking->saveTrackData($transport_id, $data); echo CJSON::encode(['status' => $res ? 'success' : 'failed']); Yii::log("actionData success", "info"); } else { echo CJSON::encode(['status' => 'failed', 'data' => "wrong pass for transport_id=[{$transport_id}]"]); } } else { echo CJSON::encode(['status' => 'failed', 'data' => "Transport not found [{$transport_id}]"]); } } else { echo CJSON::encode(['status' => 'failed', 'data' => "Wrong params transport_id=[{$transport_id}],pass=[{$pass}]"]); } Yii::app()->end(); }
/** * Gets the time spent in a course by a given user * * @param string User id field name * @param string User id value * @param string Course id field name * @param string Course id value * @return array Array of results */ public function GetTimeSpentOnCourseInSession($user_id_field_name, $user_id_value, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) { $user_id = $this->getUserId($user_id_field_name, $user_id_value); if ($user_id instanceof WSError) { return $user_id; } $course_id = $this->getCourseId($course_id_field_name, $course_id_value); if ($course_id instanceof WSError) { return $course_id; } $session_id = $this->getSessionId($session_id_field_name, $session_id_value); if ($session_id instanceof WSError) { return $session_id; } return Tracking::get_time_spent_on_the_course($user_id, $course_id, $session_id); }
/** * Get the calculated progress for an user in a session * @param int $sessionId The session ID * @param int $userId The user ID * * @return float The progress */ public static function getSessionProgress($sessionId, $userId) { $courses = SessionManager::get_course_list_by_session_id($sessionId); $progress = 0; if (empty($courses)) { return 0; } foreach ($courses as $course) { $courseProgress = Tracking::get_avg_student_progress($userId, $course['code'], [], $sessionId, false, true); if ($courseProgress === false) { continue; } $progress += $courseProgress; } return round($progress / count($courses), 2); }
<?php include '../includes.php'; Tracking::track(basename(filter_input(INPUT_SERVER, 'PHP_SELF'))); User::logout(); header("Location: ../default.php");
/** * Get data for users list in sortable with pagination * @param $from * @param $number_of_items * @param $column * @param $direction * @param $includeInvitedUsers boolean Whether include the invited users * @return array */ public static function get_user_data($from, $number_of_items, $column, $direction, $includeInvitedUsers = false) { global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id; $course_code = Database::escape_string($course_code); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); // get all users data from a course for sortable with limit if (is_array($user_ids)) { $user_ids = array_map('intval', $user_ids); $condition_user = "******" . implode(',', $user_ids) . ") "; } else { $user_ids = intval($user_ids); $condition_user = "******"; } if (!empty($_GET['user_keyword'])) { $keyword = trim(Database::escape_string($_GET['user_keyword'])); $condition_user .= " AND (\n user.firstname LIKE '%" . $keyword . "%' OR\n user.lastname LIKE '%" . $keyword . "%' OR\n user.username LIKE '%" . $keyword . "%' OR\n user.email LIKE '%" . $keyword . "%'\n ) "; } $url_table = null; $url_condition = null; if (api_is_multiple_url_enabled()) { $url_table = ", " . $tbl_url_rel_user . "as url_users"; $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='{$access_url_id}'"; } $invitedUsersCondition = ''; if (!$includeInvitedUsers) { $invitedUsersCondition = " AND user.status != " . INVITEE; } $sql = "SELECT user.user_id as user_id,\n user.official_code as col0,\n user.lastname as col1,\n user.firstname as col2,\n user.username as col3\n FROM {$tbl_user} as user {$url_table}\n \t {$condition_user} {$url_condition} {$invitedUsersCondition}"; if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); $sql .= " ORDER BY col{$column} {$direction} "; $sql .= " LIMIT {$from},{$number_of_items}"; $res = Database::query($sql); $users = array(); $course_info = api_get_course_info($course_code); $total_surveys = 0; $total_exercises = ExerciseLib::get_all_exercises($course_info, $session_id, false, null, false, 3); if (empty($session_id)) { $survey_user_list = array(); $survey_list = SurveyManager::get_surveys($course_code, $session_id); $total_surveys = count($survey_list); if (!empty($survey_list)) { foreach ($survey_list as $survey) { $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $course_info['real_id']); foreach ($user_list as $user_id) { isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : ($survey_user_list[$user_id] = 1); } } } } while ($user = Database::fetch_array($res, 'ASSOC')) { $courseInfo = api_get_course_info($course_code); $courseId = $courseInfo['real_id']; $user['official_code'] = $user['col0']; $user['lastname'] = $user['col1']; $user['firstname'] = $user['col2']; $user['username'] = $user['col3']; $user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, $session_id)); $avg_student_score = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), $session_id); $avg_student_progress = Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), $session_id); if (empty($avg_student_progress)) { $avg_student_progress = 0; } $user['average_progress'] = $avg_student_progress . '%'; $total_user_exercise = Tracking::get_exercise_student_progress($total_exercises, $user['user_id'], $courseId, $session_id); $user['exercise_progress'] = $total_user_exercise; $total_user_exercise = Tracking::get_exercise_student_average_best_attempt($total_exercises, $user['user_id'], $courseId, $session_id); $user['exercise_average_best_attempt'] = $total_user_exercise; if (is_numeric($avg_student_score)) { $user['student_score'] = $avg_student_score . '%'; } else { $user['student_score'] = $avg_student_score; } $user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id); $user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id); $user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $courseId, $session_id); $user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $courseInfo, $session_id); // we need to display an additional profile field $user['additional'] = ''; if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) { if (isset($additional_user_profile_info[$user['user_id']]) && is_array($additional_user_profile_info[$user['user_id']])) { $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]); } } if (empty($session_id)) { $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) . ' / ' . $total_surveys; } $user['link'] = '<center><a href="../mySpace/myStudents.php?student=' . $user['user_id'] . '&details=true&course=' . $course_code . '&origin=tracking_course&id_session=' . $session_id . '"><img src="' . api_get_path(WEB_IMG_PATH) . 'icons/22/2rightarrow.png" border="0" /></a></center>'; // store columns in array $users $is_western_name_order = api_is_western_name_order(); $user_row = array(); $user_row[] = $user['official_code']; //0 if ($is_western_name_order) { $user_row[] = $user['firstname']; $user_row[] = $user['lastname']; } else { $user_row[] = $user['lastname']; $user_row[] = $user['firstname']; } $user_row[] = $user['username']; $user_row[] = $user['time']; $user_row[] = $user['average_progress']; $user_row[] = $user['exercise_progress']; $user_row[] = $user['exercise_average_best_attempt']; $user_row[] = $user['student_score']; $user_row[] = $user['count_assignments']; $user_row[] = $user['count_messages']; if (empty($session_id)) { $user_row[] = $user['survey']; } $user_row[] = $user['first_connection']; $user_row[] = $user['last_connection']; if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) { $user_row[] = $user['additional']; } $user_row[] = $user['link']; $users[] = $user_row; if ($export_csv) { if (empty($session_id)) { $user_row = array_map('strip_tags', $user_row); unset($user_row[14]); unset($user_row[15]); } else { $user_row = array_map('strip_tags', $user_row); unset($user_row[13]); unset($user_row[14]); } $csv_content[] = $user_row; } } return $users; }
$headerList[] = $item[0]; } $csvContent[] = array(); $csvContent[] = array(get_lang('Courses')); $csvContent[] = $headerList; $data = array(); $courseToolInformationTotal = null; while ($course = Database::fetch_object($res)) { $courseInfo = api_get_course_info_by_id($course->c_id); $courseCode = $courseInfo['code']; $courseToolInformation = null; $tools = '<a href="course_information.php?code=' . $courseCode . '">' . Display::return_icon('synthese_view.gif', get_lang('Overview')) . '</a>' . '<a href="' . $courseInfo['course_public_url'] . '">' . Display::return_icon('course_home.gif', get_lang('CourseHomepage')) . '</a>' . '<a href="course_edit.php?course_code=' . $courseCode . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>'; if ($course->status == STUDENT) { $tools .= '<a href="user_information.php?action=unsubscribe&course_code=' . $courseCode . '&user_id=' . $user['user_id'] . '">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>'; } $timeSpent = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseInfo['real_id'], 0)); $totalForumMessages = CourseManager::getCountPostInForumPerUser($user['user_id'], $course->id, 0); $row = array(Display::url($courseCode, $courseInfo['course_public_url']), $course->title, $course->status == STUDENT ? get_lang('Student') : get_lang('Teacher'), $timeSpent, $totalForumMessages, $tools); $csvContent[] = array_map('strip_tags', $row); $data[] = $row; $result = TrackingUserLogCSV::getToolInformation($user['user_id'], $courseInfo, 0); $courseToolInformationTotal .= $result['html']; $csvContent = array_merge($csvContent, $result['array']); } $courseInformation = Display::page_subheader(get_lang('Courses')); $courseInformation .= Display::return_sortable_table($header, $data, array(), array(), array('user_id' => intval($_GET['user_id']))); $courseInformation .= $courseToolInformationTotal; } else { $courseInformation = '<p>' . get_lang('NoCoursesForThisUser') . '</p>'; } /**
/** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ public function get_content_html() { $content = ''; $sessions = $this->sessions; //$content = '<div style="margin:10px;">'; $content .= '<h4>' . get_lang('YourSessionsList') . '</h4>'; if (count($sessions) > 0) { $sessions_table = '<table class="data_table" width:"95%">'; $sessions_table .= '<tr> <th >' . get_lang('Title') . '</th> <th >' . get_lang('Date') . '</th> <th width="100px">' . get_lang('NbCoursesPerSession') . '</th> </tr>'; $i = 1; foreach ($sessions as $session) { $session_id = intval($session['id']); $title = $session['name']; if ($session['access_start_date'] != '0000-00-00 00:00:00' && $session['access_end_date'] != '0000-00-00 00:00:00') { $date = get_lang('From') . ' ' . api_convert_and_format_date($session['access_start_date'], DATE_FORMAT_SHORT, date_default_timezone_get()) . ' ' . get_lang('To') . ' ' . api_convert_and_format_date($session['access_end_date'], DATE_FORMAT_SHORT, date_default_timezone_get()); } else { $date = ' - '; } $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id)); if ($i % 2 == 0) { $class_tr = 'row_odd'; } else { $class_tr = 'row_even'; } $sessions_table .= '<tr class="' . $class_tr . '"> <td>' . $title . '</td> <td align="center">' . $date . '</td> <td align="center">' . $count_courses_in_session . '</td> </tr>'; $i++; } $sessions_table .= '</table>'; $content .= $sessions_table; } else { $content .= get_lang('ThereIsNoInformationAboutYourSessions'); } if (count($sessions) > 0) { $content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/session.php">' . get_lang('SeeMore') . '</a></div>'; } //$content .= '</div>'; return $content; }
} else { $form_name = get_lang('ModifyAnnouncement'); } $form->addElement('header', $form_name); $to = []; if (empty($group_id)) { if (isset($_GET['remind_inactive'])) { $email_ann = '1'; $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'), api_get_setting('platform.site_name'), 7); $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('platform.site_name')); } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] == 'true') { // we want to remind inactive users. The $_GET['since'] parameter // determines which users have to be warned (i.e the users who have been inactive for x days or more $since = isset($_GET['since']) ? intval($_GET['since']) : 6; // getting the users who have to be reminded $to = Tracking::getInactiveStudentsInCourse(api_get_course_int_id(), $since, $sessionId); // setting the variables for the form elements: the users who need to receive the message foreach ($to as &$user) { $user = '******' . $user; } // setting the variables for the form elements: the message has to be sent by email $email_ann = '1'; // setting the variables for the form elements: the title of the email $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('platform.site_name')); // setting the variables for the form elements: the message of the email $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'), api_get_setting('platform.site_name'), $since); // when we want to remind the users who have never been active // then we have a different subject and content for the announcement if ($_GET['since'] == 'never') { $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('platform.site_name')); $content_to_modify = get_lang('YourAccountIsActiveYouCanLoginAndCheckYourCourses');
$res = Database::query($sql); //Getting the list of LPs in the new session $lp_list = new LearnpathList($user_id, $origin_course_code, $new_session_id); $flat_list = $lp_list->get_flat_list(); $list = array(); while ($row = Database::fetch_array($res, 'ASSOC')) { //Checking if the LP exist in the new session if (in_array($row['lp_id'], array_keys($flat_list))) { $list[$row['id']] = $row; } } if (!empty($list)) { foreach ($list as $id => $data) { //Getting all information of that lp_item_id $score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); $result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' => $progress); } } } //6. Agenda //calendar_event_attachment no problems no session_id $sql = "SELECT ref FROM {$TBL_ITEM_PROPERTY} WHERE tool = 'calendar_event' AND insert_user_id = {$user_id} AND c_id = {$course_id} "; $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { $id = $row['ref']; if ($update_database) { $sql = "UPDATE {$TBL_AGENDA} SET session_id = {$new_session_id} WHERE c_id = {$course_id} AND id = {$id} "; if ($debug) { var_dump($sql); }
public function actionDeletefj() { $userid = Yii::app()->session['login']['id']; $groupid = $_POST['groupid']; // groups tabel deleting $groups = Group::model()->findByAttributes(array('group_id' => $groupid)); //$groups = new Group; $groups->group_activestatus = '2'; if ($groups->save(false)) { echo "success"; } $imagetypeid = Lookups::model()->findByAttributes(array('lookup_type' => 'uploadtype', 'lookup_status' => 1, 'lookup_name' => 'Image')); $videotypeid = Lookups::model()->findByAttributes(array('lookup_type' => 'uploadtype', 'lookup_status' => 1, 'lookup_name' => 'Video')); $sourcetypeidfinao = Lookups::model()->findByAttributes(array('lookup_type' => 'uploadsourcetype', 'lookup_status' => 1, 'lookup_name' => 'finao')); $sourcetypeidtile = Lookups::model()->findByAttributes(array('lookup_type' => 'uploadsourcetype', 'lookup_status' => 1, 'lookup_name' => 'tile')); $tracked_tileids = Yii::app()->session['login']['id']; /*$tileinfo = Tracking::model()->findAllByAttributes(array('tracked_userid'=>$tracked_tileids,'tracked_tileid'=>$tileid)); if(isset($tileinfo['0']['tracking_id'])) { $tileinfo = Tracking::model()->findByAttributes(array('tracking_id'=>$tileinfo['0']['tracking_id'])); $tileinfo->delete(); } */ $sourcetypeidjournal = Lookups::model()->findByAttributes(array('lookup_type' => 'uploadsourcetype', 'lookup_status' => 1, 'lookup_name' => 'journal')); $groupfinao = UserFinao::model()->findByAttributes(array('group_id' => $groupid)); // finaos deleteing $type = "finao"; if ($type == "finao") { // uploadedetails deleteing $delfiles = Uploaddetails::model()->findAllByAttributes(array('upload_sourceid' => $groupfinao->user_finao_id)); //$delfiles1 = Uploaddetails::model()->findAllByAttributes(array('uploadtype'=>$videotypeid->lookup_id,'upload_sourcetype'=>$sourcetypeidfinao->lookup_id,'upload_sourceid'=>$journalid,'uploadedby'=>$userid)); if (isset($delfiles) && !empty($delfiles)) { foreach ($delfiles as $image) { $image->status = 2; $image->save(false); } } /*if(isset($delfiles1) && !empty($delfiles1)) { foreach($delfiles1 as $video) { $video->status = 2; $video->save(false); } }*/ $tiles = UserFinaoTile::model()->findAllByAttributes(array('finao_id' => $groupfinao->user_finao_id, 'createdby' => $userid)); if (isset($tiles) && !empty($tiles)) { foreach ($tiles as $eachtile) { $eachtile->status = '2'; $eachtile->save(false); } } // finaos deleteing $finaodel = UserFinao::model()->findAllByAttributes(array('user_finao_id' => $groupfinao->user_finao_id, 'updatedby' => $userid)); //echo $groupfinao->user_finao_id; echo $userid; if (isset($finaodel) && !empty($finaodel)) { $finaodel->finao_activestatus = '2'; $finaodel->save(false); } $tracked_tileids = Yii::app()->session['login']['id']; $tileinfo = Tracking::model()->findAllByAttributes(array('tracked_userid' => $tracked_tileids, 'tracked_tileid' => $tileid)); if (isset($tileinfo['0']['tracking_id'])) { $tileinfo = Tracking::model()->findByAttributes(array('tracking_id' => $tileinfo['0']['tracking_id'])); $tileinfo->delete(); } //echo "successful"; } }
/** * Search the courses database for a course that matches the search term. * The search is done on the code, title and tutor field of the course table. * @param string $search_term The string that the user submitted, what we are looking for * @param array $limit * @return array An array containing a list of all the courses matching the the search term. */ public function search_courses($search_term, $limit) { $courseTable = Database::get_main_table(TABLE_MAIN_COURSE); $extraFieldTable = Database::get_main_table(TABLE_EXTRA_FIELD); $extraFieldValuesTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); $limitFilter = getLimitFilterFromArray($limit); // get course list auto-register $sql = "SELECT item_id\n FROM {$extraFieldValuesTable} tcfv\n INNER JOIN {$extraFieldTable} tcf ON tcfv.field_id = tcf.id\n WHERE\n tcf.variable = 'special_course' AND\n tcfv.value = 1 "; $special_course_result = Database::query($sql); if (Database::num_rows($special_course_result) > 0) { $special_course_list = array(); while ($result_row = Database::fetch_array($special_course_result)) { $special_course_list[] = '"' . $result_row['item_id'] . '"'; } } $without_special_courses = ''; if (!empty($special_course_list)) { $without_special_courses = ' AND course.code NOT IN (' . implode(',', $special_course_list) . ')'; } $search_term_safe = Database::escape_string($search_term); $sql_find = "SELECT * FROM {$courseTable}\n WHERE (\n code LIKE '%" . $search_term_safe . "%' OR\n title LIKE '%" . $search_term_safe . "%' OR\n tutor_name LIKE '%" . $search_term_safe . "%'\n )\n {$without_special_courses}\n ORDER BY title, visual_code ASC\n {$limitFilter}\n "; if (api_is_multiple_url_enabled()) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id != -1) { $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql_find = "SELECT *\n FROM {$courseTable} as course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE\n access_url_id = {$url_access_id} AND (\n code LIKE '%" . $search_term_safe . "%' OR\n title LIKE '%" . $search_term_safe . "%' OR\n tutor_name LIKE '%" . $search_term_safe . "%'\n )\n {$without_special_courses}\n ORDER BY title, visual_code ASC\n {$limitFilter}\n "; } } $result_find = Database::query($sql_find); $courses = array(); while ($row = Database::fetch_array($result_find)) { $row['registration_code'] = !empty($row['registration_code']); $count_users = count(CourseManager::get_user_list_from_course_code($row['code'])); $count_connections_last_month = Tracking::get_course_connections_count($row['id'], 0, api_get_utc_datetime(time() - 30 * 86400)); $point_info = CourseManager::get_course_ranking($row['id'], 0); $courses[] = array('real_id' => $row['id'], 'point_info' => $point_info, 'code' => $row['code'], 'directory' => $row['directory'], 'visual_code' => $row['visual_code'], 'title' => $row['title'], 'tutor' => $row['tutor_name'], 'subscribe' => $row['subscribe'], 'unsubscribe' => $row['unsubscribe'], 'registration_code' => $row['registration_code'], 'creation_date' => $row['creation_date'], 'visibility' => $row['visibility'], 'count_users' => $count_users, 'count_connections' => $count_connections_last_month); } return $courses; }
<?php require 'include/config.php'; require 'include/class.tracking.php'; $t = new Tracking($db); $views = $t->getViews($_GET['hash']); include 'include/top.php'; ?> <table> <thead> <tr> <th>Date/Time</th> <th>Browser</th> <th>Referer</th> <th>IP</th> <th>Source</th> <th>Parameters</th> </tr> </thead> <tbody> <?php foreach ($views as $v) { ?> <tr> <td><?php echo $v['datetime']; ?> </td> <td><?php
/** * Return user info array of all users registered in a course * This only returns the users that are registered in this actual course, not linked courses. * @param string $course_code * @param int $session_id * @param string $limit * @param string $order_by the field to order the users by. * Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement * that starts with ORDER BY ... * @param null $filter_by_status if using the session_id: 0 or 2 (student, coach), * if using session_id = 0 STUDENT or COURSEMANAGER * @param null $return_count * @param bool $add_reports * @param bool $resumed_report * @param array $extra_field * @param array $courseCodeList * @param array $userIdList * @param string $filterByActive * @param array $sessionIdList * @return array|int */ public static function get_user_list_from_course_code($course_code = null, $session_id = 0, $limit = null, $order_by = null, $filter_by_status = null, $return_count = null, $add_reports = false, $resumed_report = false, $extra_field = array(), $courseCodeList = array(), $userIdList = array(), $filterByActive = null, $sessionIdList = array()) { $course_table = Database::get_main_table(TABLE_MAIN_COURSE); $sessionTable = Database::get_main_table(TABLE_MAIN_SESSION); $session_id = intval($session_id); $course_code = Database::escape_string($course_code); $courseInfo = api_get_course_info($course_code); $courseId = 0; if (!empty($courseInfo)) { $courseId = $courseInfo['real_id']; } $where = array(); if (empty($order_by)) { $order_by = 'user.lastname, user.firstname'; if (api_is_western_name_order()) { $order_by = 'user.firstname, user.lastname'; } } // if the $order_by does not contain 'ORDER BY' // we have to check if it is a valid field that can be sorted on if (!strstr($order_by, 'ORDER BY')) { if (!empty($order_by)) { $order_by = 'ORDER BY ' . $order_by; } else { $order_by = ''; } } $filter_by_status_condition = null; if (!empty($session_id) || !empty($sessionIdList)) { $sql = 'SELECT DISTINCT user.user_id, user.email, session_course_user.status as status_session, session_id, user.*, course.*, session.name as session_name '; if ($return_count) { $sql = " SELECT COUNT(user.user_id) as count"; } $sessionCondition = " session_course_user.session_id = {$session_id}"; if (!empty($sessionIdList)) { $sessionIdListTostring = implode("','", array_map('intval', $sessionIdList)); $sessionCondition = " session_course_user.session_id IN ('{$sessionIdListTostring}') "; } $courseCondition = " course.id = {$courseId}"; if (!empty($courseCodeList)) { $courseCodeListForSession = array_map(array('Database', 'escape_string'), $courseCodeList); $courseCodeListForSession = implode('","', $courseCodeListForSession); $courseCondition = ' course.code IN ("' . $courseCodeListForSession . '") '; } $sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; $sql .= " LEFT JOIN " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " as session_course_user\n ON\n user.user_id = session_course_user.user_id AND\n {$sessionCondition}\n INNER JOIN {$course_table} course ON session_course_user.c_id = course.id AND\n {$courseCondition}\n INNER JOIN {$sessionTable} session ON session_course_user.session_id = session.id\n "; $where[] = ' session_course_user.c_id IS NOT NULL '; // 2 = coach // 0 = student if (isset($filter_by_status)) { $filter_by_status = intval($filter_by_status); $filter_by_status_condition = " session_course_user.status = {$filter_by_status} AND "; } } else { if ($return_count) { $sql = " SELECT COUNT(*) as count"; if ($resumed_report) { //$sql = " SELECT count(field_id) "; } } else { if (empty($course_code)) { $sql = 'SELECT DISTINCT course.title, course.code, course_rel_user.status as status_rel, user.user_id, user.email, course_rel_user.is_tutor, user.* '; } else { $sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, user.email, course_rel_user.is_tutor, user.* '; } } $sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . ' as course_rel_user ON user.user_id = course_rel_user.user_id AND course_rel_user.relation_type <> ' . COURSE_RELATION_TYPE_RRHH . ' '; $sql .= " INNER JOIN {$course_table} course ON course_rel_user.c_id = course.id "; if (!empty($course_code)) { $sql .= ' AND course_rel_user.c_id="' . $courseId . '"'; } $where[] = ' course_rel_user.c_id IS NOT NULL '; if (isset($filter_by_status) && is_numeric($filter_by_status)) { $filter_by_status = intval($filter_by_status); $filter_by_status_condition = " course_rel_user.status = {$filter_by_status} AND "; } } $multiple_access_url = api_get_multiple_access_url(); if ($multiple_access_url) { $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au ON (au.user_id = user.user_id) '; } $extraFieldWasAdded = false; if ($return_count && $resumed_report) { foreach ($extra_field as $extraField) { $extraFieldInfo = UserManager::get_extra_field_information_by_name($extraField); if (!empty($extraFieldInfo)) { $fieldValuesTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); $sql .= ' LEFT JOIN ' . $fieldValuesTable . ' as ufv ON ( user.user_id = ufv.item_id AND (field_id = ' . $extraFieldInfo['id'] . ' OR field_id IS NULL) )'; $extraFieldWasAdded = true; } } } $sql .= ' WHERE ' . $filter_by_status_condition . ' ' . implode(' OR ', $where); if ($multiple_access_url) { $current_access_url_id = api_get_current_access_url_id(); $sql .= " AND (access_url_id = {$current_access_url_id} ) "; } if ($return_count && $resumed_report && $extraFieldWasAdded) { $sql .= ' AND field_id IS NOT NULL GROUP BY value '; } if (!empty($courseCodeList)) { $courseCodeList = array_map(array('Database', 'escape_string'), $courseCodeList); $courseCodeList = implode('","', $courseCodeList); if (empty($sessionIdList)) { $sql .= ' AND course.code IN ("' . $courseCodeList . '")'; } } if (!empty($userIdList)) { $userIdList = array_map('intval', $userIdList); $userIdList = implode('","', $userIdList); $sql .= ' AND user.user_id IN ("' . $userIdList . '")'; } if (isset($filterByActive)) { $filterByActive = intval($filterByActive); $sql .= ' AND user.active = ' . $filterByActive; } $sql .= ' ' . $order_by . ' ' . $limit; $rs = Database::query($sql); $users = array(); $extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true); $counter = 1; $count_rows = Database::num_rows($rs); if ($return_count && $resumed_report) { return $count_rows; } $table_user_field_value = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); $tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD); if ($count_rows) { while ($user = Database::fetch_array($rs)) { if ($return_count) { return $user['count']; } $report_info = array(); $user_info = $user; $user_info['status'] = $user['status']; if (isset($user['is_tutor'])) { $user_info['is_tutor'] = $user['is_tutor']; } if (!empty($session_id)) { $user_info['status_session'] = $user['status_session']; } $sessionId = isset($user['session_id']) ? $user['session_id'] : 0; $course_code = isset($user['code']) ? $user['code'] : null; if ($add_reports) { if ($resumed_report) { $extra = array(); if (!empty($extra_fields)) { foreach ($extra_fields as $extra) { if (in_array($extra['1'], $extra_field)) { $user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']); break; } } } $row_key = '-1'; $name = '-'; if (!empty($extra)) { if (!empty($user_data[$extra['1']])) { $row_key = $user_data[$extra['1']]; $name = $user_data[$extra['1']]; $users[$row_key]['extra_' . $extra['1']] = $name; } } $users[$row_key]['training_hours'] += Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, $sessionId); $users[$row_key]['count_users'] += $counter; $registered_users_with_extra_field = 0; if (!empty($name) && $name != '-') { $extraFieldType = EntityExtraField::COURSE_FIELD_TYPE; $name = Database::escape_string($name); $sql = "SELECT count(v.item_id) as count\n FROM {$table_user_field_value} v INNER JOIN\n {$tableExtraField} f\n ON (f.id = v.field_id)\n WHERE value = '{$name}' AND extra_field_type = {$extraFieldType}"; $result_count = Database::query($sql); if (Database::num_rows($result_count)) { $row_count = Database::fetch_array($result_count); $registered_users_with_extra_field = $row_count['count']; } } $users[$row_key]['count_users_registered'] = $registered_users_with_extra_field; $users[$row_key]['average_hours_per_user'] = $users[$row_key]['training_hours'] / $users[$row_key]['count_users']; $category = Category::load(null, null, $course_code, null, null, $sessionId); if (!isset($users[$row_key]['count_certificates'])) { $users[$row_key]['count_certificates'] = 0; } if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) { $users[$row_key]['count_certificates']++; } foreach ($extra_fields as $extra) { if ($extra['1'] == 'ruc') { continue; } if (!isset($users[$row_key][$extra['1']])) { $user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']); if (!empty($user_data[$extra['1']])) { $users[$row_key][$extra['1']] = $user_data[$extra['1']]; } } } } else { $sessionName = !empty($sessionId) ? ' - ' . $user['session_name'] : ''; $report_info['course'] = $user['title'] . $sessionName; $report_info['user'] = api_get_person_name($user['firstname'], $user['lastname']); $report_info['email'] = $user['email']; $report_info['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, $sessionId)); $category = Category::load(null, null, $course_code, null, null, $sessionId); $report_info['certificate'] = Display::label(get_lang('No')); if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) { $report_info['certificate'] = Display::label(get_lang('Yes'), 'success'); } $progress = intval(Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), $sessionId)); $report_info['progress_100'] = $progress == 100 ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No')); $report_info['progress'] = $progress . "%"; foreach ($extra_fields as $extra) { $user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']); $report_info[$extra['1']] = $user_data[$extra['1']]; } $report_info['user_id'] = $user['user_id']; $users[] = $report_info; } } else { $users[$user['user_id']] = $user_info; } } } return $users; }
$totalImpression = $totalUniqueImpression = $totalClick = $totalUniqueClick = $totalImpressionOver = $totalClickOver = $totalUniqueImpressionOver = $totalUniqueClickOver = $totalByEvent = 0; if (!empty($flightTracking)) { $totalImpression = $flightTracking['total_impression']; $totalUniqueImpression = $flightTracking['total_unique_impression']; $totalClick = $flightTracking['total_click']; $totalUniqueClick = $flightTracking['total_unique_click']; //over report $totalImpressionOver = $flightTracking['total_impression_over']; $totalUniqueImpressionOver = $flightTracking['total_unique_impression_over']; $totalClickOver = $flightTracking['total_click_over']; $totalUniqueClickOver = $flightTracking['total_unique_click_over']; $TrackingInventory = new TrackingInventory(); if (isset($flight->event) && $flight->event != '') { $event = $flight->event; } else { $event = Tracking::getTrackingEventType($flight->cost_type); } $key = "total_{$event}"; $keyOver = "total_{$event}_over"; $totalByEvent = $flightTracking[$key] + $flightTracking[$keyOver]; } ?> <td class="bg-default">Total Impression</td> <td width="30%"> <span class="badge badge-info">{{number_format($totalImpression + $totalImpressionOver)}}</span> @if ($totalImpressionOver) <span class="blue">({{number_format($totalImpressionOver)}})</span> @endif </td> </tr> <tr>
} else { $sql = "SELECT id_user as user_id FROM {$tbl_session_course_user} srcu\n\t\t\t WHERE srcu.c_id='{$courseId}' AND id_session = '{$id_session}' AND srcu.status<>2"; } $rs = Database::query($sql); $users = array(); while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; } if (count($users) > 0) { $nb_students_in_course = count($users); // tracking datas $avg_progress_in_course = Tracking::get_avg_student_progress($users, $courseId, array(), $id_session); $avg_score_in_course = Tracking::get_avg_student_score($users, $courseId, array(), $id_session); $avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $courseId, $id_session); $messages_in_course = Tracking::count_student_messages($users, $courseId, $id_session); $assignments_in_course = Tracking::count_student_assignments($users, $courseId, $id_session); $avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course); $avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2); if (is_numeric($avg_score_in_course)) { $avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2) . '%'; } } else { $avg_time_spent_in_course = null; $avg_progress_in_course = null; $avg_score_in_course = null; $messages_in_course = null; $assignments_in_course = null; } $tematic_advance_progress = 0; $thematic = new Thematic($course); $tematic_advance = $thematic->get_total_average_of_thematic_advances($course_code, $id_session);
><?php echo $pr['title']; ?> </option> <?php } ?> </select> <input type="submit" name="submit" value=" Filter " /> </p> </form> <?php if (isset($_GET['submit'])) { require 'include/class.tracking.php'; $t = new Tracking($db); $ses = $t->getSessionsReport($_GET['start'] . ' 00:00:00', $_GET['end'] . ' 23:59:59', $_GET['group'], isset($_GET['filter']) ? $_GET['filter'] : 0); ?> <table class="tablesorter"> <thead> <tr> <th>Param</th> <th>Revenue</th> <th>Unique clicks</th> <th>Raw Clicks</th> <th>Conversion Count</th> <th>Unique Clicks CR</th> <th>Raw Clicks CR</th> <th>Unique EPC</th> <th>Raw EPC</th>
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;
$result = $result . ' (' . $user_info_stat['attempts'] . ' ' . get_lang('Attempts') . ')'; $counter++; } else { $result = '-'; } $html_result .= $result; $html_result .= "</td>"; } if (empty($counter)) { $total_student = '-'; } else { $total_student = $total_result_by_user / $counter; $total_average_score += $total_student; $total_average_score_count++; } $string_date = Tracking::get_last_connection_date($user['user_id'], true); $html_result .= "<td>{$total_student}</td><td>{$string_date}</td></tr>"; } $html_result .= "<tr><th>" . get_lang('AverageScore') . "</th>"; $total_average = 0; $counter = 0; foreach ($course_list as $course_item) { if (!empty($course_average_counter[$course_item['code']])) { $average_per_course = round($course_average[$course_item['code']] / ($course_average_counter[$course_item['code']] * 100) * 100, 2); } else { $average_per_course = '-'; } if (!empty($average_per_course)) { $counter++; } $total_average = $total_average + $average_per_course;
/** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ public function get_students_content_html_for_platform_admin() { $students = $this->students; $content = '<div style="margin:10px;">'; $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 width="10%" rowspan="2">' . get_lang('FirstName') . '</th> <th width="10%" rowspan="2">' . get_lang('LastName') . '</th> <th width="30%" colspan="2">' . get_lang('CourseInformation') . '</th> </tr> <tr> <th width="10%">' . get_lang('Courses') . '</th> <th width="10%">' . get_lang('Time') . '</th> </tr>'; $i = 1; foreach ($students as $student) { $courses_by_user = CourseManager::get_courses_list_by_user_id($student['user_id'], true); $count_courses = count($courses_by_user); $rowspan = $count_courses ? $count_courses + 1 : 2; if ($i % 2 == 0) { $style = ' style="background-color:#F2F2F2" '; } else { $style = ' style="background-color:#FFF" '; } $students_table .= '<tr ' . $style . '> <td rowspan="' . $rowspan . '">' . $student['firstname'] . '</td> <td rowspan="' . $rowspan . '">' . $student['lastname'] . '</td> </tr>'; // courses information about the student if (!empty($courses_by_user)) { foreach ($courses_by_user as $course) { $course_code = $course['code']; $course_title = $course['title']; $time = api_time_to_hms(Tracking::get_time_spent_on_the_course($student['user_id'], $course['real_id'])); $students_table .= '<tr ' . $style . '> <td align="right">' . $course_title . '</td> <td align="right">' . $time . '</td> </tr>'; } } else { $students_table .= '<tr ' . $style . '> <td align="center" colspan="2"><i>' . get_lang('Empty') . '</i></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=useroverview">' . get_lang('SeeMore') . '</a></div>'; } $content .= '</div>'; return $content; }
'where' => $whereCondition, 'order' => "$sidx $sord", 'limit' => "$start , $limit" ) ); } */ break; case 'get_exercise_progress': $sessionId = intval($_GET['session_id']); $courseId = intval($_GET['course_id']); $exerciseId = intval($_GET['exercise_id']); $date_from = $_GET['date_from']; $date_to = $_GET['date_to']; $columns = array('session', 'exercise_id', 'quiz_title', 'username', 'lastname', 'firstname', 'time', 'question_id', 'question', 'description', 'answer', 'correct'); $result = Tracking::get_exercise_progress($sessionId, $courseId, $exerciseId, $date_from, $date_to, array('where' => $whereCondition, 'order' => "{$sidx} {$sord}", 'limit' => "{$start} , {$limit}")); break; case 'get_session_lp_progress': $sessionId = 0; if (!empty($_GET['session_id']) && !empty($_GET['course_id'])) { $sessionId = intval($_GET['session_id']); $courseId = intval($_GET['course_id']); $course = api_get_course_info_by_id($courseId); } /** * Add lessons of course * */ $columns = array('username', 'firstname', 'lastname'); $lessons = LearnpathList::get_course_lessons($course['code'], $sessionId); foreach ($lessons as $lesson_id => $lesson) {
if (!$isAllowedToEdit) { api_not_allowed(true); } $lpTable = Database::get_course_table(TABLE_LP_MAIN); $lpId = isset($_GET['lp_id']) ? boolval($_GET['lp_id']) : false; $sessionId = api_get_session_id(); $courseId = api_get_course_int_id(); $courseCode = api_get_course_id(); $sessionUsers = SessionManager::get_users_by_session($sessionId, 0); $userList = []; $lpInfo = Database::select('*', $lpTable, array('where' => array('c_id = ? AND ' => $courseId, 'id = ?' => $lpId)), 'first'); foreach ($sessionUsers as $user) { $lpTime = Tracking::get_time_spent_in_lp($user['user_id'], $courseCode, array($lpId), $sessionId); $lpScore = Tracking::get_avg_student_score($user['user_id'], $courseCode, array($lpId), $sessionId); $lpPogress = Tracking::get_avg_student_progress($user['user_id'], $courseCode, array($lpId), $sessionId); $lpLastConnection = Tracking::get_last_connection_time_in_lp($user['user_id'], $courseCode, array($lpId), $sessionId); $lpLastConnection = empty($lpLastConnection) ? '-' : api_convert_and_format_date($lpLastConnection, DATE_TIME_FORMAT_LONG); $userList[] = ['id' => $user['user_id'], 'first_name' => $user['firstname'], 'last_name' => $user['lastname'], 'lp_time' => api_time_to_hms($lpTime), 'lp_score' => is_numeric($lpScore) ? "{$lpScore}%" : $lpScore, 'lp_progress' => "{$lpPogress}%", 'lp_last_connection' => $lpLastConnection]; } // View $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php', 'name' => get_lang('LearningPaths')]; $actions = Display::url(Display::return_icon('back.png', get_lang('Back'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq()); $template = new Template(get_lang('StudentScore')); $template->assign('user_list', $userList); $template->assign('session_id', api_get_session_id()); $template->assign('course_code', api_get_course_id()); $template->assign('lp_id', $lpId); $layout = $template->get_template('learnpath/report.tpl'); $template->assign('header', $lpInfo['name']); $template->assign('actions', $actions); $template->assign('content', $template->fetch($layout));
/** * @param string $category_code * @param int $random_value * @param array $limit will be used if $random_value is not set. * This array should contains 'start' and 'length' keys * @return array */ function browseCoursesInCategory($category_code, $random_value = null, $limit = array()) { $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $specialCourseList = CourseManager::get_special_course_list(); $without_special_courses = ''; if (!empty($specialCourseList)) { $without_special_courses = ' AND course.code NOT IN (' . implode(',', $specialCourseList) . ')'; } $visibilityCondition = null; $hidePrivate = api_get_setting('platform.course_catalog_hide_private'); if ($hidePrivate === 'true') { $courseInfo = api_get_course_info(); $courseVisibility = $courseInfo['visibility']; $visibilityCondition = ' AND course.visibility <> 1'; } if (!empty($random_value)) { $random_value = intval($random_value); $sql = "SELECT COUNT(*) FROM {$tbl_course}"; $result = Database::query($sql); list($num_records) = Database::fetch_row($result); if (api_is_multiple_url_enabled()) { $url_access_id = api_get_current_access_url_id(); $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql = "SELECT COUNT(*) FROM {$tbl_course} course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE access_url_id = {$url_access_id} "; $result = Database::query($sql); list($num_records) = Database::fetch_row($result); $sql = "SELECT course.id FROM {$tbl_course} course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE\n access_url_id = {$url_access_id} AND\n RAND()*{$num_records}< {$random_value}\n {$without_special_courses} {$visibilityCondition}\n ORDER BY RAND()\n LIMIT 0, {$random_value}"; } else { $sql = "SELECT id FROM {$tbl_course} course\n WHERE RAND()*{$num_records}< {$random_value} {$without_special_courses} {$visibilityCondition}\n ORDER BY RAND()\n LIMIT 0, {$random_value}"; } $result = Database::query($sql); $id_in = null; while (list($id) = Database::fetch_row($result)) { if ($id_in) { $id_in .= ",{$id}"; } else { $id_in = "{$id}"; } } if ($id_in === null) { return array(); } $sql = "SELECT * FROM {$tbl_course} WHERE id IN({$id_in})"; } else { $limitFilter = self::getLimitFilterFromArray($limit); $category_code = Database::escape_string($category_code); if (empty($category_code) || $category_code == "ALL") { $sql = "SELECT * FROM {$tbl_course}\n WHERE\n 1=1\n {$without_special_courses}\n {$visibilityCondition}\n ORDER BY title {$limitFilter} "; } else { if ($category_code == 'NONE') { $category_code = ''; } $sql = "SELECT * FROM {$tbl_course}\n WHERE\n category_code='{$category_code}'\n {$without_special_courses}\n {$visibilityCondition}\n ORDER BY title {$limitFilter} "; } //showing only the courses of the current Chamilo access_url_id if (api_is_multiple_url_enabled()) { $url_access_id = api_get_current_access_url_id(); $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); if ($category_code != "ALL") { $sql = "SELECT * FROM {$tbl_course} as course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE\n access_url_id = {$url_access_id} AND\n category_code='{$category_code}'\n {$without_special_courses}\n {$visibilityCondition}\n ORDER BY title {$limitFilter}"; } else { $sql = "SELECT * FROM {$tbl_course} as course\n INNER JOIN {$tbl_url_rel_course} as url_rel_course\n ON (url_rel_course.c_id = course.id)\n WHERE\n access_url_id = {$url_access_id}\n {$without_special_courses}\n {$visibilityCondition}\n ORDER BY title {$limitFilter}"; } } } $result = Database::query($sql); $courses = array(); while ($row = Database::fetch_array($result)) { $row['registration_code'] = !empty($row['registration_code']); $count_users = CourseManager::get_users_count_in_course($row['code']); $count_connections_last_month = Tracking::get_course_connections_count($row['id'], 0, api_get_utc_datetime(time() - 30 * 86400)); if ($row['tutor_name'] == '0') { $row['tutor_name'] = get_lang('NoManager'); } $point_info = CourseManager::get_course_ranking($row['id'], 0); $courses[] = array('real_id' => $row['id'], 'point_info' => $point_info, 'code' => $row['code'], 'directory' => $row['directory'], 'visual_code' => $row['visual_code'], 'title' => $row['title'], 'tutor' => $row['tutor_name'], 'subscribe' => $row['subscribe'], 'unsubscribe' => $row['unsubscribe'], 'registration_code' => $row['registration_code'], 'creation_date' => $row['creation_date'], 'visibility' => $row['visibility'], 'count_users' => $count_users, 'count_connections' => $count_connections_last_month); } return $courses; }
/** * Formats user information into a standard array * This function should be only used inside api_get_user_info() * * @param array Non-standard user array * @param bool $add_password * * @return array Standard user array */ function _api_format_user($user, $add_password = false) { $result = array(); $firstname = null; $lastname = null; if (isset($user['firstname']) && isset($user['lastname'])) { $firstname = $user['firstname']; $lastname = $user['lastname']; } elseif (isset($user['firstName']) && isset($user['lastName'])) { $firstname = isset($user['firstName']) ? $user['firstName'] : null; $lastname = isset($user['lastName']) ? $user['lastName'] : null; } $result['complete_name'] = api_get_person_name($firstname, $lastname); $result['complete_name_with_username'] = $result['complete_name']; if (!empty($user['username'])) { $result['complete_name_with_username'] = $result['complete_name'] . ' (' . $user['username'] . ')'; } $result['firstname'] = $firstname; $result['lastname'] = $lastname; // Kept for historical reasons $result['firstName'] = $firstname; $result['lastName'] = $lastname; $attributes = array('phone', 'picture_uri', 'official_code', 'status', 'active', 'auth_source', 'username', 'theme', 'language', 'creator_id', 'registration_date', 'hr_dept_id', 'expiration_date'); foreach ($attributes as $attribute) { $result[$attribute] = isset($user[$attribute]) ? $user[$attribute] : null; } if (isset($user['email'])) { $result['mail'] = isset($user['email']) ? $user['email'] : null; $result['email'] = isset($user['email']) ? $user['email'] : null; } else { $result['mail'] = isset($user['mail']) ? $user['mail'] : null; $result['email'] = isset($user['mail']) ? $user['mail'] : null; } $user_id = intval($user['user_id']); // Maintain the user_id index for backwards compatibility $result['user_id'] = $result['id'] = $user_id; $saveUserLastLogin = api_get_configuration_value('save_user_last_login'); if ($saveUserLastLogin) { $last_login = $user['last_login']; } else { if (!isset($user['lastLogin']) && !isset($user['last_login'])) { $timestamp = Tracking::get_last_connection_date($result['user_id'], false, true); // Convert the timestamp back into a datetime // NOTE: this timestamp has ALREADY been converted to the local timezone in the get_last_connection_date function $last_login = date('Y-m-d H:i:s', $timestamp); } else { if (isset($user['lastLogin'])) { $last_login = $user['lastLogin']; } else { $last_login = $user['last_login']; } } } $result['last_login'] = $last_login; // Kept for historical reasons $result['lastLogin'] = $last_login; // Getting user avatar. $originalFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL, $result); $smallFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_SMALL, $result); $result['avatar'] = $originalFile; $avatarString = explode('?', $originalFile); $result['avatar_no_query'] = reset($avatarString); $result['avatar_small'] = $smallFile; //$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).'img/unknown.jpg'; if (isset($user['user_is_online'])) { $result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0; } if (isset($user['user_is_online_in_chat'])) { $result['user_is_online_in_chat'] = intval($user['user_is_online_in_chat']); } if ($add_password) { $result['password'] = $user['password']; } $result['profile_url'] = api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $user_id; if (isset($user['extra'])) { $result['extra'] = $user['extra']; } return $result; }
function get_users($from, $limit, $column, $direction) { $active = isset($_GET['active']) ? $_GET['active'] : 1; $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null; $sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null; $lastConnectionDate = null; if (!empty($sleepingDays)) { $lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays . ' days ago')); } $is_western_name_order = api_is_western_name_order(); $coach_id = api_get_user_id(); $drhLoaded = false; if (api_is_drh()) { $column = 'u.user_id'; if (api_drh_can_access_all_session_content()) { $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id(), false, $from, $limit, $column, $direction, $keyword, $active, $lastConnectionDate, null, null, api_is_student_boss() ? null : STUDENT); $drhLoaded = true; } } if ($drhLoaded == false) { $students = UserManager::getUsersFollowedByUser(api_get_user_id(), api_is_student_boss() ? null : STUDENT, false, false, false, $from, $limit, $column, $direction, $active, $lastConnectionDate, api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER, $keyword); } $all_datas = array(); foreach ($students as $student_data) { $student_id = $student_data['user_id']; if (isset($_GET['id_session'])) { $courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']); } $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0; $nb_courses_student = 0; if (!empty($courses)) { foreach ($courses as $course_code) { $courseInfo = api_get_course_info($course_code); $courseId = $courseInfo['real_id']; if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) { $avg_time_spent += Tracking::get_time_spent_on_the_course($student_id, $courseId, $_GET['id_session']); $my_average = Tracking::get_avg_student_score($student_id, $course_code); if (is_numeric($my_average)) { $avg_student_score += $my_average; } $avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code); $total_assignments += Tracking::count_student_assignments($student_id, $course_code); $total_messages += Tracking::count_student_messages($student_id, $course_code); $nb_courses_student++; } } } if ($nb_courses_student > 0) { $avg_time_spent = $avg_time_spent / $nb_courses_student; $avg_student_score = $avg_student_score / $nb_courses_student; $avg_student_progress = $avg_student_progress / $nb_courses_student; } else { $avg_time_spent = null; $avg_student_score = null; $avg_student_progress = null; } $row = array(); if ($is_western_name_order) { $row[] = $student_data['firstname']; $row[] = $student_data['lastname']; } else { $row[] = $student_data['lastname']; $row[] = $student_data['firstname']; } $string_date = Tracking::get_last_connection_date($student_id, true); $first_date = Tracking::get_first_connection_date($student_id); $row[] = $first_date; $row[] = $string_date; if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) { $detailsLink = '<a href="myStudents.php?student=' . $student_id . '&id_coach=' . $coach_id . '&id_session=' . $_GET['id_session'] . '"> <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } else { $detailsLink = '<a href="myStudents.php?student=' . $student_id . '"> <img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } $row[] = $detailsLink; $all_datas[] = $row; } return $all_datas; }
public function adsProcess() { $responseType = ''; $expandFields = array(); $zoneID = Input::get('zid', 0); $publisherID = Input::get('pid', 0); $requestType = Input::get('type', Delivery::REQUEST_TYPE_AD); $trackingModel = new Tracking(); $deliveryModel = new Delivery(); $flightDateModel = new FlightDateBaseModel(); //ghi log trước khi xử lý $logPreProcess = $trackingModel->logPreProcess($requestType); if ($logPreProcess) { //kiểm tra referrer $hostReferer = $trackingModel->getRequestReferer(); if (empty($zoneID)) { $responseType = Delivery::RESPONSE_TYPE_INVALID; } elseif (empty($hostReferer)) { $responseType = Delivery::RESPONSE_TYPE_EMPTY_REFERRER; } elseif ($trackingModel->countLatestRequest(1) < Delivery::ANTI_CHEAT_MAX_REQUEST_PER_1MIN && $trackingModel->countLatestRequest(5) < Delivery::ANTI_CHEAT_MAX_REQUEST_PER_5MIN) { $responseType = Delivery::RESPONSE_TYPE_ANTI_MANY_REQUEST; } //pre validate ok if (empty($responseType)) { //default invalid if ($zoneID && $publisherID) { $adZone = PublisherAdZoneBaseModel::find($zoneID); if ($adZone && $adZone->publisher) { if ($adZone->publisher_id == $publisherID) { $flightPublishers = FlightPublisherBaseModel::where('publisher_id', $publisherID)->with('flightDate', function ($query) { $today = date('Y-m-d'); $query->where('start', '<=', $today)->where('end', '>=', $today); })->where('publisher_ad_zone_id', $zoneID)->orderBy('order', 'asc')->get(); if ($flightPublishers) { if ($requestType == Delivery::REQUEST_TYPE_AD) { //lấy ad từ list thỏa điều kiện để trả về foreach ($flightPublishers as $k => $flightPublisher) { if ($flightPublisher->flightDate) { $runningInventory = $trackingModel->runningInventory($flightPublisher->id); if ($flightPublisher->total_inventory < $runningInventory) { $deliveryStatus = $deliveryModel->deliveryAd($flightPublisher->ad, $flightPublisher->flight); if ($deliveryStatus == Delivery::DELIVERY_STATUS_OK) { //trả về ad này $serveAd = $flightPublisher->ad; $expandFields = array('flight_id' => $flightPublisher->flight_id, 'ad_format_id' => $flightPublisher->ad_format_id, 'ad_id' => $flightPublisher->ad_id, 'campaign_id' => $flightPublisher->campaign_id, 'publisher_ad_zone_id' => $flightPublisher->publisher_ad_zone_id, 'flight_publisher_id' => $flightPublisher->id, 'publisher_id' => $flightPublisher->publisher_id, 'flight_publisher_id' => $flightPublisher->id); break; } } } } //endforeach } elseif ($requestType == Delivery::REQUEST_TYPE_TRACKING_BEACON) { //tracking beacon TO DO, now : do nothing if ($trackingModel->isKnownVisitor()) { } else { $responseType = Delivery::RESPONSE_TYPE_EMPTY_REFERRER; } } } } //serve Ad if (!empty($serveAd)) { } else { } } } } } if (empty($responseType)) { $responseType = Delivery::RESPONSE_TYPE_INVALID; } //ghi log process $trackingModel->logAfterProcess($responseType, $expandFields); return $deliveryModel->emptyAd(); }
$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>
/** * This method return a graph containing information about evaluations * inside courses in sessions, it's used inside get_block method for * showing it inside dashboard interface * @return string img html */ public function get_evaluations_courses_in_sessions_graph() { $graphs = array(); if (!empty($this->sessions)) { $session_ids = array_keys($this->sessions); foreach ($session_ids as $session_id) { $courses_code = array_keys(Tracking::get_courses_list_from_session($session_id)); $courses_graph = array(); foreach ($courses_code as $course_code) { $cats = Category::load(null, null, $course_code, null, null, $session_id); if (isset($cats) && isset($cats[0])) { $alleval = $cats[0]->get_evaluations(null, true, $course_code); $alllinks = $cats[0]->get_links(null, true); $users = get_all_users($alleval, $alllinks); $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); $evaluation_sumary = $datagen->get_evaluation_sumary_results(); if (!empty($evaluation_sumary)) { $items = array_keys($evaluation_sumary); $max = $min = $avg = array(); foreach ($evaluation_sumary as $evaluation) { $max[] = $evaluation['max']; $min[] = $evaluation['min']; $avg[] = $evaluation['avg']; } // Dataset definition $data_set = new pData; $data_set->AddPoint($max, "Max"); $data_set->AddPoint($avg, "Avg"); $data_set->AddPoint($min, "Min"); $data_set->AddPoint($items, "Items"); $data_set->SetXAxisName(get_lang('EvaluationName')); $data_set->SetYAxisName(get_lang('Percentage')); $data_set->AddAllSeries(); $data_set->RemoveSerie("Items"); $data_set->SetAbsciseLabelSerie("Items"); $graph_id = $this->user_id.'StudentEvaluationGraph'; $cache = new pCache(); // the graph id $data = $data_set->GetData(); if ($cache->IsInCache($graph_id, $data)) { //if we already created the img $img_file = $cache->GetHash($graph_id, $data); } else { // Initialise the graph $angle = -30; $test = new pChart($this->bg_width, $this->bg_height); $test->setFontProperties(api_get_path(LIBRARY_PATH) . 'pchart/fonts/tahoma.ttf', 8); $test->fixHeightByRotation( $data_set->GetData(), $data_set->GetDataDescription(), $angle ); $test->setGraphArea(50, 30, $this->bg_width - 75, $this->bg_height - 75); $test->drawFilledRoundedRectangle( 7, 7, $this->bg_width - 20, $test->YSize - 20, 5, 240, 240, 240 ); $test->drawRoundedRectangle( 5, 5, $this->bg_width - 18, $test->YSize - 18, 5, 230, 230, 230 ); $test->drawGraphArea(255,255,255,TRUE); $test->setFixedScale(0,100,5); $test->drawScale( $data_set->GetData(), $data_set->GetDataDescription(), SCALE_ADDALL, 150, 150, 150, TRUE, $angle, 2, TRUE ); $test->setColorPalette(0,105,221,34); $test->setColorPalette(1,255,135,30); $test->setColorPalette(2,255,0,0); $test->drawGrid(4,TRUE,230,230,230,50); // Draw the 0 line $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',6); $test->drawTreshold(0,143,55,72,TRUE,TRUE); // Draw the bar graph $test->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100); // Finish the graph $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8); $test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255); $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10); $test->setColorPalette(0,50,50,50); $test->setColorPalette(1,50,50,50); $test->setColorPalette(2,50,50,50); $test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg")); $cache->WriteToCache($graph_id, $data_set->GetData(), $test); ob_start(); $test->Stroke(); ob_end_clean(); $img_file = $cache->GetHash($graph_id, $data_set->GetData()); } if (!empty($img_file)) { $courses_graph[$course_code] = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">'; } } } } if (!empty($courses_graph)) { $graphs[$session_id] = $courses_graph; } } } return $graphs; }