|
|
|
@ -1,20 +1,29 @@ |
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Component\Utils\ChamiloApi; |
|
|
|
|
use ChamiloSession as Session; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @package chamilo.tracking |
|
|
|
|
*/ |
|
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
|
|
|
|
|
|
|
|
$current_course_tool = TOOL_TRACKING; |
|
|
|
|
$courseId = api_get_course_id(); |
|
|
|
|
$courseInfo = api_get_course_info($courseId); |
|
|
|
|
//keep course_code form as it is loaded (global) by the table's get_user_data |
|
|
|
|
$course_code = $courseCode = $courseInfo['code']; |
|
|
|
|
|
|
|
|
|
$courseInfo = api_get_course_info(); |
|
|
|
|
if (empty($courseInfo)) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
|
$is_allowedToTrack = Tracking::isAllowToTrack($sessionId); |
|
|
|
|
|
|
|
|
|
if (!$is_allowedToTrack) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//keep course_code form as it is loaded (global) by the table's get_user_data |
|
|
|
|
$courseCode = $courseInfo['code']; |
|
|
|
|
$courseId = $courseInfo['real_id']; |
|
|
|
|
|
|
|
|
|
// PERSON_NAME_DATA_EXPORT is buggy |
|
|
|
|
$sortByFirstName = api_sort_by_first_name(); |
|
|
|
|
$from_myspace = false; |
|
|
|
@ -33,12 +42,6 @@ if ($from === 'myspace') { |
|
|
|
|
$this_section = 'session_my_space'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$is_allowedToTrack = Tracking::isAllowToTrack($sessionId); |
|
|
|
|
|
|
|
|
|
if (!$is_allowedToTrack) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// If the user is a HR director (drh) |
|
|
|
|
if (api_is_drh()) { |
|
|
|
|
// Blocking course for drh |
|
|
|
@ -67,7 +70,7 @@ if (api_is_drh()) { |
|
|
|
|
// then check if he has also been given access to the corresponding courses |
|
|
|
|
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id()); |
|
|
|
|
$coursesFollowedList = array_keys($coursesFollowedList); |
|
|
|
|
if (!in_array($courseId, $coursesFollowedList)) { |
|
|
|
|
if (!in_array($courseCode, $coursesFollowedList)) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -102,11 +105,11 @@ $js = "<script> |
|
|
|
|
function(index) { |
|
|
|
|
$(this).prepend( |
|
|
|
|
'<div style=\"cursor:pointer\" onclick=\"foldup(' + index + ')\">".Display::return_icon( |
|
|
|
|
'visible.png', |
|
|
|
|
get_lang('HideColumn'), |
|
|
|
|
['align' => 'absmiddle', 'hspace' => '3px'], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
)."</div>' |
|
|
|
|
'visible.png', |
|
|
|
|
get_lang('HideColumn'), |
|
|
|
|
['align' => 'absmiddle', 'hspace' => '3px'], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
)."</div>' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
@ -159,10 +162,10 @@ $tpl = new Template($nameTools); |
|
|
|
|
// Getting all the students of the course |
|
|
|
|
if (empty($sessionId)) { |
|
|
|
|
// Registered students in a course outside session. |
|
|
|
|
$studentList = CourseManager::get_student_list_from_course_code($courseId); |
|
|
|
|
$studentList = CourseManager::get_student_list_from_course_code($courseCode); |
|
|
|
|
} else { |
|
|
|
|
// Registered students in session. |
|
|
|
|
$studentList = CourseManager::get_student_list_from_course_code($courseId, true, $sessionId); |
|
|
|
|
$studentList = CourseManager::get_student_list_from_course_code($courseCode, true, $sessionId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$nbStudents = count($studentList); |
|
|
|
@ -182,7 +185,6 @@ if (isset($_GET['additional_profile_field'])) { |
|
|
|
|
$fieldId, |
|
|
|
|
$user_array |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$extra_info[$fieldId] = UserManager::get_extra_field_information($fieldId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -210,7 +212,8 @@ if (isset($_GET['users_tracking_per_page'])) { |
|
|
|
|
$users_tracking_per_page = '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$actionsRight .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$additionalParams.$users_tracking_per_page.'"> |
|
|
|
|
$actionsRight .= '<a href="'.api_get_self().'?'.api_get_cidreq( |
|
|
|
|
).'&export=csv&'.$additionalParams.$users_tracking_per_page.'"> |
|
|
|
|
'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
$actionsRight .= '</div>'; |
|
|
|
|
// Create a search-box. |
|
|
|
@ -236,24 +239,24 @@ $course_name = get_lang('Course').' '.$courseInfo['name']; |
|
|
|
|
|
|
|
|
|
if ($sessionId) { |
|
|
|
|
$titleSession = Display::return_icon( |
|
|
|
|
'session.png', |
|
|
|
|
get_lang('Session'), |
|
|
|
|
[], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
).' '.api_get_session_name($sessionId); |
|
|
|
|
'session.png', |
|
|
|
|
get_lang('Session'), |
|
|
|
|
[], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
).' '.api_get_session_name($sessionId); |
|
|
|
|
$titleCourse = Display::return_icon( |
|
|
|
|
'course.png', |
|
|
|
|
get_lang('Course'), |
|
|
|
|
[], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
).' '.$course_name; |
|
|
|
|
'course.png', |
|
|
|
|
get_lang('Course'), |
|
|
|
|
[], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
).' '.$course_name; |
|
|
|
|
} else { |
|
|
|
|
$titleSession = Display::return_icon( |
|
|
|
|
'course.png', |
|
|
|
|
get_lang('Course'), |
|
|
|
|
[], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
).' '.$courseInfo['name']; |
|
|
|
|
'course.png', |
|
|
|
|
get_lang('Course'), |
|
|
|
|
[], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
).' '.$courseInfo['name']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$teacherList = CourseManager::getTeacherListFromCourseCodeToString( |
|
|
|
@ -322,11 +325,69 @@ if ($showReporting) { |
|
|
|
|
|
|
|
|
|
$trackingColumn = isset($_GET['users_tracking_column']) ? $_GET['users_tracking_column'] : null; |
|
|
|
|
$trackingDirection = isset($_GET['users_tracking_direction']) ? $_GET['users_tracking_direction'] : null; |
|
|
|
|
|
|
|
|
|
$hideReports = api_get_configuration_value('hide_course_report_graph'); |
|
|
|
|
$conditions = []; |
|
|
|
|
|
|
|
|
|
$groupList = GroupManager::get_group_list(null, $courseInfo, 1); |
|
|
|
|
|
|
|
|
|
$class = new UserGroup(); |
|
|
|
|
|
|
|
|
|
$options['where'] = [' usergroup.course_id = ? ' => $courseId]; |
|
|
|
|
$classes = $class->getUserGroupInCourse($options); |
|
|
|
|
|
|
|
|
|
// Show the charts part only if there are students subscribed to this course/session |
|
|
|
|
if ($nbStudents > 0) { |
|
|
|
|
// Classes |
|
|
|
|
$formClass = new FormValidator( |
|
|
|
|
'classes', |
|
|
|
|
'get', |
|
|
|
|
api_get_self().'?'.api_get_cidreq().'&'.$additionalParams.$users_tracking_per_page |
|
|
|
|
); |
|
|
|
|
$formClass->addHidden('cidReq', $courseCode); |
|
|
|
|
$formClass->addHidden('id_session', $sessionId); |
|
|
|
|
$groupIdList = ['--']; |
|
|
|
|
foreach ($classes as $class) { |
|
|
|
|
$groupIdList[$class['id']] = $class['name']; |
|
|
|
|
} |
|
|
|
|
$formClass->addSelect('class_id', get_lang('Class'), $groupIdList); |
|
|
|
|
$formClass->addButtonSearch(get_lang('Search')); |
|
|
|
|
|
|
|
|
|
// Groups |
|
|
|
|
$formGroup = new FormValidator( |
|
|
|
|
'groups', |
|
|
|
|
'get', |
|
|
|
|
api_get_self().'?'.api_get_cidreq().'&'.$additionalParams.$users_tracking_per_page |
|
|
|
|
); |
|
|
|
|
$formGroup->addHidden('cidReq', $courseCode); |
|
|
|
|
$formGroup->addHidden('id_session', $sessionId); |
|
|
|
|
$groupIdList = ['--']; |
|
|
|
|
foreach ($groupList as $group) { |
|
|
|
|
$groupIdList[$group['id']] = $group['name']; |
|
|
|
|
} |
|
|
|
|
$formGroup->addSelect('group_id', get_lang('Group'), $groupIdList); |
|
|
|
|
$formGroup->addButtonSearch(get_lang('Search')); |
|
|
|
|
|
|
|
|
|
// Extra fields |
|
|
|
|
$formExtraField = new FormValidator( |
|
|
|
|
'extra_fields', |
|
|
|
|
'get', |
|
|
|
|
api_get_self().'?'.api_get_cidreq().'&'.$additionalParams.$users_tracking_per_page |
|
|
|
|
); |
|
|
|
|
$formExtraField->addHidden('cidReq', $courseCode); |
|
|
|
|
$formExtraField->addHidden('id_session', $sessionId); |
|
|
|
|
if (isset($_GET['additional_profile_field'])) { |
|
|
|
|
foreach ($_GET['additional_profile_field'] as $fieldId) { |
|
|
|
|
$fieldId = Security::remove_XSS($fieldId); |
|
|
|
|
$formExtraField->addHidden('additional_profile_field[]', $fieldId); |
|
|
|
|
$formGroup->addHidden('additional_profile_field[]', $fieldId); |
|
|
|
|
$formClass->addHidden('additional_profile_field[]', $fieldId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$extraField = new ExtraField('user'); |
|
|
|
|
$extraField->addElements($formExtraField); |
|
|
|
|
$formExtraField->addButtonSearch(get_lang('Search')); |
|
|
|
|
|
|
|
|
|
$numberStudentsCompletedLP = 0; |
|
|
|
|
$averageStudentsTestScore = 0; |
|
|
|
|
$scoresDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
|
|
|
@ -337,19 +398,51 @@ if ($nbStudents > 0) { |
|
|
|
|
$category = Category::load( |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$course_code, |
|
|
|
|
$courseCode, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$conditions = []; |
|
|
|
|
$fields = []; |
|
|
|
|
|
|
|
|
|
if ($formClass->validate()) { |
|
|
|
|
$classId = (int) $formClass->getSubmitValue('class_id'); |
|
|
|
|
if (!empty($classId)) { |
|
|
|
|
$whereCondition = " AND gu.usergroup_id = $classId "; |
|
|
|
|
$tableGroup = Database::get_main_table(TABLE_USERGROUP_REL_USER); |
|
|
|
|
$joins = " INNER JOIN $tableGroup gu ON (user.id = gu.user_id) "; |
|
|
|
|
$conditions = ['where' => $whereCondition, 'inject_joins' => $joins]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($formGroup->validate()) { |
|
|
|
|
$groupId = (int) $formGroup->getSubmitValue('group_id'); |
|
|
|
|
if (!empty($groupId)) { |
|
|
|
|
$whereCondition = " AND gu.group_id = $groupId "; |
|
|
|
|
$tableGroup = Database::get_course_table(TABLE_GROUP_USER); |
|
|
|
|
$joins = " INNER JOIN $tableGroup gu ON (user.id = gu.user_id) "; |
|
|
|
|
$conditions = ['where' => $whereCondition, 'inject_joins' => $joins]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($formExtraField->validate()) { |
|
|
|
|
$extraResult = $extraField->processExtraFieldSearch($_REQUEST, $formExtraField, 'user'); |
|
|
|
|
if (!empty($extraResult)) { |
|
|
|
|
$conditions = $extraResult['condition']; |
|
|
|
|
$fields = $extraResult['fields']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($hideReports === false) { |
|
|
|
|
$conditions['include_invited_users'] = false; |
|
|
|
|
$usersTracking = TrackingCourseLog::get_user_data( |
|
|
|
|
null, |
|
|
|
|
$nbStudents, |
|
|
|
|
$trackingColumn, |
|
|
|
|
$trackingDirection, |
|
|
|
|
false |
|
|
|
|
$conditions |
|
|
|
|
); |
|
|
|
|
foreach ($usersTracking as $userTracking) { |
|
|
|
|
$userInfo = api_get_user_info_from_username($userTracking[3]); |
|
|
|
@ -397,7 +490,6 @@ if ($nbStudents > 0) { |
|
|
|
|
$averageStudentsTestScore = round($averageStudentsTestScore / $nbStudents); |
|
|
|
|
|
|
|
|
|
$colors = ChamiloApi::getColorPalette(true, true, 10); |
|
|
|
|
|
|
|
|
|
$tpl->assign('chart_colors', json_encode($colors)); |
|
|
|
|
$tpl->assign('certificate_count', $certificateCount); |
|
|
|
|
$tpl->assign('score_distribution', json_encode($scoresDistribution)); |
|
|
|
@ -414,6 +506,10 @@ if ($nbStudents > 0) { |
|
|
|
|
$html .= Display::page_subheader2(get_lang('StudentList')); |
|
|
|
|
|
|
|
|
|
if ($nbStudents > 0) { |
|
|
|
|
$html .= $formClass->returnForm(); |
|
|
|
|
$html .= $formGroup->returnForm(); |
|
|
|
|
$html .= $formExtraField->returnForm(); |
|
|
|
|
|
|
|
|
|
$getLangXDays = get_lang('XDays'); |
|
|
|
|
$form = new FormValidator( |
|
|
|
|
'reminder_form', |
|
|
|
@ -441,17 +537,15 @@ if ($nbStudents > 0) { |
|
|
|
|
['disable_js' => true, 'class' => 'col-sm-3'] |
|
|
|
|
); |
|
|
|
|
$el->setSelected(7); |
|
|
|
|
|
|
|
|
|
$form->addElement('hidden', 'action', 'add'); |
|
|
|
|
$form->addElement('hidden', 'remindallinactives', 'true'); |
|
|
|
|
$form->addElement('hidden', 'cidReq', $courseInfo['code']); |
|
|
|
|
$form->addElement('hidden', 'id_session', api_get_session_id()); |
|
|
|
|
$form->addButtonSend(get_lang('SendNotification')); |
|
|
|
|
|
|
|
|
|
$extra_field_select = TrackingCourseLog::display_additional_profile_fields(); |
|
|
|
|
|
|
|
|
|
if (!empty($extra_field_select)) { |
|
|
|
|
$html .= $extra_field_select; |
|
|
|
|
$extraFieldSelect = TrackingCourseLog::display_additional_profile_fields(); |
|
|
|
|
if (!empty($extraFieldSelect)) { |
|
|
|
|
$html .= $extraFieldSelect; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$html .= $form->returnForm(); |
|
|
|
@ -470,22 +564,22 @@ if ($nbStudents > 0) { |
|
|
|
|
'users_tracking' |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$conditions['include_invited_users'] = true; |
|
|
|
|
$table = new SortableTable( |
|
|
|
|
'users_tracking', |
|
|
|
|
['TrackingCourseLog', 'get_number_of_users'], |
|
|
|
|
['TrackingCourseLog', 'get_user_data'], |
|
|
|
|
1 |
|
|
|
|
1, |
|
|
|
|
20 |
|
|
|
|
); |
|
|
|
|
$table->setDataFunctionParams($conditions); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table->total_number_of_items = $nbStudents; |
|
|
|
|
|
|
|
|
|
$parameters['cidReq'] = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : ''; |
|
|
|
|
$parameters['id_session'] = $sessionId; |
|
|
|
|
$parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null; |
|
|
|
|
|
|
|
|
|
$table->set_additional_parameters($parameters); |
|
|
|
|
|
|
|
|
|
$headers = []; |
|
|
|
|
// tab of header texts |
|
|
|
|
$table->set_header(0, get_lang('OfficialCode'), true); |
|
|
|
@ -512,7 +606,9 @@ if ($nbStudents > 0) { |
|
|
|
|
['style' => 'width:110px;'] |
|
|
|
|
); |
|
|
|
|
$headers['training_time'] = get_lang('TrainingTime'); |
|
|
|
|
$table->set_header(5, get_lang('CourseProgress').' '. |
|
|
|
|
$table->set_header( |
|
|
|
|
5, |
|
|
|
|
get_lang('CourseProgress').' '. |
|
|
|
|
Display::return_icon( |
|
|
|
|
'info3.gif', |
|
|
|
|
get_lang('ScormAndLPProgressTotalAverage'), |
|
|
|
@ -523,7 +619,9 @@ if ($nbStudents > 0) { |
|
|
|
|
); |
|
|
|
|
$headers['course_progress'] = get_lang('CourseProgress'); |
|
|
|
|
|
|
|
|
|
$table->set_header(6, get_lang('ExerciseProgress').' '. |
|
|
|
|
$table->set_header( |
|
|
|
|
6, |
|
|
|
|
get_lang('ExerciseProgress').' '. |
|
|
|
|
Display::return_icon( |
|
|
|
|
'info3.gif', |
|
|
|
|
get_lang('ExerciseProgressInfo'), |
|
|
|
@ -533,13 +631,17 @@ if ($nbStudents > 0) { |
|
|
|
|
['style' => 'width:110px;'] |
|
|
|
|
); |
|
|
|
|
$headers['exercise_progress'] = get_lang('ExerciseProgress'); |
|
|
|
|
$table->set_header(7, get_lang('ExerciseAverage').' '. |
|
|
|
|
$table->set_header( |
|
|
|
|
7, |
|
|
|
|
get_lang('ExerciseAverage').' '. |
|
|
|
|
Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), |
|
|
|
|
false, |
|
|
|
|
['style' => 'width:110px;'] |
|
|
|
|
); |
|
|
|
|
$headers['exercise_average'] = get_lang('ExerciseAverage'); |
|
|
|
|
$table->set_header(8, get_lang('Score').' '. |
|
|
|
|
$table->set_header( |
|
|
|
|
8, |
|
|
|
|
get_lang('Score').' '. |
|
|
|
|
Display::return_icon( |
|
|
|
|
'info3.gif', |
|
|
|
|
get_lang('ScormAndLPTestTotalAverage'), |
|
|
|
@ -573,6 +675,7 @@ if ($nbStudents > 0) { |
|
|
|
|
$table->set_header($counter, $extra_info[$fieldId]['display_text'], false); |
|
|
|
|
$headers[$extra_info[$fieldId]['variable']] = $extra_info[$fieldId]['display_text']; |
|
|
|
|
$counter++; |
|
|
|
|
$parameters['additional_profile_field'] = $fieldId; |
|
|
|
|
} |
|
|
|
|
$table->set_header($counter, get_lang('Details'), false); |
|
|
|
|
$headers['details'] = get_lang('Details'); |
|
|
|
@ -580,6 +683,17 @@ if ($nbStudents > 0) { |
|
|
|
|
$table->set_header(15, get_lang('Details'), false); |
|
|
|
|
$headers['Details'] = get_lang('Details'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($fields)) { |
|
|
|
|
foreach ($fields as $key => $value) { |
|
|
|
|
$key = Security::remove_XSS($key); |
|
|
|
|
$value = Security::remove_XSS($value); |
|
|
|
|
$parameters[$key] = $value; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$parameters['cidReq'] = $courseCode; |
|
|
|
|
$parameters['id_session'] = $sessionId; |
|
|
|
|
$table->set_additional_parameters($parameters); |
|
|
|
|
// display buttons to un hide hidden columns |
|
|
|
|
$html .= '<div id="unhideButtons" class="btn-toolbar">'; |
|
|
|
|
$index = 0; |
|
|
|
@ -607,8 +721,136 @@ if ($nbStudents > 0) { |
|
|
|
|
$html .= Display::return_message(get_lang('NoUsersInCourse'), 'warning', true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$groupContent = ''; |
|
|
|
|
echo Display::panel($html, $titleSession); |
|
|
|
|
|
|
|
|
|
if (!empty($groupList)) { |
|
|
|
|
$groupTable = new HTML_Table(['class' => 'table data_table']); |
|
|
|
|
$column = 0; |
|
|
|
|
$groupTable->setHeaderContents(0, $column++, get_lang('Name')); |
|
|
|
|
$groupTable->setHeaderContents(0, $column++, get_lang('TrainingTime')); |
|
|
|
|
$groupTable->setHeaderContents(0, $column++, get_lang('AverageTrainingTime')); |
|
|
|
|
$groupTable->setHeaderContents(0, $column++, get_lang('CourseProgress')); |
|
|
|
|
$groupTable->setHeaderContents(0, $column++, get_lang('ExerciseAverage')); |
|
|
|
|
|
|
|
|
|
$row = 1; |
|
|
|
|
$exerciseList = ExerciseLib::get_all_exercises( |
|
|
|
|
$courseInfo, |
|
|
|
|
$sessionId, |
|
|
|
|
false, |
|
|
|
|
null, |
|
|
|
|
false, |
|
|
|
|
3 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$totalTime = null; |
|
|
|
|
$totalLpProgress = null; |
|
|
|
|
$totalScore = null; |
|
|
|
|
$totalAverageTime = null; |
|
|
|
|
$totalBestScoreAverageNotInLP = null; |
|
|
|
|
|
|
|
|
|
foreach ($groupList as $groupInfo) { |
|
|
|
|
$column = 0; |
|
|
|
|
$groupTable->setCellContents($row, $column++, $groupInfo['name']); |
|
|
|
|
$usersInGroup = GroupManager::getStudents($groupInfo['iid']); |
|
|
|
|
|
|
|
|
|
$time = null; |
|
|
|
|
$lpProgress = null; |
|
|
|
|
$score = null; |
|
|
|
|
$averageTime = null; |
|
|
|
|
$bestScoreAverageNotInLP = null; |
|
|
|
|
if (!empty($usersInGroup)) { |
|
|
|
|
$usersInGroup = array_column($usersInGroup, 'user_id'); |
|
|
|
|
$userInGroupCount = count($usersInGroup); |
|
|
|
|
$timeInSeconds = Tracking::get_time_spent_on_the_course( |
|
|
|
|
$usersInGroup, |
|
|
|
|
$courseId, |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
$totalTime += $timeInSeconds; |
|
|
|
|
if (!empty($timeInSeconds)) { |
|
|
|
|
$time = api_time_to_hms($timeInSeconds); |
|
|
|
|
$averageTime = $timeInSeconds / $userInGroupCount; |
|
|
|
|
$totalAverageTime += $averageTime; |
|
|
|
|
$averageTime = api_time_to_hms($averageTime); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lpProgress = Tracking::get_avg_student_progress( |
|
|
|
|
$usersInGroup, |
|
|
|
|
$courseCode, |
|
|
|
|
[], |
|
|
|
|
$sessionId, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($lpProgress)) { |
|
|
|
|
$lpProgress = ''; |
|
|
|
|
} else { |
|
|
|
|
$lpProgress = $lpProgress[0] / $userInGroupCount; |
|
|
|
|
$totalLpProgress += $lpProgress; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($exerciseList)) { |
|
|
|
|
foreach ($exerciseList as $exerciseData) { |
|
|
|
|
foreach ($usersInGroup as $userId) { |
|
|
|
|
$results = Event::get_best_exercise_results_by_user( |
|
|
|
|
$exerciseData['id'], |
|
|
|
|
$courseInfo['real_id'], |
|
|
|
|
0, |
|
|
|
|
$userId |
|
|
|
|
); |
|
|
|
|
$best = 0; |
|
|
|
|
if (!empty($results)) { |
|
|
|
|
foreach ($results as $result) { |
|
|
|
|
if (!empty($result['exe_weighting'])) { |
|
|
|
|
$score = $result['exe_result'] / $result['exe_weighting']; |
|
|
|
|
if ($score > $best) { |
|
|
|
|
$best = $score; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$bestScoreAverageNotInLP += $best; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$bestScoreAverageNotInLP = round( |
|
|
|
|
$bestScoreAverageNotInLP / count($exerciseList) * 100 / $userInGroupCount, |
|
|
|
|
2 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$totalBestScoreAverageNotInLP += $bestScoreAverageNotInLP; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($score)) { |
|
|
|
|
$score = ''; |
|
|
|
|
} |
|
|
|
|
if (empty($lpProgress)) { |
|
|
|
|
$lpProgress = ''; |
|
|
|
|
} |
|
|
|
|
if (empty($bestScoreAverageNotInLP)) { |
|
|
|
|
$bestScoreAverageNotInLP = ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$groupTable->setCellContents($row, $column++, $time); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $averageTime); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $lpProgress); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $bestScoreAverageNotInLP); |
|
|
|
|
$row++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$column = 0; |
|
|
|
|
$totalTime = api_time_to_hms($totalTime); |
|
|
|
|
$totalAverageTime = api_time_to_hms($totalAverageTime); |
|
|
|
|
$groupTable->setCellContents($row, $column++, get_lang('Total')); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $totalTime); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $totalAverageTime); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $totalLpProgress); |
|
|
|
|
$groupTable->setCellContents($row, $column++, $totalBestScoreAverageNotInLP); |
|
|
|
|
|
|
|
|
|
echo Display::panel($groupTable->toHtml(), ''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Send the csv file if asked. |
|
|
|
|
if ($export_csv) { |
|
|
|
|
$csv_headers = []; |
|
|
|
|