Restores admin view in reports see #7477

1.9.x
Julio Montoya 10 years ago
parent 7f55f83751
commit 299ba99439
  1. 8
      main/inc/lib/display.lib.php
  2. 63
      main/mySpace/admin_view.php
  3. 72
      main/mySpace/index.php
  4. 375
      main/mySpace/myspace.lib.php
  5. 200
      main/tracking/course_session_report.php
  6. 2
      main/tracking/exams.php
  7. 186
      main/tracking/question_course_report.php

@ -1795,16 +1795,20 @@ class Display
* @param array $items
* @return null|string
*/
public static function actions($items)
public static function actions($items, $class = 'new_actions')
{
$html = null;
if (!empty($items)) {
$html = '<div class="new_actions"><ul class="nav nav-pills">';
$html = '<div class="'.$class.'"><ul class="nav nav-pills">';
foreach ($items as $value) {
$class = null;
if (isset($value['active']) && $value['active']) {
$class = 'class ="active"';
}
if (basename($_SERVER['REQUEST_URI']) == basename($value['url']) ) {
$class = 'class ="active"';
}
$html .= "<li $class >";
$html .= self::url($value['content'], $value['url']);
$html .= '</li>';

@ -0,0 +1,63 @@
<?php
/* For licensing terms, see /license.txt */
$language_file = array('registration', 'index', 'tracking', 'admin', 'exercice');
$cidReset = true;
require_once '../inc/global.inc.php';
// including additional libraries
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once 'myspace.lib.php';
$exportCSV = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
$htmlHeadXtra[] = api_get_jqgrid_js();
// the section (for the tabs)
$this_section = SECTION_TRACKING;
$csv_content = array();
$nameTools = get_lang('MySpace');
$is_platform_admin = api_is_platform_admin();
$is_drh = api_is_drh();
$is_session_admin = api_is_session_admin();
if ($exportCSV) {
if ($display == 'user') {
MySpace::export_tracking_user_overview();
exit;
} elseif ($display == 'session') {
MySpace::export_tracking_session_overview();
exit;
} elseif ($display == 'course') {
MySpace::export_tracking_course_overview();
exit;
}
}
Display :: display_header($nameTools);
echo '<div class="actions">';
echo MySpace::getTopMenu();
echo '</div>';
echo MySpace::getAdminActions();
switch ($display) {
case 'coaches':
MySpace::display_tracking_coach_overview($exportCSV);
break;
case 'user':
MySpace::display_tracking_user_overview();
break;
case 'session':
MySpace::display_tracking_session_overview();
break;
case 'course':
MySpace::display_tracking_course_overview();
break;
}
Display::display_footer();

@ -1,12 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Homepage for the MySpace directory
* @package chamilo.reporting
*/
/**
* code
*/
$language_file = array('registration', 'index', 'tracking', 'admin', 'exercice');
// resetting the course id
@ -48,19 +47,6 @@ api_block_anonymous_users();
if (!$export_csv) {
Display :: display_header($nameTools);
} else {
if ($_GET['view'] == 'admin') {
if ($display == 'useroverview') {
MySpace::export_tracking_user_overview();
exit;
} elseif ($display == 'sessionoverview') {
MySpace::export_tracking_session_overview();
exit;
} elseif ($display == 'courseoverview') {
MySpace::export_tracking_course_overview();
exit;
}
}
}
// Database table definitions
@ -87,15 +73,38 @@ $menu_items = array();
if ($is_platform_admin) {
if ($view == 'admin') {
$title = get_lang('CoachList');
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=teacher');
$menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=admin');
$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
$menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
$menu_items[] = Display::url(
Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM),
api_get_self().'?view=teacher'
);
$menu_items[] = Display::url(
Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php'
);
$menu_items[] = Display::url(
Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'tracking/exams.php'
);
$menu_items[] = Display::url(
Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php'
);
} else {
$menu_items[] = Display::url(Display::return_icon('teacher_na.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), '');
$menu_items[] = Display::url(Display::return_icon('star.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=admin');
$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
$menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
$menu_items[] = Display::url(
Display::return_icon('teacher_na.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), '');
$menu_items[] = Display::url(
Display::return_icon('star.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM),
//api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin'
api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php'
);
$menu_items[] = Display::url(
Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'tracking/exams.php'
);
$menu_items[] = Display::url(
Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php'
);
}
}
@ -121,7 +130,9 @@ echo '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</span>';
if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview','exerciseprogress', 'surveyoverview'))) {
if (!empty($session_id) &&
!in_array($display, array('accessoverview','lpprogressoverview','progressoverview','exerciseprogress', 'surveyoverview'))
) {
echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
if (!api_is_platform_admin()) {
if (api_get_setting('add_users_by_coach') == 'true') {
@ -139,12 +150,17 @@ if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogres
echo "</div><br />";
}
} else {
echo Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php");
echo Display::url(
Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
);
}
// Actions menu
$nb_menu_items = count($menu_items);
if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview', 'exerciseprogress', 'surveyoverview'))) {
if (empty($session_id) ||
in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview', 'exerciseprogress', 'surveyoverview'))
) {
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
@ -188,8 +204,8 @@ $inactiveTime = time() - (3600 * 24 * 7);
$nb_students = 0;
$numberTeachers = 0;
$countHumanResourcesUsers = 0;
$daysAgo = 7;
$studentIds = array();
if (!empty($students)) {
// Students
$nb_students = count($students);

@ -10,6 +10,41 @@ require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
*/
class MySpace
{
/**
* Get admin actions
* @return string
*/
public static function getAdminActions()
{
$actions = array(
//array('url' => api_get_path(WEB_CODE_PATH).'mySpace/index.php', 'content' => get_lang('Home')),
array('url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=coaches', 'content' => get_lang('DisplayCoaches')),
array('url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=user', 'content' => get_lang('DisplayUserOverview')),
array('url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=session', 'content' => get_lang('DisplaySessionOverview')),
array('url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=course', 'content' => get_lang('DisplayCourseOverview')),
array('url' => api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin', 'content' => get_lang('LPQuestionListResults')),
array('url' => api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin', 'content' => get_lang('LPExerciseResultsBySession')),
);
return Display :: actions($actions, null);
}
public static function getTopMenu()
{
$menu_items = array();
$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher');
$menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32), '#');
$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
$menu = null;
foreach ($menu_items as $item) {
$menu .= $item;
}
$menu .= '<br />';
return $menu;
}
/**
* This function serves exporting data in CSV format.
* @param array $header The header labels.
@ -156,9 +191,10 @@ class MySpace
* @param array $row the row information (the other columns)
* @return string html code
*/
function course_info_tracking_filter($user_id, $url_params, $row) {
public static function course_info_tracking_filter($user_id, $url_params, $row)
{
// the table header
$return .= '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$return = '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
/*$return .= ' <tr>';
$return .= ' <th>'.get_lang('Course').'</th>';
$return .= ' <th>'.get_lang('AvgTimeSpentInTheCourse').'</th>';
@ -226,10 +262,11 @@ class MySpace
* @version Dokeos 1.8.6
* @since October 2008
*/
function display_tracking_user_overview() {
public static function display_tracking_user_overview()
{
MySpace::display_user_overview_export_options();
$t_head .= ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
//$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>';
$t_head .= '<tr>';
$t_head .= ' <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
@ -265,6 +302,202 @@ class MySpace
$table->set_column_filter(4, array('MySpace','course_info_tracking_filter'));
$table->display();
}
public static function display_tracking_coach_overview($export_csv)
{
global $_configuration;
if ($export_csv) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
} else {
$is_western_name_order = api_is_western_name_order();
}
$sort_by_first_name = api_sort_by_first_name();
$tracking_column = isset($_GET['tracking_list_coaches_column']) ? $_GET['tracking_list_coaches_column'] : ($is_western_name_order xor $sort_by_first_name) ? 1 : 0;
$tracking_direction = (isset($_GET['tracking_list_coaches_direction']) && in_array(strtoupper($_GET['tracking_list_coaches_direction']), array('ASC', 'DESC', 'ASCENDING', 'DESCENDING', '0', '1'))) ? $_GET['tracking_list_coaches_direction'] : 'DESC';
// Prepare array for column order - when impossible, use some of user names.
if ($is_western_name_order) {
$order = array(0 => 'firstname', 1 => 'lastname', 2 => ($sort_by_first_name ? 'firstname' : 'lastname'), 3 => 'login_date', 4 => ($sort_by_first_name ? 'firstname' : 'lastname'), 5 => ($sort_by_first_name ? 'firstname' : 'lastname'));
} else {
$order = array(0 => 'lastname', 1 => 'firstname', 2 => ($sort_by_first_name ? 'firstname' : 'lastname'), 3 => 'login_date', 4 => ($sort_by_first_name ? 'firstname' : 'lastname'), 5 => ($sort_by_first_name ? 'firstname' : 'lastname'));
}
$table = new SortableTable('tracking_list_coaches_myspace', array('MySpace', 'count_coaches'), null, ($is_western_name_order xor $sort_by_first_name) ? 1 : 0);
$parameters['view'] = 'admin';
$table->set_additional_parameters($parameters);
if ($is_western_name_order) {
$table -> set_header(0, get_lang('FirstName'), true);
$table -> set_header(1, get_lang('LastName'), true);
} else {
$table -> set_header(0, get_lang('LastName'), true);
$table -> set_header(1, get_lang('FirstName'), true);
}
$table -> set_header(2, get_lang('TimeSpentOnThePlatform'), false);
$table -> set_header(3, get_lang('LastConnexion'), false);
$table -> set_header(4, get_lang('NbStudents'), false);
$table -> set_header(5, get_lang('CountCours'), false);
$table -> set_header(6, get_lang('NumberOfSessions'), false);
$table -> set_header(7, get_lang('Sessions'), false);
if ($is_western_name_order) {
$csv_header[] = array (
get_lang('FirstName', ''),
get_lang('LastName', ''),
get_lang('TimeSpentOnThePlatform', ''),
get_lang('LastConnexion', ''),
get_lang('NbStudents', ''),
get_lang('CountCours', ''),
get_lang('NumberOfSessions', '')
);
} else {
$csv_header[] = array (
get_lang('LastName', ''),
get_lang('FirstName', ''),
get_lang('TimeSpentOnThePlatform', ''),
get_lang('LastConnexion', ''),
get_lang('NbStudents', ''),
get_lang('CountCours', ''),
get_lang('NumberOfSessions', '')
);
}
$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
$sqlCoachs = "SELECT DISTINCT scu.id_user as id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
FROM $tbl_user, $tbl_session_course_user scu, $tbl_track_login
WHERE scu.id_user=user_id AND scu.status=2 AND login_user_id=user_id
GROUP BY user_id ";
if ($_configuration['multiple_access_urls']) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sqlCoachs = "SELECT DISTINCT scu.id_user as id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
FROM $tbl_user, $tbl_session_course_user scu, $tbl_track_login , $tbl_session_rel_access_url session_rel_url
WHERE scu.id_user=user_id AND scu.status=2 AND login_user_id=user_id AND access_url_id = $access_url_id AND session_rel_url.session_id=id_session
GROUP BY user_id ";
}
}
if (!empty($order[$tracking_column])) {
$sqlCoachs .= "ORDER BY ".$order[$tracking_column]." ".$tracking_direction;
}
$result_coaches = Database::query($sqlCoachs);
$total_no_coaches = Database::num_rows($result_coaches);
$global_coaches = array();
while ($coach = Database::fetch_array($result_coaches)) {
$global_coaches[$coach['user_id']] = $coach;
}
$sql_session_coach = 'SELECT session.id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
FROM '.$tbl_user.','.$tbl_sessions.' as session,'.$tbl_track_login.'
WHERE id_coach=user_id AND login_user_id=user_id
GROUP BY user_id
ORDER BY login_date '.$tracking_direction;
if ($_configuration['multiple_access_urls']) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql_session_coach = 'SELECT session.id_coach, user_id, lastname, firstname, MAX(login_date) as login_date
FROM '.$tbl_user.','.$tbl_sessions.' as session,'.$tbl_track_login.' , '.$tbl_session_rel_access_url.' as session_rel_url
WHERE id_coach=user_id AND login_user_id=user_id AND access_url_id = '.$access_url_id.' AND session_rel_url.session_id=session.id
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;
if ($is_western_name_order) {
$csv_content[] = array(
api_html_entity_decode($coaches['firstname'], ENT_QUOTES, $charset),
api_html_entity_decode($coaches['lastname'], ENT_QUOTES, $charset),
$time_on_platform,
$last_connection,
$nb_students,
$nb_courses,
$nb_sessions
);
} else {
$csv_content[] = array(
api_html_entity_decode($coaches['lastname'], ENT_QUOTES, $charset),
api_html_entity_decode($coaches['firstname'], ENT_QUOTES, $charset),
$time_on_platform,
$last_connection,
$nb_students,
$nb_courses,
$nb_sessions
);
}
}
if ($tracking_column != 3) {
if ($tracking_direction == 'DESC') {
usort($all_datas, array('MySpace','rsort_users'));
} else {
usort($all_datas, array('MySpace','sort_users'));
}
}
if ($export_csv && $tracking_column != 3) {
usort($csv_content, 'sort_users');
}
if ($export_csv) {
$csv_content = array_merge($csv_header, $csv_content);
}
foreach ($all_datas as $row) {
$table -> addRow($row, 'align="right"');
}
$table -> display();
}
public static function count_coaches() {
global $total_no_coaches;
return $total_no_coaches;
}
public static function sort_users($a, $b) {
return api_strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
}
public static function rsort_users($a, $b) {
return api_strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
}
/**
* Display a sortable table that contains an overview off all the progress of the user in a session
* @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
@ -520,7 +753,7 @@ class MySpace
$table = Display::grid_js($tableId, $url, $column, $column_model, $extra_params, array(), '', true);
$return = '<script>$(function() {' . $table .
'jQuery("#' . $tableId . '").jqGrid("navGrid","#' . $tableId . '_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
'jQuery("#' . $tableId . '").jqGrid("navGrid","#' . $tableId . '_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
jQuery("#' . $tableId . '").jqGrid("navButtonAdd","#' . $tableId . '_pager",{
caption:"",
title:"' . get_lang('ExportExcel') . '",
@ -611,7 +844,7 @@ class MySpace
*/
static function display_tracking_progress_overview($sessionId = 0, $courseId = 0, $date_from, $date_to)
{
//The order is important you need to check the the $column variable in the model.ajax.php file
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(
get_lang('LastName'),
get_lang('FirstName'),
@ -724,37 +957,37 @@ class MySpace
"startColumnName" => 'courses',
"numberOfColumns" => 7,
"titleText" => get_lang('Global'),
),
),
'lessons' => array(
"startColumnName" => 'lessons_total',
"numberOfColumns" => 4,
"titleText" => get_lang('LearningPaths'),
),
),
'exercises' => array(
"startColumnName" => 'exercises_total',
"numberOfColumns" => 4,
"titleText" => get_lang('Exercises'),
),
),
'forums' => array(
"startColumnName" => 'forums_total',
"numberOfColumns" => 4,
"titleText" => get_lang('Forums'),
),
),
'assignments' => array(
"startColumnName" => 'assigments_total',
"numberOfColumns" => 4,
"titleText" => get_lang('Assignments'),
),
),
'wikis' => array(
"startColumnName" => 'wiki_total',
"numberOfColumns" => 5,
"titleText" => get_lang('Wiki'),
),
),
'surveys' => array(
"startColumnName" => 'surveys_total',
"numberOfColumns" => 4,
"titleText" => get_lang('Survey'),
),
),
);
//height auto
$extra_params['height'] = 'auto';
@ -849,10 +1082,9 @@ class MySpace
* @version Dokeos 1.8.6
* @since November 2008
*/
function display_user_overview_export_options() {
public static function display_user_overview_export_options()
{
// include the user manager and formvalidator library
if ($_GET['export'] == 'options') {
// get all the defined extra fields
$extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC', false, 1);
@ -928,10 +1160,10 @@ class MySpace
/**
* Display a sortable table that contains an overview of all the reporting progress of all courses
*/
function display_tracking_course_overview() {
public static function display_tracking_course_overview() {
//MySpace::display_user_overview_export_options();
$t_head .= ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
//$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>';
$t_head .= '<tr>';
$t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
@ -950,7 +1182,7 @@ class MySpace
$addparams = array('view' => 'admin', 'display' => 'courseoverview');
$table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1);
$table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1);
$table->additional_parameters = $addparams;
$table->set_header(0, '', false, null, array('style' => 'display: none'));
@ -965,7 +1197,8 @@ class MySpace
*
* @return integer Total number of courses
*/
public function get_total_number_courses() {
public static function get_total_number_courses()
{
// database table definition
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
return Database::count_rows($main_course_table);
@ -980,7 +1213,8 @@ class MySpace
* @param string Order direction
* @return array Results
*/
public function get_course_data_tracking_overview($from, $number_of_items, $column, $direction) {
public static function get_course_data_tracking_overview($from, $number_of_items, $column, $direction)
{
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$from = intval($from);
$number_of_items = intval($number_of_items);
@ -1004,10 +1238,11 @@ class MySpace
* @param array $row the row information (the other columns)
* @return string html code
*/
function course_tracking_filter($course_code, $url_params, $row) {
public static function course_tracking_filter($course_code, $url_params, $row)
{
$course_code = $row[0];
// the table header
$return .= '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$return = '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
// database table definition
$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@ -1107,7 +1342,8 @@ class MySpace
* This function exports the table that we see in display_tracking_course_overview()
*
*/
function export_tracking_course_overview() {
public static function export_tracking_course_overview()
{
// database table definition
$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -1248,10 +1484,11 @@ class MySpace
* Display a sortable table that contains an overview of all the reporting progress of all sessions and all courses the user is subscribed to
* @author Guillaume Viguier <guillaume@viguierjust.com>
*/
function display_tracking_session_overview() {
public static function display_tracking_session_overview()
{
//MySpace::display_user_overview_export_options();
$t_head .= ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
//$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>';
$t_head .= '<tr>';
$t_head .= ' <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
@ -1277,7 +1514,7 @@ class MySpace
$table->set_header(0, '', false, null, array('style' => 'display: none'));
$table->set_header(1, get_lang('Session'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
$table->set_column_filter(2, array('MySpace','session_tracking_filter'));
$table->set_column_filter(2, array('MySpace', 'session_tracking_filter'));
$table->display();
}
@ -1286,7 +1523,8 @@ class MySpace
*
* @return integer Total number of sessions
*/
public function get_total_number_sessions() {
public static function get_total_number_sessions()
{
// database table definition
$main_session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
return Database::count_rows($main_session_table);
@ -1301,7 +1539,8 @@ class MySpace
* @param string Order direction
* @return array Results
*/
public function get_session_data_tracking_overview($from, $number_of_items, $column, $direction) {
public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction)
{
//global $_configuration;
// database table definition
//$access_url_id = api_get_current_access_url_id();
@ -1337,10 +1576,11 @@ class MySpace
* @param array $row the row information (the other columns)
* @return string html code
*/
function session_tracking_filter($session_id, $url_params, $row) {
public static function session_tracking_filter($session_id, $url_params, $row)
{
$session_id = $row[0];
// the table header
$return .= '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$return = '<table class="data_table" style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
/*$return .= ' <tr>';
$return .= ' <th>'.get_lang('Course').'</th>';
$return .= ' <th>'.get_lang('AvgTimeSpentInTheCourse').'</th>';
@ -1463,7 +1703,8 @@ class MySpace
* This function exports the table that we see in display_tracking_session_overview()
*
*/
function export_tracking_session_overview() {
public static function export_tracking_session_overview()
{
// database table definition
$tbl_session_rel_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -1612,7 +1853,6 @@ class MySpace
exit;
}
/**
* Get general information about the exercise performance of the user
* the total obtained score (all the score on all the questions)
@ -1626,7 +1866,8 @@ class MySpace
* @version Dokeos 1.8.6
* @since November 2008
*/
function exercises_results($user_id, $course_code, $session_id = false) {
public static function exercises_results($user_id, $course_code, $session_id = false)
{
$questions_answered = 0;
$sql = 'SELECT exe_result , exe_weighting
FROM '.Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES)."
@ -1651,7 +1892,12 @@ class MySpace
$percentage = null;
}
return array('score_obtained' => $score_obtained, 'score_possible' => $score_possible, 'questions_answered' => $questions_answered, 'percentage' => $percentage);
return array(
'score_obtained' => $score_obtained,
'score_possible' => $score_possible,
'questions_answered' => $questions_answered,
'percentage' => $percentage
);
}
/**
@ -1661,9 +1907,8 @@ class MySpace
* @version Dokeos 1.8.6
* @since October 2008
*/
function export_tracking_user_overview() {
public static function export_tracking_user_overview()
{
// database table definitions
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@ -1788,7 +2033,8 @@ class MySpace
* Get data for courses list in sortable with pagination
* @return array
*/
static function get_course_data($from, $number_of_items, $column, $direction) {
public static function get_course_data($from, $number_of_items, $column, $direction)
{
global $courses, $csv_content, $charset, $session_id;
// definition database tables
@ -1894,7 +2140,8 @@ class MySpace
* @version Dokeos 1.8.6
* @since October 2008
*/
function get_number_of_users_tracking_overview() {
public static function get_number_of_users_tracking_overview()
{
// database table definition
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
return Database::count_rows($main_user_table);
@ -1907,7 +2154,8 @@ class MySpace
* @version Dokeos 1.8.6
* @since October 2008
*/
function get_user_data_tracking_overview($from, $number_of_items, $column, $direction) {
public static function get_user_data_tracking_overview($from, $number_of_items, $column, $direction)
{
global $_configuration;
// database table definition
$access_url_id = api_get_current_access_url_id();
@ -1933,7 +2181,7 @@ class MySpace
lastname AS col1,
firstname AS col2,
").
"username AS col3,
"username AS col3,
user.user_id AS col4
FROM
$main_user_table as user $condition_multi_url
@ -1956,7 +2204,8 @@ class MySpace
* @version Dokeos 1.8.6
* @since November 2008
*/
function get_user_overview_export_extra_fields($user_id) {
public static function get_user_overview_export_extra_fields($user_id)
{
// include the user manager
$extra_data = UserManager::get_extra_user_data($user_id, true);
@ -1972,7 +2221,8 @@ class MySpace
* @return array with the username, the sufix
* @author Julio Montoya Armas
*/
function make_username($firstname, $lastname, $username, $language = null, $encoding = null) {
public static function make_username($firstname, $lastname, $username, $language = null, $encoding = null)
{
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// if username exist
@ -2006,7 +2256,8 @@ class MySpace
* @return array with the $usernames array and the $user_array array
* @author Julio Montoya Armas
*/
function check_user_in_array($usernames, $user_array) {
public static function check_user_in_array($usernames, $user_array)
{
$user_list = array_keys($usernames);
$username = $user_array['username'].$user_array['sufix'];
@ -2028,7 +2279,8 @@ class MySpace
* @return 0 if the user is not subscribed otherwise it returns the user_id of the given username
* @author Julio Montoya Armas
*/
function user_available_in_session($username, $course_list, $id_session) {
public static function user_available_in_session($username, $course_list, $id_session)
{
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$id_session = intval($id_session);
@ -2036,7 +2288,11 @@ class MySpace
foreach($course_list as $enreg_course) {
$sql_select = " SELECT u.user_id FROM $tbl_session_rel_course_rel_user rel INNER JOIN $table_user u
ON (rel.id_user=u.user_id)
WHERE rel.id_session='$id_session' AND u.status='5' AND u.username ='$username' AND rel.course_code='$enreg_course'";
WHERE
rel.id_session='$id_session' AND
u.status='5' AND
u.username ='$username' AND
rel.course_code='$enreg_course'";
$rs = Database::query($sql_select);
if (Database::num_rows($rs) > 0) {
return Database::result($rs, 0, 0);
@ -2053,7 +2309,7 @@ class MySpace
Of course, if in the database there is a user with the name jmontoya, the newly created two users registered would be jmontoya2 and jmontoya3.
@param $users list of users
@author Julio Montoya Armas
*/
*/
function check_all_usernames($users, $course_list, $id_session) {
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$usernames = array();
@ -2152,7 +2408,7 @@ class MySpace
$user['UserName'] = trim($user['UserName']);
if (empty($user['UserName'])) {
$user['UserName'] = UserManager::create_username($user['FirstName'], $user['LastName']);
$user['UserName'] = UserManager::create_username($user['FirstName'], $user['LastName']);
}
$new_users[] = $user;
}
@ -2486,7 +2742,7 @@ function get_connections_to_course_by_date($user_id, $course_code, $start_date,
function convert_to_array($sql_result){
$result_to_print = '<table>';
foreach ($sql_result as $key => $data) {
$result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
$result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
}
$result_to_print .= '</table>';
$result_to_print = array("result"=>$result_to_print);
@ -2506,7 +2762,7 @@ function convert_to_string($sql_result){
$result_to_print = '<table>';
if (!empty($sql_result)) {
foreach ($sql_result as $key => $data) {
$result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
$result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
}
}
$result_to_print .= '</table>';
@ -2551,7 +2807,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
$main_month_year[date('m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
$main_day[date('d-m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
if ($i > 500) {
break;
break;
}
$i++;
}
@ -2592,7 +2848,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data_set->GetData())) {
//if (0) {
//if (0) {
//if we already created the img
// echo 'in cache';
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
@ -2619,13 +2875,13 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
$test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
if (count($main_date) == 1) {
//Draw a graph
echo '<strong>'.$labels.'</strong><br/>';
$test->drawBarGraph($data_set->GetData(), $data_set->GetDataDescription(), TRUE);
//Draw a graph
echo '<strong>'.$labels.'</strong><br/>';
$test->drawBarGraph($data_set->GetData(), $data_set->GetDataDescription(), TRUE);
} else {
//Draw the line graph
$test->drawLineGraph($data_set->GetData(), $data_set->GetDataDescription());
$test->drawPlotGraph($data_set->GetData(), $data_set->GetDataDescription(), 3, 2, 255, 255, 255);
//Draw the line graph
$test->drawLineGraph($data_set->GetData(), $data_set->GetDataDescription());
$test->drawPlotGraph($data_set->GetData(), $data_set->GetDataDescription(), 3, 2, 255, 255, 255);
}
// Finish the graph
@ -2647,4 +2903,5 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
$foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8');
return $foo_img;
}
}

@ -1,11 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Report
* @package chamilo.tracking
*/
/**
* Code
*/
$language_file = array ('registration', 'index', 'tracking', 'exercice','survey');
$cidReset = true;
require_once '../inc/global.inc.php';
@ -20,25 +20,24 @@ require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
$this_section = "session_my_space";
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
if(!$is_allowedToTrack) {
api_not_allowed(true);
if (!$is_allowedToTrack) {
api_not_allowed(true);
}
$export_to_xls = false;
if (isset($_GET['export'])) {
$export_to_xls = true;
}
if (api_is_platform_admin() ) {
if (api_is_platform_admin() ) {
$global = true;
} else {
$global = false;
}
$global = true;
$session_id = intval($_GET['session_id']);
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : null;
if (empty($session_id)) {
$session_id = 1;
}
@ -69,54 +68,27 @@ $course_list = SessionManager::get_course_list_by_session_id($session_id);
if (!$export_to_xls) {
Display :: display_header(get_lang("MySpace"));
echo '<div class="actions" style ="font-size:10pt;" >';
if ($global) {
$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher');
$menu_items[] = Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32);
$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
$nb_menu_items = count($menu_items);
if($nb_menu_items>1) {
foreach($menu_items as $key=> $item) {
echo $item;
}
echo '<br />';
}
echo '<div class="actions">';
if ($global) {
echo MySpace::getTopMenu();
} else {
echo '<div style="float:left; clear:left">
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>';
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>';
}
echo '</div>';
if (api_is_platform_admin()) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=coaches">'.get_lang('DisplayCoaches').'</a> | ';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin">'.get_lang('LPQuestionListResults').'</a>';
echo ' | '.get_lang('LPExerciseResultsBySession').'';
}
if (api_is_platform_admin()) {
echo MySpace::getAdminActions();
}
echo '<h2>'.get_lang('LPExerciseResultsBySession').'</h2>';
$form->display();
Display::display_normal_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts'));
//echo '<h3>'.sprintf(get_lang('FilteringWithScoreX'), $filter_score).'%</h3>';
// echo '<a href="'.api_get_self().'?export=1&score='.$filter_score.'&exercise_id='.$exercise_id.'"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a><br /><br />';
}
$users = SessionManager::get_users_by_session($session_id);
$course_average = $course_average_counter = array();
@ -125,25 +97,25 @@ $main_result = array();
//Getting course list
foreach ($course_list as $current_course ) {
$course_info = api_get_course_info($current_course['code']);
$_course = $course_info;
$_course = $course_info;
$attempt_result = array();
//Getting LP list
$list = new learnpathList('', $current_course['code'], $session_id);
$lp_list = $list->get_flat_list();
// Looping LPs
foreach ($lp_list as $lp_id =>$lp) {
$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);
//Looping Chamilo Exercises in LP
foreach ($lp_list as $lp_id =>$lp) {
$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);
// Looping Chamilo Exercises in LP
foreach ($exercise_list as $exercise) {
$exercise_stats = get_all_exercise_event_from_lp($exercise['path'], $course_info['id'], $session_id);
//Looping Exercise Attempts
foreach($exercise_stats as $stats) {
$attempt_result[$stats['exe_user_id']]['result'] += $stats['exe_result'] / $stats['exe_weighting'];
$attempt_result[$stats['exe_user_id']]['attempts']++;
}
}
// Looping Exercise Attempts
foreach ($exercise_stats as $stats) {
$attempt_result[$stats['exe_user_id']]['result'] += $stats['exe_result'] / $stats['exe_weighting'];
$attempt_result[$stats['exe_user_id']]['attempts']++;
}
}
}
$main_result[$current_course['code']] = $attempt_result;
}
@ -152,15 +124,15 @@ foreach ($course_list as $current_course ) {
$total_average_score = 0;
$total_average_score_count = 0;
if (!empty($users) && is_array($users)) {
$html_result .= '<table class="data_table">';
$html_result .= '<tr><th>'.get_lang('User').'</th>';
foreach($course_list as $item ) {
$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>';
foreach($course_list as $item ) {
$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>';
}
$html_result .= '<th>'.get_lang('AverageScore').' %</th>';
$html_result .= '<th>'.get_lang('LastConnexionDate').'</th></tr>';
$html_result .= '<th>'.get_lang('LastConnexionDate').'</th></tr>';
foreach ($users as $user) {
$total_student = 0;
$counter ++;
@ -171,41 +143,51 @@ if (!empty($users) && is_array($users)) {
$html_result .= "<tr class='$s_css_class'>
<td >";
$html_result .= $user['firstname'].' '.$user['lastname'];
$html_result .= "</td>";
//Getting course list
$html_result .= "</td>";
// Getting course list
$counter = 0;
$total_result_by_user = 0;
foreach($course_list as $current_course ) {
$total_course = 0;
$user_info_stat = $main_result[$current_course['code']][$user['user_id']];
foreach ($course_list as $current_course ) {
$total_course = 0;
$html_result .= "<td>";
if (!empty($user_info_stat['result']) && !empty($user_info_stat['attempts'])) {
$result =round($user_info_stat['result']/$user_info_stat['attempts'] * 100, 2);
$total_course +=$result;
$total_result_by_user +=$result;
$course_average[$current_course['code']] += $total_course;
$course_average_counter[$current_course['code']]++;
$result = $result .' ('.$user_info_stat['attempts'].' '.get_lang('Attempts').')';
$counter++;
} else {
$result = '-';
$result = '-';
if (isset($main_result[$current_course['code']][$user['user_id']])) {
$user_info_stat = $main_result[$current_course['code']][$user['user_id']];
if (!empty($user_info_stat['result']) && !empty($user_info_stat['attempts'])) {
$result = round(
$user_info_stat['result'] / $user_info_stat['attempts'] * 100,
2
);
$total_course += $result;
$total_result_by_user += $result;
$course_average[$current_course['code']] += $total_course;
$course_average_counter[$current_course['code']]++;
$result = $result . ' (' . $user_info_stat['attempts'] . ' ' . get_lang(
'Attempts'
) . ')';
$counter++;
}
}
$html_result .= $result;
$html_result .= "</td>";
}
}
if (empty($counter)) {
$total_student = '-';
} else {
} 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 .="<td>$total_student</td><td>$string_date</td></tr>";
}
$html_result .="<tr><th>".get_lang('AverageScore')."</th>";
$total_average = 0;
$counter = 0;
@ -216,28 +198,28 @@ if (!empty($users) && is_array($users)) {
$average_per_course = '-';
}
if (!empty($average_per_course)) {
$counter++;
$counter++;
}
$total_average = $total_average + $average_per_course;
$html_result .="<td>$average_per_course</td>";
}
}
if (!empty($total_average_score_count)) {
$total_average = round($total_average_score/($total_average_score_count*100)*100,2);
} else {
$total_average = '-';
}
$html_result .='<td>'.$total_average.'</td>';
$html_result .="<td>-</td>";
$html_result .="</tr>";
$html_result .= '</table>';
} else {
} else {
Display::display_warning_message(get_lang('NoResults'));
}
if (!$export_to_xls) {
echo $html_result;
echo $html_result;
}
$filename = 'exam-reporting-'.date('Y-m-d-h:i:s').'.xls';
@ -256,27 +238,27 @@ function sort_user($a, $b) {
}
return 0;
}
return 1;
return 1;
}
function export_complete_report_xls($filename, $array) {
global $charset;
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8); // BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
/*
$line = 0;
$column = 1; // Skip the first column (row titles)
foreach ($array as $elem) {
$worksheet->write($line, $column, $elem);
$column++;
}
$workbook->close();*/
exit;
global $charset;
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8); // BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
/*
$line = 0;
$column = 1; // Skip the first column (row titles)
foreach ($array as $elem) {
$worksheet->write($line, $column, $elem);
$column++;
}
$workbook->close();*/
exit;
}
Display :: display_footer();

@ -107,7 +107,7 @@ if (!$exportToXLS) {
if (api_is_platform_admin()) {
$menuItems[] = Display::url(
Display::return_icon('star.png', get_lang('AdminInterface'), array(), 32),
api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin'
api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php'
);
} else {
$menuItems[] = Display::url(

@ -34,7 +34,7 @@ if (isset($_GET['export'])) {
$export_to_xls = true;
}
if (api_is_platform_admin() ) {
if (api_is_platform_admin() ) {
$global = true;
} else {
$global = false;
@ -46,21 +46,21 @@ $course_select_list[0] = get_lang('None');
$htmlHeadXtra[] = '
<script type="text/javascript">
function load_courses() {
function load_courses() {
document.search_simple.submit();
}
</script> ';
$session_id = intval($_REQUEST['session_id']);
$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null;
if (empty($session_id)) {
$temp_course_list = CourseManager :: get_courses_list();
} else {
$temp_course_list = SessionManager::get_course_list_by_session_id($session_id);
$temp_course_list = SessionManager::get_course_list_by_session_id($session_id);
}
foreach($temp_course_list as $temp_course_item) {
$course_item = CourseManager ::get_course_information($temp_course_item['code']);
$course_item = CourseManager ::get_course_information($temp_course_item['code']);
$course_list[]= array('db_name' =>$course_item['db_name'],'code'=>$course_item['code'], 'title'=>$course_item['title'], 'visual_code'=>$course_item['visual_code']);
$course_select_list[$temp_course_item['code']] = $course_item['title'];
}
@ -87,53 +87,53 @@ if (empty($course_code)) {
$form->setDefaults(array('course_code'=>(string)$course_code));
$course_info = api_get_course_info($course_code);
//var_dump($session_id);
if (!empty($course_info)) {
if (!empty($course_info)) {
$list = new learnpathList('', $course_code);
$lp_list = $list->get_flat_list();
$_course = $course_info;
$lp_list = $list->get_flat_list();
$_course = $course_info;
$main_question_list = array();
foreach ($lp_list as $lp_id =>$lp) {
$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);
//var_dump($exercise_list);
foreach ($exercise_list as $exercise) {
$my_exercise = new Exercise();
$exercise_list = get_all_exercises_from_lp($lp_id, $course_info['real_id']);
//var_dump($exercise_list);
foreach ($exercise_list as $exercise) {
$my_exercise = new Exercise();
//$my_exercise->read($exercise['ref']);
$my_exercise->read($exercise['path']);
$question_list = $my_exercise->selectQuestionList();
$exercise_stats = get_all_exercise_event_from_lp($exercise['path'],$course_info['id'], $session_id);
//echo '<pre>'; print_r($exercise_stats);
$question_list = $my_exercise->selectQuestionList();
$exercise_stats = get_all_exercise_event_from_lp($exercise['path'],$course_info['id'], $session_id);
//echo '<pre>'; print_r($exercise_stats);
foreach($question_list as $question_id) {
$question_data = Question::read($question_id);
///var_dump($question_data);
$main_question_list[$question_id] = $question_data;
///var_dump($question_data);
$main_question_list[$question_id] = $question_data;
$quantity_exercises = 0;
$question_result = 0;
//echo '<pre>';
//echo '<pre>';
//print_r($exercise_stats);
foreach($exercise_stats as $stats) {
if (!empty($stats['question_list'])) {
foreach($stats['question_list'] as $my_question_stat) {
// var_dump($my_question_stat);
if ($question_id == $my_question_stat['question_id']) {
//var_dump($my_question_stat);
$question_result = $question_result + $my_question_stat['marks'];
// var_dump($my_question_stat['marks']);
$quantity_exercises++;
// var_dump($my_question_stat);
if ($question_id == $my_question_stat['question_id']) {
//var_dump($my_question_stat);
$question_result = $question_result + $my_question_stat['marks'];
// var_dump($my_question_stat['marks']);
$quantity_exercises++;
}
}
}
}
//echo $question_id;
//var_dump($question_result.' - '.$quantity_exercises.$main_question_list[$question_id]->weighting);
if(!empty($quantity_exercises)) {
$main_question_list[$question_id]->results =(($question_result / ($quantity_exercises)) ) ; // Score % average
} else {
$main_question_list[$question_id]->results = 0;
}
$main_question_list[$question_id]->quantity = $quantity_exercises;
//echo $question_id;
//var_dump($question_result.' - '.$quantity_exercises.$main_question_list[$question_id]->weighting);
if(!empty($quantity_exercises)) {
$main_question_list[$question_id]->results =(($question_result / ($quantity_exercises)) ) ; // Score % average
} else {
$main_question_list[$question_id]->results = 0;
}
$main_question_list[$question_id]->quantity = $quantity_exercises;
}
}
}
@ -145,49 +145,31 @@ if (!empty($course_info)) {
//$course_list = SessionManager::get_course_list_by_session_id($session_id);
if (!$export_to_xls) {
Display :: display_header(get_lang("MySpace"));
echo '<div class="actions" style ="font-size:10pt;" >';
echo '<div class="actions">';
if ($global) {
$menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" );
$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher');
$menu_items[] = Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32);
$menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
$nb_menu_items = count($menu_items);
if($nb_menu_items>1) {
foreach($menu_items as $key=> $item) {
echo $item;
}
}
echo MySpace::getTopMenu();
} else {
echo '<div style="float:left; clear:left">
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>';
}
echo '</div>';
}
echo '</div>';
if (api_is_platform_admin()) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=coaches">'.get_lang('DisplayCoaches').'</a> | ';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=useroverview">'.get_lang('DisplayUserOverview').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
echo ' | '.get_lang('LPQuestionListResults');
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin">'.get_lang('LPExerciseResultsBySession').'</a>';
}
if (api_is_platform_admin()) {
echo MySpace::getAdminActions();
}
echo '<br />';
echo '<h2>'.get_lang('LPQuestionListResults').'</h2>';
$form->display();
//Display::display_normal_message(get_lang('QuestionsAreTakenFromLPExercises'));
if (empty($course_code)) {
Display::display_warning_message(get_lang('PleaseSelectACourse'));
}
Display::display_warning_message(get_lang('PleaseSelectACourse'));
}
}
$course_average = array();
@ -196,10 +178,10 @@ $counter = 0;
if (!empty($main_question_list) && is_array($main_question_list)) {
$html_result .= '<table class="data_table">';
$html_result .= '<tr><th>'.get_lang('Question').Display :: return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>';
$html_result .= '<tr><th>'.get_lang('Question').Display :: return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>';
$html_result .= '<th>'.$course_info['visual_code'].' '.get_lang('AverageScore').Display :: return_icon('info3.gif', get_lang('AllStudentsAttemptsAreConsidered'), array('align' => 'absmiddle', 'hspace' => '3px')).' </th>';
$html_result .= '<th>'.get_lang('Quantity').'</th>';
$html_result .= '<th>'.get_lang('Quantity').'</th>';
foreach($main_question_list as $question) {
$total_student = 0;
$counter ++;
@ -210,33 +192,33 @@ if (!empty($main_question_list) && is_array($main_question_list)) {
$html_result .= "<tr class='$s_css_class'>
<td >";
$question_title = trim($question->question);
if (empty($question_title)) {
if (empty($question_title)) {
$html_result .= get_lang('Untitled').' '.get_lang('Question').' #'.$question->id;
} else {
} else {
$html_result .= $question->question;
}
$html_result .= "</td>";
$html_result .= "<td>";
$html_result .= "<td>";
$html_result .= round($question->results, 2).' / '.$question->weighting;
$html_result .= "</td>";
$html_result .= "<td>";
$html_result .= $question->quantity;
$html_result .= "</td>";
$html_result .= "<td>";
$html_result .= $question->quantity;
$html_result .= "</td>";
}
$html_result .="</tr>";
$html_result .= '</table>';
} else {
} else {
if (!empty($course_code)) {
Display::display_warning_message(get_lang('NoResults'));
}
}
if (!$export_to_xls) {
echo $html_result;
echo $html_result;
}
$filename = 'exam-reporting-'.date('Y-m-d-h:i:s').'.xls';
@ -255,27 +237,27 @@ function sort_user($a, $b) {
}
return 0;
}
return 1;
return 1;
}
function export_complete_report_xls($filename, $array) {
global $charset;
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8); // BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
/*
$line = 0;
$column = 1; // Skip the first column (row titles)
foreach ($array as $elem) {
$worksheet->write($line, $column, $elem);
$column++;
}
$workbook->close();*/
exit;
global $charset;
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->send($filename);
$workbook->setVersion(8); // BIFF8
$worksheet =& $workbook->addWorksheet('Report');
//$worksheet->setInputEncoding(api_get_system_encoding());
$worksheet->setInputEncoding($charset);
/*
$line = 0;
$column = 1; // Skip the first column (row titles)
foreach ($array as $elem) {
$worksheet->write($line, $column, $elem);
$column++;
}
$workbook->close();*/
exit;
}
Display :: display_footer();

Loading…
Cancel
Save