Adding company reports see BT#5476

skala
Julio Montoya 12 years ago
parent fb7f22a982
commit b0951147b8
  1. 147
      main/admin/index.php
  2. 46
      main/inc/ajax/model.ajax.php
  3. 69
      main/inc/lib/course.lib.php
  4. 2
      main/inc/lib/usermanager.lib.php
  5. 87
      main/mySpace/company_reports.php

@ -29,12 +29,12 @@ $message = '';
if (api_is_platform_admin()) {
if (is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php')) {
$message = Display::return_message(get_lang('InstallDirAccessibleSecurityThreat'),'warning');
$message = Display::return_message(get_lang('InstallDirAccessibleSecurityThreat'),'warning');
}
if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
$message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
}
/* ACTION HANDLING */
if (!empty($_POST['Register'])) {
register_site();
@ -45,13 +45,13 @@ if (api_is_platform_admin()) {
if (isset($_GET['msg']) && isset($_GET['type'])) {
if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed')))
switch($_GET['type']) {
switch($_GET['type']) {
case 'error':
$message = Display::return_message(get_lang($_GET['msg']), 'error');
break;
case 'confirmation':
case 'confirmation':
$message = Display::return_message(get_lang($_GET['msg']), 'confirm');
}
}
}
$blocks = array();
@ -61,19 +61,19 @@ $blocks = array();
$blocks['users']['icon'] = Display::return_icon('members.gif', get_lang('Users'), array(), ICON_SIZE_SMALL, false);
$blocks['users']['label'] = api_ucfirst(get_lang('Users'));
if (api_is_platform_admin()) {
if (api_is_platform_admin()) {
$search_form = ' <form method="get" class="form-search" action="user_list.php">
<input class="span3" type="text" name="keyword" value="">
<button class="btn" type="submit">'.get_lang('Search').'</button>
</form>';
$blocks['users']['search_form'] = $search_form;
$blocks['users']['search_form'] = $search_form;
$items = array(
array('url'=>'user_list.php', 'label' => get_lang('UserList')),
array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
array('url'=>'user_export.php', 'label' => get_lang('ExportUserListXMLCSV')),
array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
);
if (api_get_setting('allow_social_tool') == 'true') {
$items[] = array('url'=>'group_add.php', 'label' => get_lang('AddGroups'));
$items[] = array('url'=>'group_list.php', 'label' => get_lang('GroupList'));
@ -81,11 +81,11 @@ if (api_is_platform_admin()) {
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
$items[] = array('url'=>'ldap_users_list.php', 'label' => get_lang('ImportLDAPUsersIntoPlatform'));
}
$items[] = array('url'=>'user_fields.php', 'label' => get_lang('ManageUserFields'));
$items[] = array('url'=>'user_fields.php', 'label' => get_lang('ManageUserFields'));
} else {
$items = array(
array('url'=>'user_list.php', 'label' => get_lang('UserList')),
array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
array('url'=>'user_add.php', 'label' => get_lang('AddUsers')),
array('url'=>'user_import.php', 'label' => get_lang('ImportUserListXMLCSV')),
);
}
@ -96,16 +96,16 @@ if (api_is_platform_admin()) {
/* Courses */
$blocks['courses']['icon'] = Display::return_icon('course.gif', get_lang('Courses'), array(), ICON_SIZE_MEDIUM, false);
$blocks['courses']['label'] = api_ucfirst(get_lang('Courses'));
$search_form = ' <form method="get" class="form-search" action="course_list.php">
<input class="span3" type="text" name="keyword" value="">
<button class="btn" type="submit">'.get_lang('Search').'</button>
</form>';
$blocks['courses']['search_form'] = $search_form;
$items = array();
$items = array();
$items[] = array('url'=>'course_list.php', 'label' => get_lang('CourseList'));
if (api_get_setting('course_validation') != 'true') {
$items[] = array('url'=>'course_add.php', 'label' => get_lang('AddCourse'));
} else {
@ -113,63 +113,64 @@ if (api_is_platform_admin()) {
$items[] = array('url'=>'course_request_accepted.php', 'label' => get_lang('AcceptedCourseRequests'));
$items[] = array('url'=>'course_request_rejected.php', 'label' => get_lang('RejectedCourseRequests'));
}
$items[] = array('url'=>'course_export.php', 'label' => get_lang('ExportCourses'));
$items[] = array('url'=>'course_import.php', 'label' => get_lang('ImportCourses'));
$items[] = array('url'=>'course_category.php', 'label' => get_lang('AdminCategories'));
$items[] = array('url'=>'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
$items[] = array('url'=>'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
if (api_get_setting('gradebook_enable_grade_model') == 'true') {
$items[] = array('url'=>'grade_models.php', 'label' => get_lang('GradeModel'));
}
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
$items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
}
$blocks['courses']['items'] = $items;
$blocks['courses']['extra'] = null;
/* Platform */
/* Platform */
$blocks['platform']['icon'] = Display::return_icon('platform.png', get_lang('Platform'), array(), ICON_SIZE_MEDIUM, false);
$blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
$blocks['platform']['label'] = api_ucfirst(get_lang('Platform'));
$search_form = ' <form method="get" action="settings.php" class="form-search">
<input class="span3" type="text" name="search_field" value="" >
<input type="hidden" value="search_setting" name="category">
<button class="btn" type="submit">'.get_lang('Search').'</button>
</form>';
$blocks['platform']['search_form'] = $search_form;
$items = array();
$items[] = array('url'=>'settings.php', 'label' => get_lang('PlatformConfigSettings'));
$items[] = array('url'=>'settings.php?category=Plugins','label' => get_lang('Plugins'));
$items[] = array('url'=>'settings.php?category=Regions','label' => get_lang('Regions'));
$items[] = array('url'=>'system_announcements.php', 'label' => get_lang('SystemAnnouncements'));
$items[] = array('url'=>api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin', 'label' => get_lang('GlobalAgenda'));
$items[] = array('url'=> api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=admin', 'label' => get_lang('GlobalAgenda'));
$items[] = array('url'=>'configure_homepage.php', 'label' => get_lang('ConfigureHomePage'));
$items[] = array('url'=>'configure_inscription.php', 'label' => get_lang('ConfigureInscription'));
$items[] = array('url'=>'statistics/index.php', 'label' => get_lang('Statistics'));
$items[] = array('url'=> api_get_path(WEB_CODE_PATH).'mySpace/company_reports.php', 'label' => get_lang('Reports'));
/* Event settings */
if (api_get_setting('activate_email_template') == 'true') {
if (api_get_setting('activate_email_template') == 'true') {
$items[] = array('url'=>'event_controller.php?action=listing', 'label' => get_lang('EventMessageManagement'));
}
}
if (!empty($_configuration['multiple_access_urls'])) {
if (api_is_global_platform_admin()) {
$items[] = array('url'=>'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
$items[] = array('url'=>'access_urls.php', 'label' => get_lang('ConfigureMultipleAccessURLs'));
}
}
if (api_get_setting('allow_reservation') == 'true') {
$items[] = array('url'=>'../reservation/m_category.php', 'label' => get_lang('BookingSystem'));
$items[] = array('url'=>'../reservation/m_category.php', 'label' => get_lang('BookingSystem'));
}
if (api_get_setting('allow_terms_conditions') == 'true') {
$items[] = array('url'=>'legal_add.php', 'label' => get_lang('TermsAndConditions'));
}
}
$blocks['platform']['items'] = $items;
$blocks['platform']['extra'] = null;
}
@ -182,7 +183,7 @@ $search_form = ' <form method="GET" class="form-search" action="session_list.php
<input class="span3" type="text" name="keyword" value="">
<button class="btn" type="submit">'.get_lang('Search').'</button>
</form>';
$blocks['sessions']['search_form'] = $search_form;
$blocks['sessions']['search_form'] = $search_form;
$items = array();
$items[] = array('url'=>'session_list.php', 'label' => get_lang('ListSession'));
$items[] = array('url'=>'session_add.php', 'label' => get_lang('AddSession'));
@ -195,9 +196,9 @@ $items[] = array('url'=>'session_export.php', 'label' => get_lang('ExportSessio
$items[] = array('url'=>'../coursecopy/copy_course_session.php', 'label' => get_lang('CopyFromCourseInSessionToAnotherSession'));
if (api_is_platform_admin()) {
if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required
if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) { // option only visible in development mode. Enable through code if required
$items[] = array('url'=>'user_move_stats.php', 'label' => get_lang('MoveUserStats'));
}
}
$items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
}
@ -208,11 +209,11 @@ $blocks['sessions']['extra'] = null;
/* Settings */
if (api_is_platform_admin()) {
if (api_is_platform_admin()) {
$blocks['settings']['icon'] = Display::return_icon('settings.png', get_lang('System'), array(), ICON_SIZE_SMALL, false);
$blocks['settings']['label'] = api_ucfirst(get_lang('System'));
$items = array();
$items[] = array('url'=>'special_exports.php', 'label' => get_lang('SpecialExports'));
if (!empty($_configuration['db_admin_path'])) {
@ -222,33 +223,29 @@ if (api_is_platform_admin()) {
if (is_dir(api_get_path(SYS_TEST_PATH).'datafiller/')) {
$items[] = array('url'=>'filler.php', 'label' => get_lang('DataFiller'));
}
//if (api_is_global_platform_admin()) {
$items[] = array('url'=>'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
//}
$items[] = array('url'=>'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup'));
$items[] = array('url'=>'system_management.php', 'label' => get_lang('SystemManagement'));
//$items[] = array('url'=>'statistics/index.php?action=activities', 'label' => get_lang('ImportantActivities'));
$blocks['settings']['items'] = $items;
$blocks['settings']['extra'] = null;
$blocks['settings']['search_form'] = null;
/* Extensions */
/*
$blocks['extensions']['icon'] = Display::return_icon('visio_meeting.gif', get_lang('ConfigureExtensions'), array(), ICON_SIZE_SMALL, false);
$blocks['extensions']['label'] = api_ucfirst(get_lang('ConfigureExtensions'));
$items = array();
$items[] = array('url'=>'configure_extensions.php?display=visio', 'label' => get_lang('Visioconf'));
$items[] = array('url'=>'configure_extensions.php?display=ppt2lp', 'label' => get_lang('Ppt2lp'));
//$items[] = array('url'=>'configure_extensions.php?display=ephorus', 'label' => get_lang('EphorusPlagiarismPrevention'));
$items[] = array('url'=>'configure_extensions.php?display=search', 'label' => get_lang('SearchEngine'));
$items[] = array('url'=>'configure_extensions.php?display=serverstats', 'label' => get_lang('ServerStatistics'));
$items[] = array('url'=>'configure_extensions.php?display=bandwidthstats', 'label' => get_lang('BandWidthStatistics'));
$blocks['extensions']['items'] = $items;
$items[] = array('url'=>'configure_extensions.php?display=bandwidthstats', 'label' => get_lang('BandWidthStatistics'));
$blocks['extensions']['items'] = $items;
*/
//Skills
if (api_get_setting('allow_skills_tool') == 'true') {
$blocks['skills']['icon'] = Display::return_icon('logo.gif', get_lang('Skills'), array(), ICON_SIZE_SMALL, false);
@ -260,42 +257,42 @@ if (api_is_platform_admin()) {
$items[] = array('url'=>'skills_import.php', 'label' => get_lang('SkillsImport'));
//$items[] = array('url'=>'skills_profile.php', 'label' => get_lang('SkillsProfile'));
$items[] = array('url'=>api_get_path(WEB_CODE_PATH).'social/skills_ranking.php', 'label' => get_lang('SkillsRanking'));
$items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
$items[] = array('url'=>'skills_gradebook.php', 'label' => get_lang('SkillsAndGradebooks'));
$blocks['skills']['items'] = $items;
$blocks['skills']['extra'] = null;
$blocks['skills']['search_form'] = null;
}
/* Chamilo.org */
$blocks['chamilo']['icon'] = Display::return_icon('logo.gif', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
$blocks['chamilo']['label'] = 'Chamilo.org';
$items = array();
$items[] = array('url'=>'http://www.chamilo.org/', 'label' => get_lang('ChamiloHomepage'));
$items[] = array('url'=>'http://www.chamilo.org/forum', 'label' => get_lang('ChamiloForum'));
$items[] = array('url'=>'../../documentation/installation_guide.html', 'label' => get_lang('InstallationGuide'));
$items[] = array('url'=>'../../documentation/changelog.html', 'label' => get_lang('ChangesInLastVersion'));
$items[] = array('url'=>'../../documentation/credits.html', 'label' => get_lang('ContributorsList'));
$items[] = array('url'=>'../../documentation/security.html', 'label' => get_lang('SecurityGuide'));
$items[] = array('url'=>'../../documentation/optimization.html', 'label' => get_lang('OptimizationGuide'));
$items[] = array('url'=>'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
$items[] = array('url'=>'http://www.chamilo.org/en/providers', 'label' => get_lang('ChamiloOfficialServicesProviders'));
$blocks['chamilo']['items'] = $items;
$items[] = array('url'=>'http://www.chamilo.org/extensions', 'label' => get_lang('ChamiloExtensions'));
$items[] = array('url'=>'http://www.chamilo.org/en/providers', 'label' => get_lang('ChamiloOfficialServicesProviders'));
$blocks['chamilo']['items'] = $items;
$blocks['chamilo']['extra'] = null;
$blocks['chamilo']['search_form'] = null;
// Try to display a maximum before we check the chamilo version and all that.
//session_write_close(); //close session to avoid blocking concurrent access
//flush(); //send data to client as much as allowed by the web server
//ob_flush();
//Version check
$blocks['version_check']['icon'] = Display::return_icon('logo.gif', 'Chamilo.org', array(), ICON_SIZE_SMALL, false);
$blocks['version_check']['label'] = get_lang('VersionCheck');
$blocks['version_check']['extra'] = version_check();
$blocks['version_check']['label'] = get_lang('VersionCheck');
$blocks['version_check']['extra'] = version_check();
$blocks['version_check']['search_form'] = null;
$blocks['version_check']['items'] = null;
}
@ -324,9 +321,9 @@ function version_check() {
// The site has not been registered yet.
$return = '';
if ($row['selected_value'] == 'false') {
if ($row['selected_value'] == 'false') {
$return .= get_lang('VersionCheckExplanation');
$return .= '<form class="well" action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
$return .= '<form class="well" action="'.api_get_self().'" id="VersionCheck" name="VersionCheck" method="post">';
$return .= '<label class="checkbox"><input type="checkbox" name="donotlistcampus" value="1" id="checkbox" />'.get_lang('HideCampusFromPublicPlatformsList');
$return .= '</label><button type="submit" class="btn btn-primary" name="Register" value="'.get_lang('EnableVersionCheck').'" id="register" >'.get_lang('EnableVersionCheck').'</button>';
$return .= '</form>';
@ -397,8 +394,8 @@ function check_system_version() {
'adminname' => api_get_setting('administratorName').' '.api_get_setting('administratorSurname'),
);
$res = _http_request('version.chamilo.org', 80, '/version.php', $data);
$res = _http_request('version.chamilo.org', 80, '/version.php', $data);
if ($res !== false) {
$version_info = $res;
@ -444,23 +441,23 @@ function _http_request($ip, $port = 80, $uri = '/', $getdata = array(), $timeout
$req .= 'Accept-Language: en-us,en;q=0.5' . $crlf;
$req .= 'Accept-Encoding: deflate' . $crlf;
$req .= 'Accept-Charset: utf-8;q=0.7,*;q=0.7' . $crlf;
$req .= $crlf;
if ($req_hdr) { $ret .= $req; }
if (($fp = @fsockopen($ip, $port, $errno, $errstr, $timeout)) == false) {
return "Error $errno: $errstr\n";
}
stream_set_timeout($fp, $timeout);
$r = @fwrite($fp, $req);
$line = @fread($fp,512);
$ret .= $line;
$ret .= $line;
fclose($fp);
if (!$res_hdr) {
$ret = substr($ret, strpos($ret, "\r\n\r\n") + 4);
}
return trim($ret);
}

@ -68,15 +68,17 @@ function get_where_clause($col, $oper, $val) {
if (empty($col)){
return '';
}
if($oper == 'bw' || $oper == 'bn') $val .= '%';
if($oper == 'ew' || $oper == 'en' ) $val = '%'.$val;
if($oper == 'cn' || $oper == 'nc' || $oper == 'in' || $oper == 'ni') $val = '%'.$val.'%';
if ($oper == 'bw' || $oper == 'bn') $val .= '%';
if ($oper == 'ew' || $oper == 'en' ) $val = '%'.$val;
if ($oper == 'cn' || $oper == 'nc' || $oper == 'in' || $oper == 'ni') $val = '%'.$val.'%';
$val = Database::escape_string($val);
return " $col {$ops[$oper]} '$val' ";
}
$where_condition = ""; //if there is no search request sent by jqgrid, $where should be empty
$operation = isset($_REQUEST['oper']) ? $_REQUEST['oper'] : false;
$search_field = isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : false;
$search_oper = isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : false;
$search_string = isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : false;
@ -114,6 +116,9 @@ if (!$sidx) $sidx = 1;
//@todo rework this
switch ($action) {
case 'get_user_course_report':
$count = CourseManager::get_count_user_list_from_course_code();
break;
case 'get_user_skill_ranking':
$skill = new Skill();
$count = $skill->get_user_list_skill_ranking_count();
@ -216,6 +221,16 @@ $is_allowedToEdit = api_is_allowed_to_edit(null,true) || api_is_allowed_to_edit(
$columns = array();
switch ($action) {
case 'get_user_course_report':
$columns = array('course', 'user', 'time', 'status', 'score');
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
if (!empty($extra_fields)) {
foreach($extra_fields as $extra) {
$columns[] = $extra['1'];
}
}
$result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT $start, $limit", " $sidx $sord", null, null, true);
break;
case 'get_user_skill_ranking':
$columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');
$result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition);
@ -467,7 +482,9 @@ $allowed_actions = array('get_careers',
'get_timelines',
'get_grade_models',
'get_event_email_template',
'get_user_skill_ranking');
'get_user_skill_ranking',
'get_user_course_report'
);
//5. Creating an obj to return a json
if (in_array($action, $allowed_actions)) {
@ -475,7 +492,26 @@ if (in_array($action, $allowed_actions)) {
$response->page = $page;
$response->total = $total_pages;
$response->records = $count;
$i=0;
if ($operation && $operation == 'excel') {
$j = 1;
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
$array = array();
foreach ($columns as $col) {
$array[0][] = $col;
}
foreach ($result as $row) {
foreach ($columns as $col) {
$array[$j][] = strip_tags($row[$col]);
}
$j++;
}
Export :: export_table_csv($array, 'company_report');
exit;
}
$i = 0;
if (!empty($result)) {
foreach ($result as $row) {
//print_r($row);

@ -1123,7 +1123,7 @@ class CourseManager {
* @param int if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
* @return array
*/
public static function get_user_list_from_course_code($course_code, $session_id = 0, $limit = '', $order_by = '', $filter_by_status = null) {
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) {
// variable initialisation
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
@ -1131,8 +1131,9 @@ class CourseManager {
// 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) AND in_array($order_by, array('lastname', 'firstname', 'username', 'email', 'official_code'))) {
$order_by = 'ORDER BY user.'.$order_by;
//if (!empty($order_by) AND in_array($order_by, array('lastname', 'firstname', 'username', 'email', 'official_code'))) {
if (!empty($order_by)) {
$order_by = 'ORDER BY '.$order_by;
} else {
$order_by = '';
}
@ -1156,12 +1157,26 @@ class CourseManager {
$filter_by_status_condition = " session_course_user.status = $filter_by_status AND ";
}
} else {
$sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.* ';
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
if ($return_count) {
$sql = " SELECT COUNT(*) as count";
} else {
if (empty($course_code)) {
$sql = 'SELECT DISTINCT course.title, course.code, course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.* ';
} else {
$sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, 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.'
AND course_rel_user.course_code="'.$course_code.'"';
ON user.user_id = course_rel_user.user_id AND
course_rel_user.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' ';
if (!empty($course_code)) {
$sql .= ' AND course_rel_user.course_code="'.$course_code.'"';
} else {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql .= " INNER JOIN $course_table course ON course_rel_user.course_code = course.code ";
}
$where[] = ' course_rel_user.course_code IS NOT NULL ';
if (isset($filter_by_status) && $filter_by_status != '') {
@ -1182,12 +1197,19 @@ class CourseManager {
$sql .= " AND (access_url_id = $current_access_url_id ) ";
}
$sql .= ' '.$order_by.' '.$limit;
//echo $sql;
$rs = Database::query($sql);
$users = array();
if ($add_reports) {
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
}
if (Database::num_rows($rs)) {
while ($user = Database::fetch_array($rs)) {
if ($return_count) {
return $user['count'];
}
$user_info = $user;
$user_info['status'] = $user['status'];
@ -1202,12 +1224,39 @@ class CourseManager {
$user_info['status_session'] = $user['status_session'];
}
$users[$user['user_id']] = $user_info;
if ($add_reports) {
$course_code = $user['code'];
$report_info['course'] = $user['title'];
$report_info['user'] = api_get_person_name($user['firstname'], $user['lastname']);
$report_info['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $course_code, 0));
$category = Category :: load (null, null, $course_code);
$report_info['status'] = Display::label(get_lang('No'));
if (isset($category[0]) && $category[0]->is_certificate_available($user['user_id'])) {
$report_info['status'] = Display::label(get_lang('Yes'));
}
$report_info['score'] = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), 0);
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']];
}
//var_dump($report_info);
$users[] = $report_info;
} else {
$users[$user['user_id']] = $user_info;
}
}
}
return $users;
}
static function get_count_user_list_from_course_code() {
return self::get_user_list_from_course_code(null, 0, null, null, null, true);
}
/**
* Gets subscribed users in a course or in a course/session
*
@ -3860,4 +3909,4 @@ class CourseManager {
}
return $options;
}
} //end class CourseManager
}

@ -1745,8 +1745,8 @@ class UserManager {
$t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD);
$t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$user_id = Database::escape_string($user_id);
$sql = "SELECT f.id as id, f.field_variable as fvar, f.field_type as type FROM $t_uf f ";
$sql = "SELECT f.id as id, f.field_variable as fvar, f.field_type as type FROM $t_uf f ";
$sql .= " WHERE f.field_variable = '$field_variable' ";
if (!$all_visibility) {

@ -0,0 +1,87 @@
<?php
$language_file = array('admin');
$cidReset = true;
require_once '../inc/global.inc.php';
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
//$interbreadcrumb[] = array ("url" => 'user_list.php', "name" => get_lang('Report'));
$tool_name = get_lang('Report');
$this_section = SECTION_TRACKING;
$htmlHeadXtra[] = api_get_jqgrid_js();
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report';
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Course'), get_lang('User'), get_lang('TotalTime'), get_lang('Certificate'), get_lang('Score'));
//Column config
$column_model = array(
array('name'=>'course', 'index'=>'title', 'width'=>'120', 'align'=>'left'),
array('name'=>'user', 'index'=>'user', 'width'=>'120', 'align'=>'left','sortable'=>'false'),
array('name'=>'time', 'index'=>'time', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'status', 'index'=>'status', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'score', 'index'=>'score', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
);
if (!empty($extra_fields)) {
foreach($extra_fields as $extra) {
$col = array(
'name' => $extra['1'],
'index'=> $extra['1'],
'width'=>'120',
'sortable'=>'false'
);
$column_model[] = $col;
$columns[] = $extra['3'];
}
}
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
$htmlHeadXtra[] = '<script>
$(function() {
'.Display::grid_js('user_course_report', $url,$columns,$column_model,$extra_params, array(), $action_links, true).'
jQuery("#user_course_report").jqGrid("navGrid","#user_course_report_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
jQuery("#user_course_report").jqGrid("navButtonAdd","#user_course_report_pager",{
caption:"",
onClickButton : function () {
jQuery("#user_course_report").jqGrid("excelExport",{"url":"'.$url.'"});
}
});
});
</script>';
$content = Display::grid_html('user_course_report');
$tpl = new Template($tool_name);
//$tpl->assign('actions', $actions);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
Loading…
Cancel
Save