DRH user can see the "company reports" see BT#7089

1.9.x
Julio Montoya 12 years ago
parent c8e3425aec
commit 86d47af40e
  1. 83
      main/inc/ajax/model.ajax.php
  2. 74
      main/inc/lib/course.lib.php
  3. 16
      main/mySpace/company_reports.php
  4. 4
      main/mySpace/company_reports_resumed.php
  5. 7
      main/mySpace/index.php

@ -43,7 +43,9 @@ if (!in_array(
'get_work_user_list_all',
'get_timelines',
'get_user_skill_ranking',
'get_usergroups_teacher'
'get_usergroups_teacher',
'get_user_course_report_resumed',
'get_user_course_report'
)
)) {
api_protect_admin_script(true);
@ -132,11 +134,33 @@ if (!$sidx) {
//@todo rework this
switch ($action) {
case 'get_user_course_report_resumed':
$count = CourseManager::get_count_user_list_from_course_code(true, 'ruc');
break;
case 'get_user_course_report':
$count = CourseManager::get_count_user_list_from_course_code(false);
case 'get_user_course_report_resumed':
if (!(api_is_platform_admin(false, true))) {
exit;
}
$courseCodeList = array();
$userIdList = array();
if (api_is_drh()) {
$userList = UserManager::get_users_followed_by_drh(api_get_user_id());
if (!empty($userList)) {
$userIdList = array_keys($userList);
}
$courseList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
if (!empty($courseList)) {
$courseCodeList = array_keys($courseList);
}
if (empty($userIdList) || empty($courseCodeList)) {
exit;
}
}
if ($action == 'get_user_course_report') {
$count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList);
} else {
$count = CourseManager::get_count_user_list_from_course_code(true, 'ruc', $courseCodeList, $userIdList);
}
break;
case 'get_course_exercise_medias':
$course_id = api_get_course_int_id();
@ -296,10 +320,29 @@ switch ($action) {
$columns = array(
'extra_ruc', 'training_hours', 'count_users', 'count_users_registered', 'average_hours_per_user', 'count_certificates'
);
$column_names = array(
get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscriptions'), get_lang('CountOfUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates')
get_lang('Company'),
get_lang('TrainingHoursAccumulated'),
get_lang('CountOfSubscriptions'),
get_lang('CountOfUsers'),
get_lang('AverageHoursPerStudent'),
get_lang('CountCertificates')
);
$result = CourseManager::get_user_list_from_course_code(
null,
null,
"LIMIT $start, $limit",
" $sidx $sord",
null,
null,
true,
true,
'ruc',
$courseCodeList,
$userIdList
);
$result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT $start, $limit", " $sidx $sord", null, null, true, true, 'ruc');
$new_result = array();
if (!empty($result)) {
foreach ($result as $row) {
@ -313,16 +356,34 @@ switch ($action) {
case 'get_user_course_report':
$columns = array('course', 'user', 'time', 'certificate', 'progress_100', 'progress');
$column_names = array(
get_lang('Course'), get_lang('User'), get_lang('ManHours'), get_lang('CertificateGenerated'), get_lang('Approved'), get_lang('CourseAdvance')
get_lang('Course'),
get_lang('User'),
get_lang('ManHours'),
get_lang('CertificateGenerated'),
get_lang('Approved'),
get_lang('CourseAdvance')
);
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
if (!empty($extra_fields)) {
foreach($extra_fields as $extra) {
foreach ($extra_fields as $extra) {
$columns[] = $extra['1'];
$column_names[] = $extra['3'];
}
}
$result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT $start, $limit", " $sidx $sord", null, null, true);
$result = CourseManager::get_user_list_from_course_code(
null,
null,
"LIMIT $start, $limit",
" $sidx $sord",
null,
null,
true,
false,
null,
$courseCodeList,
$userIdList
);
break;
case 'get_user_skill_ranking':
$columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');
@ -439,7 +500,7 @@ switch ($action) {
'username', 'firstname', 'lastname', 'name', 'progress'
);
$sessionId = 0;
if (isset($_GET['session_id']) && !empty($_GET['session_id']))
if (isset($_GET['session_id']) && !empty($_GET['session_id']))
{
$sessionId = intval($_GET['session_id']);
}

@ -1150,16 +1150,23 @@ class CourseManager
}
/**
* Return user info array of all users registered in the specified real or virtual course
* This only returns the users that are registered in this actual course, not linked courses.
*
* @param string $course_code the code of the course
* @param boolean $with_session determines if the course is used in a session or not
* @param integer $session_id the id of the session
* @param string $limit the LIMIT statement of the sql statement
* @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 int if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
* @return array
* Return user info array of all users registered in the specified real or virtual course
* This only returns the users that are registered in this actual course, not linked courses.
* @param null $course_code
* @param int $session_id
* @param null $limit
* @param null $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 null $extra_field
* @param array $courseCodeList
* @param array $userList
* @return array|int
*/
public static function get_user_list_from_course_code(
$course_code = null,
@ -1170,7 +1177,9 @@ class CourseManager
$return_count = null,
$add_reports = false,
$resumed_report = false,
$extra_field = null
$extra_field = null,
$courseCodeList = array(),
$userIdList = array()
) {
// variable initialisation
$session_id = intval($session_id);
@ -1258,6 +1267,20 @@ class CourseManager
$sql .= ' AND field_id IS NOT NULL GROUP BY field_value ';
}
if (!empty($courseCodeList)) {
$courseCodeList = array_map(array('Database', 'escape_string') , $courseCodeList);
$courseCodeList = implode('","', $courseCodeList);
$sql .= ' AND course.code IN ("'.$courseCodeList.'")';
}
if (!empty($userIdList)) {
$userIdList = array_map('intval', $userIdList);
$userIdList = implode('","', $userIdList);
$sql .= ' AND user.user_id IN ("'.$userIdList.'")';
}
//$userList = array()
$sql .= ' '.$order_by.' '.$limit;
$rs = Database::query($sql);
@ -1374,12 +1397,35 @@ class CourseManager
//var_dump($counter);
}
}
//var_dump($users);
return $users;
}
static function get_count_user_list_from_course_code($resumed_report = false, $extra_field = null) {
return self::get_user_list_from_course_code(null, 0, null, null, null, true, false, $resumed_report, $extra_field);
/**
* @param bool $resumed_report
* @param string $extra_field
* @param array $courseCodeList
* @param array $userIdList
* @return array|int
*/
static function get_count_user_list_from_course_code(
$resumed_report = false,
$extra_field = null,
$courseCodeList = array(),
$userIdList = array()
) {
return self::get_user_list_from_course_code(
null,
0,
null,
null,
null,
true,
false,
$resumed_report,
$extra_field,
$courseCodeList,
$userIdList
);
}
/**

@ -12,10 +12,11 @@ $language_file = array('admin', 'gradebook', 'tracking');
$cidReset = true;
require_once '../inc/global.inc.php';
api_protect_admin_script();
if (!(api_is_platform_admin(false, true))) {
api_not_allowed();
}
$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;
@ -36,12 +37,12 @@ $column_model = array(
array('name'=>'user', 'index'=>'user', 'width'=>'100', 'align'=>'left','sortable'=>'false'),
array('name'=>'time', 'index'=>'time', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'certificate', 'index'=>'certificate', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'progress_100', 'index'=>'progress_100', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'progress_100', 'index'=>'progress_100', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
array('name'=>'progress', 'index'=>'progress', 'width'=>'50', 'align'=>'left','sortable'=>'false')
);
if (!empty($extra_fields)) {
foreach($extra_fields as $extra) {
foreach ($extra_fields as $extra) {
$col = array(
'name' => $extra['1'],
'index'=> $extra['1'],
@ -54,15 +55,14 @@ if (!empty($extra_fields)) {
}
}
//Autowidth
// Autowidth
$extra_params['autowidth'] = 'true';
//height auto
// height auto
$extra_params['height'] = 'auto';
$htmlHeadXtra[] = '<script>
$(function() {
'.Display::grid_js('user_course_report', $url,$columns,$column_model,$extra_params, array(), null, true).'
'.Display::grid_js('user_course_report', $url, $columns, $column_model, $extra_params, array(), null, 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:"",

@ -11,7 +11,9 @@ $language_file = array('admin', 'gradebook', 'tracking');
$cidReset = true;
require_once '../inc/global.inc.php';
api_protect_admin_script();
if (!(api_is_platform_admin(false, true))) {
api_not_allowed();
}
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('MySpace'));

@ -18,7 +18,7 @@ require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once 'myspace.lib.php';
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = api_get_jqgrid_js();
// the section (for the tabs)
$this_section = SECTION_TRACKING;
//for HTML editor repository
@ -145,6 +145,9 @@ if ($is_drh) {
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php');
$menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php');
$menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php');
$menu_items[] = Display::url(Display::return_icon('empty_evaluation.png', get_lang('CompanyReports'), array(), ICON_SIZE_MEDIUM), 'company_reports.php');
$menu_items[] = Display::url(Display::return_icon('evaluation_rate.png', get_lang('CompanyReportResumed'), array(), ICON_SIZE_MEDIUM), 'company_reports_resumed.php');
}
echo '<div id="actions" class="actions">';
@ -205,7 +208,7 @@ if (empty($session_id) || in_array($display, array('accessoverview','progressove
#show filter by session
if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','progressoverview'))) {
echo '<div class="pull-right">';
echo '<div class="pull-right">';
echo $sessionFilter->return_form();
echo '</div>';
echo '<script>$(function() {

Loading…
Cancel
Save