Add new page stats page "course_log_events.php" see #2215

In order to get events of that course/course session
pull/2487/head
jmontoyaa 7 years ago
parent e41c5f824e
commit b904b8b447
  1. 36
      main/inc/ajax/model.ajax.php
  2. 39
      main/inc/lib/statistics.lib.php
  3. 171
      main/tracking/course_log_events.php
  4. 26
      main/tracking/course_log_groups.php
  5. 29
      main/tracking/course_log_resources.php

@ -3,11 +3,8 @@
use ChamiloSession as Session;
//@todo this could be integrated in the inc/lib/model.lib.php + try to clean this file
require_once __DIR__.'/../global.inc.php';
$libpath = api_get_path(LIBRARY_PATH);
// 1. Setting variables needed by jqgrid
$action = $_GET['a'];
$page = (int) $_REQUEST['page']; //page
@ -61,7 +58,8 @@ if (!in_array(
'get_user_course_report',
'get_sessions_tracking',
'get_sessions',
'get_course_announcements'
'get_course_announcements',
'course_log_events'
)
) && !isset($_REQUEST['from_course_session'])) {
api_protect_admin_script(true);
@ -228,6 +226,18 @@ if (!$sidx) {
//@todo rework this
switch ($action) {
case 'course_log_events':
$courseId = api_get_course_int_id();
if (empty($courseId)) {
exit;
}
$sessionId = api_get_session_id();
if (!api_is_allowed_to_edit()) {
exit;
}
$count = Statistics::getNumberOfActivities($courseId, $sessionId);
break;
case 'get_programmed_announcements':
$object = new ScheduledAnnouncement();
$count = $object->get_count();
@ -689,12 +699,10 @@ switch ($action) {
$count = $obj->get_count_by_field_id($field_id);
break;
case 'get_timelines':
require_once $libpath.'timeline.lib.php';
$obj = new Timeline();
$count = $obj->get_count();
break;
case 'get_gradebooks':
require_once $libpath.'gradebook.lib.php';
$obj = new Gradebook();
$count = $obj->get_count();
break;
@ -764,6 +772,19 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit
$columns = array();
switch ($action) {
case 'course_log_events':
$columns = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
$result = Statistics::getActivitiesData(
$start,
$limit,
$column,
$direction,
$courseId,
$sessionId
);
break;
case 'get_programmed_announcements':
$columns = array('subject', 'date', 'sent', 'actions');
$sessionId = isset($_REQUEST['session_id']) ? (int) $_REQUEST['session_id'] : 0;
@ -2070,7 +2091,8 @@ $allowed_actions = array(
'get_exercise_grade',
'get_group_reporting',
'get_course_announcements',
'get_programmed_announcements'
'get_programmed_announcements',
'course_log_events'
);
//5. Creating an obj to return a json

@ -184,7 +184,7 @@ class Statistics
* Count activities from track_e_default_table
* @return int Number of activities counted
*/
public static function getNumberOfActivities()
public static function getNumberOfActivities($courseId = 0, $session = 0)
{
// Database table definitions
$track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
@ -204,6 +204,12 @@ class Statistics
WHERE default_user_id = user.user_id ";
}
if (!empty($courseId)) {
$courseId = (int) $courseId;
$sql .= " AND c_id = $courseId";
$sql .= api_get_session_condition($sessionId);
}
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (
@ -225,13 +231,18 @@ class Statistics
* @param int $numberOfItems
* @param int $column
* @param string $direction
* @param int $courseId
* @param int $sessionId
*
* @return array
*/
public static function getActivitiesData(
$from,
$numberOfItems,
$column,
$direction
$direction,
$courseId = 0,
$sessionId = 0
) {
$track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
@ -284,6 +295,12 @@ class Statistics
default_value LIKE '%".$keyword."%') ";
}
if (!empty($courseId)) {
$courseId = (int) $courseId;
$sql .= " AND c_id = $courseId";
$sql .= api_get_session_condition($sessionId);
}
if (!empty($column) && !empty($direction)) {
$sql .= " ORDER BY col$column $direction";
} else {
@ -317,9 +334,13 @@ class Statistics
}
if (!empty($row[5])) {
//course
// Course
if (!empty($row[3])) {
$row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH).'admin/course_edit.php?id='.$row[3]);
$row[3] = Display::url(
$row[3],
api_get_path(WEB_CODE_PATH).'admin/course_edit.php?id='.$row[3]
);
} else {
$row[3] = '-';
}
@ -337,8 +358,8 @@ class Statistics
// User id.
$row[5] = Display::url(
$row[5],
api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$row[6],
array('title' => get_lang('UserInfo'))
api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$row[6],
array('class' => 'ajax')
);
$row[6] = Tracking::get_ip_from_user_event(
@ -780,9 +801,9 @@ class Statistics
);
$renderer = & $form->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$form->addElement('hidden', 'report', 'activities');
$form->addElement('hidden', 'activities_direction', 'DESC');
$form->addElement('hidden', 'activities_column', '4');
$form->addHidden('report', 'activities');
$form->addHidden('activities_direction', 'DESC');
$form->addHidden('activities_column', '4');
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addButtonSearch(get_lang('Search'), 'submit');
echo '<div class="actions">';

@ -0,0 +1,171 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.tracking
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
// Access restrictions.
$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
if (!$is_allowedToTrack) {
api_not_allowed(true);
}
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$exportXls = isset($_GET['export']) && $_GET['export'] == 'xls' ? true : false;
$course_id = api_get_course_int_id();
$course_code = api_get_course_id();
$sessionId = api_get_session_id();
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : '';
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=course_log_events&'.api_get_cidreq().'&keyword='.$keyword;
// The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(
get_lang('EventType'),
get_lang('DataType'),
get_lang('Value'),
get_lang('Course'),
get_lang('Session'),
get_lang('UserName'),
get_lang('IPAddress'),
get_lang('Date')
);
// Column config
$column_model = array(
array(
'name' => 'col0',
'index' => 'col0',
'width' => '50',
'align' => 'left',
'sortable' => 'false'
),
array(
'name' => 'col1',
'index' => 'col1',
'width' => '60',
'align' => 'left',
'sortable' => 'false',
),
array(
'name' => 'col2',
'index' => 'col2',
'width' => '200',
'align' => 'left',
'sortable' => 'false',
),
array(
'name' => 'col3',
'index' => 'col3',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
'hidden' => 'true'
),
array(
'name' => 'col4',
'index' => 'col4',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
'hidden' => 'true'
),
array(
'name' => 'col5',
'index' => 'col5',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
),
array(
'name' => 'col6',
'index' => 'col6',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
),
array(
'name' => 'col7',
'index' => 'col7',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
)
);
// Autowidth
$extra_params['autowidth'] = 'true';
// height auto
$extra_params['height'] = 'auto';
$action_links = '
function action_formatter(cellvalue, options, rowObject) {
return \'<a href="course_log_tools.php?id_session=0&cidReq='.$course_code.'&gidReq=\'+options.rowId+\'">'.Display::return_icon('2rightarrow.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
'\';
}';
// Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = '
<script>
$(function() {
'.Display::grid_js(
'course_log_events',
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
).'
});
</script>';
Display::display_header();
echo '<div class="actions">';
echo Display::url(
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
'courseLog.php?'.api_get_cidreq(true, false)
);
echo Display::url(Display::return_icon('group.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), '#');
echo Display::url(
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
'course_log_tools.php?'.api_get_cidreq(true, false)
);
echo Display::url(
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
'course_log_resources.php?'.api_get_cidreq(true, false)
);
echo '</div>';
$form = new FormValidator(
'search_simple',
'get',
api_get_self().'?'.api_get_cidreq(),
'',
'',
FormValidator::LAYOUT_INLINE
);
$form->addHidden('report', 'activities');
$form->addHidden('activities_direction', 'DESC');
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addButtonSearch(get_lang('Search'), 'submit');
echo '<div class="actions">';
$form->display();
echo '</div>';
echo Display::grid_html('course_log_events');
Display::display_footer();

@ -109,17 +109,35 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = '
<script>
$(function() {
'.Display::grid_js('group_users', $url, $columns, $column_model, $extra_params, array(), $action_links, true).'
'.Display::grid_js(
'group_users',
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
).'
});
</script>';
Display::display_header();
echo '<div class="actions">';
echo Display::url(Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM), 'courseLog.php?'.api_get_cidreq(true, false));
echo Display::url(
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
'courseLog.php?'.api_get_cidreq(true, false)
);
echo Display::url(Display::return_icon('group_na.png', get_lang('GroupReporting'), array(), ICON_SIZE_MEDIUM), '#');
echo Display::url(Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_tools.php?'.api_get_cidreq(true, false));
echo Display::url(Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM), 'course_log_resources.php?'.api_get_cidreq(true, false));
echo Display::url(
Display::return_icon('course.png', get_lang('CourseTracking'), array(), ICON_SIZE_MEDIUM),
'course_log_tools.php?'.api_get_cidreq(true, false)
);
echo Display::url(
Display::return_icon('tools.png', get_lang('ResourcesTracking'), array(), ICON_SIZE_MEDIUM),
'course_log_resources.php?'.api_get_cidreq(true, false)
);
echo '</div>';
echo Display::grid_html('group_users');

@ -2,14 +2,12 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.tracking
* @package chamilo.tracking
*/
$pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
// Including the global initialization file
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$course_info = api_get_course_info();
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
@ -24,8 +22,7 @@ if ($from == 'myspace') {
$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
if (!$is_allowedToTrack) {
api_not_allowed();
exit;
api_not_allowed(true);
}
// Starting the output buffering when we are exporting the information.
@ -83,18 +80,24 @@ if (empty($session_id)) {
// Breadcrumbs.
if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'session/session_list.php', 'name' => get_lang('SessionList'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.api_get_session_id(), 'name' => get_lang('SessionOverview'));
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'admin/index.php',
'name' => get_lang('PlatformAdmin'),
);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php',
'name' => get_lang('SessionList'),
);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.api_get_session_id(),
'name' => get_lang('SessionOverview'),
);
}
$nameTools = get_lang('Tracking');
// Display the header.
Display::display_header($nameTools, 'Tracking');
/* MAIN CODE */
echo '<div class="actions">';
echo Display::url(
Display::return_icon('user.png', get_lang('StudentsTracking'), array(), ICON_SIZE_MEDIUM),
@ -131,7 +134,6 @@ echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_pa
'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=xls&'.$addional_param.$users_tracking_per_page.'">
'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</span>';
echo '</div>';
@ -164,7 +166,6 @@ $table = new SortableTable(
);
$parameters = array(
//'keyword' => Security::remove_XSS($_GET['keyword']),
'id_session' => $session_id,
'cidReq' => api_get_course_id()
);

Loading…
Cancel
Save