upgrade
This commit is contained in:
183
main/mySpace/access_details.php
Normal file
183
main/mySpace/access_details.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This is the tracking library for Chamilo.
|
||||
*
|
||||
* @param int $user_id the user id
|
||||
* @param string $course_code the course code
|
||||
*
|
||||
* @author Julio Montoya <gugli100@gmail.com>
|
||||
* @author Jorge Frisancho Jibaja - select between dates
|
||||
*/
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) ||
|
||||
api_is_teacher() || api_is_course_tutor();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
exit;
|
||||
}
|
||||
|
||||
// the section (for the tabs)
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$user_id = isset($_REQUEST['student']) ? (int) $_REQUEST['student'] : 0;
|
||||
$session_id = isset($_REQUEST['id_session']) ? (int) $_REQUEST['id_session'] : 0;
|
||||
$type = isset($_REQUEST['type']) ? Security::remove_XSS($_REQUEST['type']) : '';
|
||||
$course_code = isset($_REQUEST['course']) ? Security::remove_XSS($_REQUEST['course']) : '';
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
if (empty($courseInfo)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$courseId = (!empty($courseInfo['real_id']) ? $courseInfo['real_id'] : null);
|
||||
$quote_simple = "'";
|
||||
|
||||
$form = new FormValidator(
|
||||
'myform',
|
||||
'get',
|
||||
api_get_self(),
|
||||
null,
|
||||
['id' => 'myform']
|
||||
);
|
||||
$form->addElement('text', 'from', get_lang('From'), ['id' => 'date_from']);
|
||||
$form->addElement('text', 'to', get_lang('Until'), ['id' => 'date_to']);
|
||||
$form->addElement(
|
||||
'select',
|
||||
'type',
|
||||
get_lang('Type'),
|
||||
['day' => get_lang('Day'), 'month' => get_lang('Month')],
|
||||
['id' => 'type']
|
||||
);
|
||||
$form->addElement('hidden', 'student', $user_id);
|
||||
$form->applyFilter('student', 'html_filter');
|
||||
$form->addElement('hidden', 'course', $course_code);
|
||||
$form->applyFilter('course', 'html_filter');
|
||||
$form->addRule('from', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$form->addRule('to', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$group = [
|
||||
$form->createElement(
|
||||
'label',
|
||||
null,
|
||||
Display::url(
|
||||
get_lang('Search'),
|
||||
'javascript://',
|
||||
['onclick' => 'loadGraph();', 'class' => 'btn btn-default']
|
||||
)
|
||||
),
|
||||
];
|
||||
$form->addGroup($group);
|
||||
$from = null;
|
||||
$to = null;
|
||||
$course = $course_code;
|
||||
if ($form->validate()) {
|
||||
$values = $form->exportValues();
|
||||
$from = $values['from'];
|
||||
$to = $values['to'];
|
||||
$type = $values['type'];
|
||||
$course = $values['course'];
|
||||
}
|
||||
|
||||
$url = api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail_by_date&course='.$course.'&student='.$user_id.'&session_id='.$session_id;
|
||||
|
||||
$htmlHeadXtra[] = '<script src="slider.js" type="text/javascript"></script>';
|
||||
$htmlHeadXtra[] = '<link rel="stylesheet" href="slider.css" />';
|
||||
$htmlHeadXtra[] = "<script>
|
||||
function loadGraph() {
|
||||
var startDate = $('#date_from').val();
|
||||
var endDate = $('#date_to').val();
|
||||
var type = $('#type option:selected').val();
|
||||
var url = '".$url."&startDate='+startDate+'&endDate='+endDate+'&type='+type;
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(db) {
|
||||
if (!db.is_empty) {
|
||||
// Display confirmation message to the user
|
||||
$('#messages').html(db.result).stop().css('opacity', 1).fadeIn(30);
|
||||
|
||||
var exportLink = $('<a></a>').
|
||||
attr(\"href\", url+'&export=excel')
|
||||
.attr('class', 'btn btn-default')
|
||||
.attr('target', '_blank')
|
||||
.html('".addslashes(get_lang('ExportAsXLS'))."');
|
||||
|
||||
$('#messages').append(exportLink);
|
||||
|
||||
$('#cev_cont_stats').html(db.stats);
|
||||
$('#graph').html(db.graph_result);
|
||||
} else {
|
||||
$('#messages').text('".get_lang('NoDataAvailable')."');
|
||||
$('#messages').addClass('warning-message');
|
||||
$('#cev_cont_stats').html('');
|
||||
$('#graph').empty();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
var dates = $('#date_from, #date_to').datepicker({
|
||||
dateFormat: ".$quote_simple."yy-mm-dd".$quote_simple.",
|
||||
changeMonth: true,
|
||||
changeYear: true
|
||||
});
|
||||
|
||||
$(\"#cev_button\").hide();
|
||||
});
|
||||
|
||||
</script>";
|
||||
|
||||
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AccessDetails')];
|
||||
|
||||
Display::display_header('');
|
||||
$userInfo = api_get_user_info($user_id);
|
||||
|
||||
echo Display::page_header(get_lang('DetailsStudentInCourse'));
|
||||
echo Display::page_subheader(
|
||||
get_lang('User').': '.$userInfo['complete_name'].' - '.
|
||||
get_lang('Course').': '.$courseInfo['title'].' ('.$course_code.')'
|
||||
);
|
||||
|
||||
$form->setDefaults(['from' => $from, 'to' => $to]);
|
||||
$form->display();
|
||||
?>
|
||||
<br />
|
||||
<br />
|
||||
<div class="text-center" id="graph"></div>
|
||||
<br />
|
||||
<br />
|
||||
<div class="row">
|
||||
<div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6">
|
||||
<div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
||||
<?php echo get_lang('Statistics'); ?>
|
||||
</div><br />
|
||||
<div id="cev_cont_stats">
|
||||
<?php
|
||||
$data = MySpace::getStats($user_id, $courseInfo, $session_id);
|
||||
if (!empty($data)) {
|
||||
$stats = '<strong>'.get_lang('Total').': </strong>'.$data['total'].'<br />';
|
||||
$stats .= '<strong>'.get_lang('Average').': </strong>'.$data['avg'].'<br />';
|
||||
$stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$data['times'].'<br />';
|
||||
echo $stats;
|
||||
} else {
|
||||
echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<br />
|
||||
</div>
|
||||
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6 col-md-6">
|
||||
<div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
||||
<?php echo get_lang('Details'); ?>
|
||||
</div><br />
|
||||
<div id="messages"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
Display::display_footer();
|
||||
601
main/mySpace/access_details_session.php
Normal file
601
main/mySpace/access_details_session.php
Normal file
@@ -0,0 +1,601 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$is_allowedToTrack = api_is_platform_admin(true, true) ||
|
||||
api_is_teacher() || api_is_course_tutor() || api_is_student_boss();
|
||||
|
||||
if (!$is_allowedToTrack) {
|
||||
api_not_allowed(true);
|
||||
exit;
|
||||
}
|
||||
|
||||
// the section (for the tabs)
|
||||
$this_section = SECTION_TRACKING;
|
||||
$quote_simple = "'";
|
||||
|
||||
$userId = isset($_REQUEST['user_id']) ? (int) $_REQUEST['user_id'] : 0;
|
||||
$userInfo = api_get_user_info($userId);
|
||||
if (empty($userInfo)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dateTime
|
||||
* @param bool $showTime
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function customDate($dateTime, $showTime = false)
|
||||
{
|
||||
$format = 'd/m/Y';
|
||||
if ($showTime) {
|
||||
$format = 'd/m/Y H:i:s';
|
||||
}
|
||||
$dateTime = api_get_local_time(
|
||||
$dateTime,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
$format
|
||||
);
|
||||
|
||||
return $dateTime;
|
||||
}
|
||||
|
||||
$sessions = SessionManager::getSessionsFollowedByUser(
|
||||
$userId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'ORDER BY s.access_end_date'
|
||||
);
|
||||
|
||||
$startDate = '';
|
||||
$endDate = '';
|
||||
if (!empty($sessions)) {
|
||||
foreach ($sessions as $session) {
|
||||
$startDate = customDate($session['access_start_date']);
|
||||
$endDate = customDate($session['access_end_date']);
|
||||
}
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'myform',
|
||||
'get',
|
||||
api_get_self().'?user_id='.$userId,
|
||||
null,
|
||||
['id' => 'myform']
|
||||
);
|
||||
$form->addElement('text', 'from', get_lang('From'), ['placeholder' => get_lang('DateFormatddmmyyyy')]);
|
||||
$form->addElement('text', 'to', get_lang('Until'), ['placeholder' => get_lang('DateFormatddmmyyyy')]);
|
||||
$form->addHidden('user_id', $userId);
|
||||
$form->addRule('from', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$form->addRule('from', get_lang('ThisFieldIsRequired').' dd/mm/yyyy', 'callback', 'validateDate');
|
||||
$form->addRule('to', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$form->addRule('to', get_lang('ThisFieldIsRequired').' dd/mm/yyyy', 'callback', 'validateDate');
|
||||
$form->addButtonSearch(get_lang('GenerateReport'));
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function validateDate($value)
|
||||
{
|
||||
$value = DateTime::createFromFormat('d/m/Y', $value);
|
||||
|
||||
if ($value === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getReport($userId, $from, $to, $addTime = false)
|
||||
{
|
||||
$sessionCategories = UserManager::get_sessions_by_category($userId, false, true, true);
|
||||
$report = [];
|
||||
$minLogin = 0;
|
||||
$maxLogin = 0;
|
||||
$totalDuration = 0;
|
||||
|
||||
foreach ($sessionCategories as $category) {
|
||||
foreach ($category['sessions'] as $session) {
|
||||
$sessionId = $session['session_id'];
|
||||
$courseList = $session['courses'];
|
||||
foreach ($courseList as $course) {
|
||||
$courseInfo = api_get_course_info_by_id($course['real_id']);
|
||||
$result = MySpace::get_connections_to_course_by_date(
|
||||
$userId,
|
||||
$courseInfo,
|
||||
$sessionId,
|
||||
$from,
|
||||
$to
|
||||
);
|
||||
|
||||
$partialMinLogin = 0;
|
||||
$partialMaxLogin = 0;
|
||||
$partialDuration = 0;
|
||||
|
||||
foreach ($result as $item) {
|
||||
$record = [
|
||||
customDate($item['login'], true),
|
||||
customDate($item['logout'], true),
|
||||
api_format_time($item['duration'], 'lang'),
|
||||
];
|
||||
|
||||
$totalDuration += $item['duration'];
|
||||
|
||||
if (empty($minLogin)) {
|
||||
$minLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if ($minLogin > api_strtotime($item['login'], 'UTC')) {
|
||||
$minLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if (api_strtotime($item['logout']) > $maxLogin) {
|
||||
$maxLogin = api_strtotime($item['logout'], 'UTC');
|
||||
}
|
||||
|
||||
// Partials
|
||||
$partialDuration += $item['duration'];
|
||||
if (empty($partialMinLogin)) {
|
||||
$partialMinLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if ($partialMinLogin > api_strtotime($item['login'], 'UTC')) {
|
||||
$partialMinLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if (api_strtotime($item['logout'], 'UTC') > $partialMaxLogin) {
|
||||
$partialMaxLogin = api_strtotime($item['logout'], 'UTC');
|
||||
}
|
||||
|
||||
$report[$sessionId]['courses'][$course['real_id']][] = $record;
|
||||
$report[$sessionId]['name'][$course['real_id']] = $courseInfo['title'].' ('.$session['session_name'].')';
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
$record = [
|
||||
customDate($partialMinLogin, true),
|
||||
customDate($partialMaxLogin, true),
|
||||
api_format_time($partialDuration, 'lang'),
|
||||
];
|
||||
$report[$sessionId]['courses'][$course['real_id']][] = $record;
|
||||
$report[$sessionId]['name'][$course['real_id']] = $courseInfo['title'].' ('.$session['session_name'].')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$courses = CourseManager::returnCourses($userId);
|
||||
$courses = array_merge($courses['in_category'], $courses['not_category']);
|
||||
|
||||
if ($addTime) {
|
||||
$fromFirst = api_get_local_time($from.' 00:00:00');
|
||||
$toEnd = api_get_local_time($from.' 23:59:59');
|
||||
|
||||
$from = api_get_utc_datetime($fromFirst);
|
||||
$to = api_get_utc_datetime($toEnd);
|
||||
}
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$result = MySpace::get_connections_to_course_by_date(
|
||||
$userId,
|
||||
$course,
|
||||
0,
|
||||
$from,
|
||||
$to
|
||||
);
|
||||
$partialMinLogin = 0;
|
||||
$partialMaxLogin = 0;
|
||||
$partialDuration = 0;
|
||||
|
||||
foreach ($result as $item) {
|
||||
$record = [
|
||||
customDate($item['login'], true),
|
||||
customDate($item['logout'], true),
|
||||
api_format_time($item['duration'], 'lang'),
|
||||
];
|
||||
$report[0]['courses'][$course['course_id']][] = $record;
|
||||
$report[0]['name'][$course['course_id']] = $course['title'];
|
||||
|
||||
$totalDuration += $item['duration'];
|
||||
|
||||
if (empty($minLogin)) {
|
||||
$minLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if ($minLogin > api_strtotime($item['login'], 'UTC')) {
|
||||
$minLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if (api_strtotime($item['logout'], 'UTC') > $maxLogin) {
|
||||
$maxLogin = api_strtotime($item['logout'], 'UTC');
|
||||
}
|
||||
|
||||
// Partials
|
||||
$partialDuration += $item['duration'];
|
||||
if (empty($partialMinLogin)) {
|
||||
$partialMinLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if ($partialMinLogin > api_strtotime($item['login'], 'UTC')) {
|
||||
$partialMinLogin = api_strtotime($item['login'], 'UTC');
|
||||
}
|
||||
if (api_strtotime($item['logout'], 'UTC') > $partialMaxLogin) {
|
||||
$partialMaxLogin = api_strtotime($item['logout'], 'UTC');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
$record = [
|
||||
customDate($partialMinLogin, true),
|
||||
customDate($partialMaxLogin, true),
|
||||
api_format_time($partialDuration, 'lang'),
|
||||
];
|
||||
|
||||
$report[0]['courses'][$course['course_id']][] = $record;
|
||||
$report[0]['name'][$course['course_id']] = $course['title'];
|
||||
}
|
||||
}
|
||||
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$headers = [
|
||||
get_lang('MinStartDate'),
|
||||
get_lang('MaxEndDate'),
|
||||
get_lang('TotalDuration'),
|
||||
];
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$row++;
|
||||
$column = 0;
|
||||
$table->setCellContents($row, $column++, customDate($minLogin));
|
||||
$table->setCellContents($row, $column++, customDate($maxLogin));
|
||||
$table->setRowAttributes($row, ['style' => 'font-weight:bold']);
|
||||
$table->setCellContents($row, $column++, api_format_time($totalDuration, 'lang'));
|
||||
|
||||
$first = $table->toHtml();
|
||||
|
||||
$courseSessionTable = '';
|
||||
$courseSessionTableData = [];
|
||||
$iconCourse = Display::return_icon('course.png', null, [], ICON_SIZE_SMALL);
|
||||
foreach ($report as $sessionId => $data) {
|
||||
foreach ($data['courses'] as $courseId => $courseData) {
|
||||
if (empty($courseData)) {
|
||||
continue;
|
||||
}
|
||||
$courseSessionTable .= '<div class="data-title">'.Display::page_subheader3(
|
||||
$iconCourse.$data['name'][$courseId]
|
||||
).'</div>';
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$headers = [
|
||||
get_lang('StartDate'),
|
||||
get_lang('EndDate'),
|
||||
get_lang('Duration'),
|
||||
];
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$row++;
|
||||
$countData = count($courseData);
|
||||
foreach ($courseData as $record) {
|
||||
$column = 0;
|
||||
foreach ($record as $item) {
|
||||
$table->setCellContents($row, $column++, $item);
|
||||
if ($row == $countData) {
|
||||
$courseSessionTableData[$data['name'][$courseId]] = $item;
|
||||
$table->setRowAttributes($row, ['style' => 'font-weight:bold']);
|
||||
}
|
||||
}
|
||||
$row++;
|
||||
}
|
||||
$courseSessionTable .= $table->toHtml();
|
||||
}
|
||||
}
|
||||
$totalCourseSessionTable = '';
|
||||
if ($courseSessionTableData) {
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$headers = [
|
||||
get_lang('Course'),
|
||||
get_lang('TotalDuration'),
|
||||
];
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$row++;
|
||||
foreach ($courseSessionTableData as $name => $duration) {
|
||||
$column = 0;
|
||||
$table->setCellContents($row, $column++, $name);
|
||||
$table->setCellContents($row, $column++, $duration);
|
||||
$row++;
|
||||
}
|
||||
$totalCourseSessionTable = $table->toHtml();
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$result['first'] = $first;
|
||||
$result['second'] = $courseSessionTable;
|
||||
$result['third'] = $totalCourseSessionTable;
|
||||
$result['total'] = $totalDuration;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
$from = $values['from'];
|
||||
$to = $values['to'];
|
||||
|
||||
$from = DateTime::createFromFormat('d/m/Y', $from);
|
||||
$to = DateTime::createFromFormat('d/m/Y', $to);
|
||||
|
||||
$from = api_get_utc_datetime($from->format('Y-m-d'));
|
||||
$to = api_get_utc_datetime($to->format('Y-m-d'));
|
||||
$title = Display::page_subheader3(sprintf(get_lang('ExtractionFromX'), api_get_local_time()));
|
||||
$result = getReport($userId, $from, $to);
|
||||
|
||||
$first = $result['first'];
|
||||
$courseSessionTable = $result['second'];
|
||||
$totalCourseSessionTable = $result['third'];
|
||||
|
||||
$tpl = new Template('', false, false, false, true, false, false);
|
||||
$tpl->assign('title', get_lang('RealisationCertificate'));
|
||||
$tpl->assign('student', $userInfo['complete_name']);
|
||||
$tpl->assign('table_progress', $title.$first.$totalCourseSessionTable.'<pagebreak>'.$courseSessionTable);
|
||||
|
||||
$content = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl'));
|
||||
|
||||
$params = [
|
||||
'pdf_title' => get_lang('Resume'),
|
||||
'course_info' => '',
|
||||
'pdf_date' => '',
|
||||
'student_info' => $userInfo,
|
||||
'show_grade_generated_date' => true,
|
||||
'show_real_course_teachers' => false,
|
||||
'show_teacher_as_myself' => false,
|
||||
'orientation' => 'P',
|
||||
];
|
||||
|
||||
$pdfName = api_strtoupper($userInfo['lastname'].'_'.$userInfo['firstname']).'_'.api_get_local_time();
|
||||
@$pdf = new PDF('A4', $params['orientation'], $params);
|
||||
@$pdf->setBackground($tpl->theme);
|
||||
@$pdf->content_to_pdf(
|
||||
$content,
|
||||
'',
|
||||
$pdfName,
|
||||
null,
|
||||
'D',
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AccessDetails')];
|
||||
$userInfo = api_get_user_info($userId);
|
||||
|
||||
$form->setDefaults(['from' => $startDate, 'to' => $endDate]);
|
||||
|
||||
$formByDay = new FormValidator(
|
||||
'by_day',
|
||||
'get',
|
||||
api_get_self().'?user_id='.$userId,
|
||||
null,
|
||||
['id' => 'by_day']
|
||||
);
|
||||
$formByDay->addElement('text', 'from', get_lang('From'), ['placeholder' => get_lang('DateFormatddmmyyyy')]);
|
||||
$formByDay->addElement('text', 'to', get_lang('Until'), ['placeholder' => get_lang('DateFormatddmmyyyy')]);
|
||||
$formByDay->addCheckBox('reduced', null, get_lang('ReducedReport'));
|
||||
$formByDay->addHidden('user_id', $userId);
|
||||
$formByDay->addRule('from', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$formByDay->addRule('from', get_lang('ThisFieldIsRequired').' dd/mm/yyyy', 'callback', 'validateDate');
|
||||
$formByDay->addRule('to', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$formByDay->addRule('to', get_lang('ThisFieldIsRequired').' dd/mm/yyyy', 'callback', 'validateDate');
|
||||
$formByDay->addButtonSearch(get_lang('GenerateReport'));
|
||||
|
||||
if ($formByDay->validate()) {
|
||||
$from = $formByDay->getSubmitValue('from');
|
||||
$to = $formByDay->getSubmitValue('to');
|
||||
$reduced = !empty($formByDay->getSubmitValue('reduced'));
|
||||
|
||||
$fromObject = DateTime::createFromFormat('d/m/Y', $from);
|
||||
$toObject = DateTime::createFromFormat('d/m/Y', $to);
|
||||
|
||||
$from = api_get_utc_datetime($fromObject->format('Y-m-d').' 00:00:00');
|
||||
$to = api_get_utc_datetime($toObject->format('Y-m-d').' 23:59:59');
|
||||
|
||||
$list = Tracking::get_time_spent_on_the_platform($userId, 'wide', $from, $to, true);
|
||||
$newList = [];
|
||||
foreach ($list as $item) {
|
||||
$key = substr($item['login_date'], 0, 10);
|
||||
|
||||
$dateLogout = substr($item['logout_date'], 0, 10);
|
||||
if ($dateLogout > $key) {
|
||||
$itemLogoutOriginal = $item['logout_date'];
|
||||
$fromItemObject = DateTime::createFromFormat('Y-m-d H:i:s', $item['login_date'], new DateTimeZone('UTC'));
|
||||
$toItemObject = DateTime::createFromFormat('Y-m-d H:i:s', $item['logout_date'], new DateTimeZone('UTC'));
|
||||
$item['logout_date'] = api_get_utc_datetime($key.' 23:59:59');
|
||||
|
||||
$period = new DatePeriod(
|
||||
$fromItemObject,
|
||||
new DateInterval('P1D'),
|
||||
$toItemObject
|
||||
);
|
||||
|
||||
$counter = 1;
|
||||
$itemKey = null;
|
||||
foreach ($period as $value) {
|
||||
$dateToCheck = api_get_utc_datetime($value->format('Y-m-d').' 00:00:01');
|
||||
$end = api_get_utc_datetime($value->format('Y-m-d').' 23:59:59');
|
||||
if ($counter === 1) {
|
||||
$dateToCheck = $item['login_date'];
|
||||
}
|
||||
$itemKey = substr($value->format('Y-m-d'), 0, 10);
|
||||
|
||||
if (isset($newList[$itemKey])) {
|
||||
if ($newList[$itemKey]['login_date']) {
|
||||
$dateToCheck = $newList[$itemKey]['login_date'];
|
||||
}
|
||||
}
|
||||
|
||||
$newList[$itemKey] = [
|
||||
'login_date' => $dateToCheck,
|
||||
'logout_date' => $end,
|
||||
'diff' => 0,
|
||||
];
|
||||
|
||||
$counter++;
|
||||
}
|
||||
|
||||
if (!empty($itemKey) && isset($newList[$itemKey])) {
|
||||
if (
|
||||
substr(api_get_local_time($newList[$itemKey]['login_date']), 0, 10) ===
|
||||
substr(api_get_local_time($itemLogoutOriginal), 0, 10)
|
||||
) {
|
||||
$newList[$itemKey]['logout_date'] = $itemLogoutOriginal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($newList[$key])) {
|
||||
$newList[$key] = [
|
||||
'login_date' => $item['login_date'],
|
||||
'logout_date' => $item['logout_date'],
|
||||
'diff' => 0,
|
||||
];
|
||||
} else {
|
||||
$newList[$key] = [
|
||||
'login_date' => $newList[$key]['login_date'],
|
||||
'logout_date' => $item['logout_date'],
|
||||
'diff' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($newList)) {
|
||||
foreach ($newList as &$item) {
|
||||
$item['diff'] = api_strtotime($item['logout_date']) - api_strtotime($item['login_date']);
|
||||
}
|
||||
}
|
||||
|
||||
$period = new DatePeriod(
|
||||
$fromObject,
|
||||
new DateInterval('P1D'),
|
||||
$toObject
|
||||
);
|
||||
|
||||
$tableList = '';
|
||||
foreach ($period as $value) {
|
||||
$dateToCheck = $value->format('Y-m-d');
|
||||
$data = isset($newList[$dateToCheck]) ? $newList[$dateToCheck] : [];
|
||||
|
||||
if (empty($data)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$table = new HTML_Table(['class' => ' table_print']);
|
||||
$headers = [
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnection'),
|
||||
get_lang('Total'),
|
||||
];
|
||||
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
|
||||
$row = 1;
|
||||
$column = 0;
|
||||
$table->setCellContents($row, $column++, customDate($data['login_date'], true));
|
||||
$table->setCellContents($row, $column++, customDate($data['logout_date'], true));
|
||||
$table->setCellContents($row, $column, api_format_time($data['diff'], 'lang'));
|
||||
|
||||
$result = getReport($userId, $dateToCheck, $dateToCheck, true);
|
||||
$first = $result['first'];
|
||||
$courseSessionTable = $result['second'];
|
||||
$totalCourseSessionTable = $result['third'];
|
||||
$total = $result['total'];
|
||||
$iconCalendar = Display::return_icon('calendar.png', null, [], ICON_SIZE_SMALL);
|
||||
$tableList .= '<div class="date-calendar">'.Display::page_subheader2(
|
||||
$iconCalendar.get_lang('Date').': '.$dateToCheck
|
||||
).'</div>';
|
||||
$tableList .= $table->toHtml();
|
||||
if (!$reduced && !empty($total)) {
|
||||
$diff = get_lang('NotInCourse').' '.api_format_time($data['diff'] - $total, 'lang');
|
||||
$tableList .= $courseSessionTable;
|
||||
$tableList .= $totalCourseSessionTable;
|
||||
$tableList .= '<div style="text-align: center;">'.Display::page_subheader3($diff).'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = new Template('', false, false, false, true, false, false);
|
||||
$tpl->assign('title', get_lang('RealisationCertificate'));
|
||||
$tpl->assign('student', $userInfo['complete_name']);
|
||||
$totalTable = Display::page_subheader3(sprintf(get_lang('ExtractionFromX'), api_get_local_time()));
|
||||
$tpl->assign('table_progress', $totalTable.$tableList);
|
||||
|
||||
$content = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl'));
|
||||
|
||||
$params = [
|
||||
'pdf_title' => get_lang('Resume'),
|
||||
'course_info' => '',
|
||||
'pdf_date' => '',
|
||||
'student_info' => $userInfo,
|
||||
'show_grade_generated_date' => true,
|
||||
'show_real_course_teachers' => false,
|
||||
'show_teacher_as_myself' => false,
|
||||
'orientation' => 'P',
|
||||
];
|
||||
$pdfName = api_strtoupper($userInfo['lastname'].'_'.$userInfo['firstname']).'_'.api_get_local_time();
|
||||
@$pdf = new PDF('A4', $params['orientation'], $params);
|
||||
@$pdf->setBackground($tpl->theme, true);
|
||||
@$pdf->content_to_pdf(
|
||||
$content,
|
||||
'',
|
||||
$pdfName,
|
||||
null,
|
||||
'D',
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
$formByDay->setDefaults(['from' => $startDate, 'to' => $endDate]);
|
||||
|
||||
Display::display_header('');
|
||||
echo Display::page_header(get_lang('CertificateOfAchievement'), get_lang('CertificateOfAchievementHelp'));
|
||||
echo Display::page_subheader(
|
||||
get_lang('User').': '.$userInfo['complete_name']
|
||||
);
|
||||
|
||||
echo Display::tabs(
|
||||
[get_lang('CertificateOfAchievement'), get_lang('CertificateOfAchievementByDay')],
|
||||
[$form->returnForm(), $formByDay->returnForm()]
|
||||
);
|
||||
|
||||
Display::display_footer();
|
||||
119
main/mySpace/admin.php
Normal file
119
main/mySpace/admin.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* Special reporting page for admins.
|
||||
*/
|
||||
ob_start();
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$nameTools = get_lang('Administrators');
|
||||
|
||||
api_block_anonymous_users();
|
||||
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
|
||||
Display::display_header($nameTools);
|
||||
|
||||
api_display_tool_title($nameTools);
|
||||
|
||||
// Database Table Definitions
|
||||
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
|
||||
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
|
||||
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
|
||||
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
|
||||
$tbl_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
|
||||
|
||||
if (isset($_POST['export'])) {
|
||||
$order_clause = api_is_western_name_order(PERSON_NAME_DATA_EXPORT) ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
|
||||
} else {
|
||||
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
|
||||
}
|
||||
$sql = "SELECT user.user_id,lastname,firstname,email
|
||||
FROM $tbl_user as user, $tbl_admin as admin
|
||||
WHERE admin.user_id=user.user_id".$order_clause;
|
||||
$result_admins = Database::query($sql);
|
||||
|
||||
if (api_is_western_name_order()) {
|
||||
echo '<table class="table table-hover table-striped data_table">
|
||||
<tr>
|
||||
<th>'.get_lang('FirstName').'</th>
|
||||
<th>'.get_lang('LastName').'</th>
|
||||
<th>'.get_lang('Email').'</th></tr>';
|
||||
} else {
|
||||
echo '<table class="table table-hover table-striped data_table">
|
||||
<tr>
|
||||
<th>'.get_lang('LastName').'</th>
|
||||
<th>'.get_lang('FirstName').'</th>
|
||||
<th>'.get_lang('Email').'</th></tr>';
|
||||
}
|
||||
|
||||
if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
|
||||
$header[] = get_lang('FirstName', '');
|
||||
$header[] = get_lang('LastName', '');
|
||||
} else {
|
||||
$header[] = get_lang('LastName', '');
|
||||
$header[] = get_lang('FirstName', '');
|
||||
}
|
||||
$header[] = get_lang('Email', '');
|
||||
|
||||
if (Database::num_rows($result_admins) > 0) {
|
||||
while ($admins = Database::fetch_array($result_admins)) {
|
||||
$user_id = $admins["user_id"];
|
||||
$lastname = $admins["lastname"];
|
||||
$firstname = $admins["firstname"];
|
||||
$email = $admins["email"];
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$css_class = "row_odd";
|
||||
if ($i % 20 == 0 && $i != 0) {
|
||||
if (api_is_western_name_order()) {
|
||||
echo '<tr><th>'.get_lang('FirstName').'</th><th>'.get_lang('LastName').'</th><th>'.get_lang('Email').'</th></tr>';
|
||||
} else {
|
||||
echo '<tr><th>'.get_lang('LastName').'</th><th>'.get_lang('FirstName').'</th><th>'.get_lang('Email').'</th></tr>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$css_class = "row_even";
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
if (api_is_western_name_order()) {
|
||||
echo "<tr class=".$css_class."><td>$firstname</td><td>$lastname</td><td><a href='mailto:".$email."'>$email</a></td></tr>";
|
||||
} else {
|
||||
echo "<tr class=".$css_class."><td>$lastname</td><td>$firstname</td><td><a href='mailto:".$email."'>$email</a></td></tr>";
|
||||
}
|
||||
|
||||
if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
|
||||
$data[$user_id]["firstname"] = $firstname;
|
||||
$data[$user_id]["lastname"] = $lastname;
|
||||
} else {
|
||||
$data[$user_id]["lastname"] = $lastname;
|
||||
$data[$user_id]["firstname"] = $firstname;
|
||||
}
|
||||
$data[$user_id]["email"] = $email;
|
||||
}
|
||||
} else {
|
||||
// No results
|
||||
echo '<tr><td colspan="3">'.get_lang('NoResults').'</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
if (isset($_POST['export'])) {
|
||||
export_csv($header, $data, 'administrators.csv');
|
||||
}
|
||||
|
||||
echo "
|
||||
<br /><br />
|
||||
<form method='post' action='admin.php'>
|
||||
<button type='submit' class='save' name='export' value='".get_lang('ExportExcel')."'>
|
||||
".get_lang('ExportExcel')."
|
||||
</button>
|
||||
<form>
|
||||
";
|
||||
|
||||
Display::display_footer();
|
||||
141
main/mySpace/admin_view.php
Normal file
141
main/mySpace/admin_view.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$exportCSV = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false;
|
||||
if (isset($_GET['export_csv']) && $exportCSV == false) {
|
||||
// to export learningPath and company
|
||||
$exportCSV = true;
|
||||
}
|
||||
$startDate = isset($_GET['startDate']) ? $_GET['startDate'] : null;
|
||||
$endDate = isset($_GET['endDate']) ? $_GET['endDate'] : null;
|
||||
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
|
||||
if (isset($_POST['display']) && $display == null) {
|
||||
$display = Security::remove_XSS($_POST['display']);
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$htmlHeadXtra[] = '<script
|
||||
type="text/javascript"
|
||||
src="'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>
|
||||
<script type="text/javascript">
|
||||
// show hide a student based on BT#17648
|
||||
function showHideStudent(el){
|
||||
if($("#"+el).hasClass("hidden")){
|
||||
$("#"+el).removeClass("hidden");
|
||||
$("#"+el+"_").find(".icon_add").addClass("hidden");
|
||||
$("#"+el+"_").find(".icon_remove").removeClass("hidden");
|
||||
}else{
|
||||
$("#"+el).addClass("hidden")
|
||||
$("#"+el+"_").find(".icon_add").removeClass("hidden");
|
||||
$("#"+el+"_").find(".icon_remove").addClass("hidden");
|
||||
}
|
||||
}
|
||||
function ShowMoreAuthor(el){
|
||||
if($(".author_"+el).hasClass("hidden")){
|
||||
$(".author_"+el).removeClass("hidden");
|
||||
$(".icon_remove_author_"+el).removeClass("hidden");
|
||||
$(".icon_add_author_"+el).addClass("hidden");
|
||||
}else{
|
||||
$(".author_"+el).addClass("hidden")
|
||||
$(".icon_remove_author_"+el).addClass("hidden");
|
||||
$(".icon_add_author_"+el).removeClass("hidden");
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
// the section (for the tabs)
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$csv_content = [];
|
||||
$nameTools = get_lang('MySpace');
|
||||
$allowToTrack = api_is_platform_admin(true, true);
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if ($exportCSV) {
|
||||
if ('user' === $display) {
|
||||
MySpace::export_tracking_user_overview();
|
||||
exit;
|
||||
} elseif ('session' === $display) {
|
||||
MySpace::export_tracking_session_overview();
|
||||
exit;
|
||||
} elseif ('course' === $display) {
|
||||
MySpace::export_tracking_course_overview();
|
||||
exit;
|
||||
} elseif ('company' === $display) {
|
||||
MySpace::exportCompanyResumeCsv($startDate, $endDate);
|
||||
exit;
|
||||
} elseif ('learningPath' === $display) {
|
||||
MySpace::displayResumeLP($startDate, $endDate, true);
|
||||
exit;
|
||||
} elseif ('learningPathByItem' === $display) {
|
||||
MySpace::displayResumeLpByItem($startDate, $endDate, true);
|
||||
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;
|
||||
case 'company':
|
||||
MySpace::displayResumeCompany($startDate, $endDate);
|
||||
break;
|
||||
case 'learningPath':
|
||||
MySpace::displayResumeLP($startDate, $endDate);
|
||||
break;
|
||||
case 'learningPathByItem':
|
||||
MySpace::displayResumeLpByItem($startDate, $endDate);
|
||||
break;
|
||||
case 'accessoverview':
|
||||
$courseId = isset($_GET['course_id']) ? (int) $_GET['course_id'] : 0;
|
||||
if ($courseId == 0 && $_POST['course_id']) {
|
||||
$courseId = (int) $_POST['course_id'];
|
||||
$_GET['course_id'] = $courseId;
|
||||
}
|
||||
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
|
||||
if ($sessionId == 0 && $_POST['session_id']) {
|
||||
$sessionId = (int) $_POST['session_id'];
|
||||
$_GET['session_id'] = $sessionId;
|
||||
}
|
||||
$studentId = isset($_GET['student_id']) ? (int) $_GET['student_id'] : 0;
|
||||
if ($studentId == 0 && $_POST['student_id']) {
|
||||
$studentId = (int) $_POST['student_id'];
|
||||
$_GET['student_id'] = $studentId;
|
||||
}
|
||||
$perPage = isset($_GET['tracking_access_overview_per_page']) ? $_GET['tracking_access_overview_per_page'] : 20;
|
||||
|
||||
$dates = isset($_GET['date']) ? $_GET['date'] : null;
|
||||
if ($dates == null && $_POST['date']) {
|
||||
$dates = $_POST['date'];
|
||||
$_GET['date'] = $dates;
|
||||
}
|
||||
MySpace::displayTrackingAccessOverView($courseId, $sessionId, $studentId, $perPage, $dates);
|
||||
break;
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
113
main/mySpace/calendar_plan.php
Normal file
113
main/mySpace/calendar_plan.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$studentList = UserManager::getUsersFollowedByStudentBoss(api_get_user_id());
|
||||
|
||||
$current_course_tool = TOOL_CALENDAR_EVENT;
|
||||
$this_section = SECTION_MYAGENDA;
|
||||
|
||||
$timezone = new DateTimeZone(api_get_timezone());
|
||||
$now = new DateTime('now', $timezone);
|
||||
$currentYear = (int) $now->format('Y');
|
||||
|
||||
$searchYear = isset($_GET['year']) ? (int) $_GET['year'] : $currentYear;
|
||||
$currentOrder = isset($_GET['order']) && 'desc' === $_GET['order'] ? 'desc' : 'asc';
|
||||
|
||||
if (api_is_western_name_order()) {
|
||||
$orderBy = "firstname";
|
||||
} else {
|
||||
$orderBy = "lastname";
|
||||
}
|
||||
|
||||
$students = UserManager::getUsersFollowedByUser(
|
||||
api_get_user_id(),
|
||||
STUDENT,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
$orderBy,
|
||||
$currentOrder,
|
||||
null,
|
||||
null,
|
||||
api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER
|
||||
);
|
||||
|
||||
if ('desc' === $currentOrder) {
|
||||
$order = 'asc';
|
||||
} else {
|
||||
$order = 'desc';
|
||||
}
|
||||
|
||||
$userInfo = api_get_user_info();
|
||||
$userId = $userInfo['id'];
|
||||
|
||||
$globalColors = ChamiloApi::getColorPalette(false, true, 500);
|
||||
$sessionColors = [];
|
||||
$sessionColorName = [];
|
||||
|
||||
foreach ($students as &$student) {
|
||||
$student = api_get_user_info($student['user_id']);
|
||||
$sessionsList = UserManager::getSubscribedSessionsByYear($student, $searchYear);
|
||||
$sessions = UserManager::getSessionsCalendarByYear($sessionsList, $searchYear);
|
||||
$personalColors = [];
|
||||
$counter = 0;
|
||||
foreach ($sessions as &$session) {
|
||||
if (!isset($sessionColors[$session['id']])) {
|
||||
$session['color'] = $globalColors[$counter];
|
||||
$sessionColors[$session['id']] = $session['color'];
|
||||
$sessionColorName[$session['color']] = $session['name'];
|
||||
} else {
|
||||
$session['color'] = $sessionColors[$session['id']];
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
$student['sessions'] = $sessions;
|
||||
//$colors = ChamiloApi::getColorPalette(false, true, count($sessions));
|
||||
//$student['colors'] = $colors;
|
||||
}
|
||||
|
||||
$table = new HTML_Table(['class' => 'table table-responsive']);
|
||||
$headers = [
|
||||
get_lang('SessionName'),
|
||||
get_lang('Color'),
|
||||
];
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$row++;
|
||||
foreach ($sessionColorName as $color => $name) {
|
||||
$table->setCellContents($row, 0, $name);
|
||||
$table->setCellContents($row, 1, "<div style='background:$color '> </div>");
|
||||
$row++;
|
||||
}
|
||||
|
||||
$agenda = new Agenda('personal');
|
||||
$actions = $agenda->displayActions('list', $userId);
|
||||
|
||||
$toolName = get_lang('SessionsPlanCalendar');
|
||||
|
||||
$template = new Template($toolName);
|
||||
$template->assign('toolbar', $actions);
|
||||
$template->assign('student_id', $userId);
|
||||
$template->assign('search_year', $searchYear);
|
||||
$template->assign('students', $students);
|
||||
$template->assign('legend', $table->toHtml());
|
||||
$template->assign('order', $order);
|
||||
$template->assign('current_order', $currentOrder);
|
||||
|
||||
$layout = $template->get_template('agenda/student_boss_planification.tpl');
|
||||
$template->display($layout);
|
||||
224
main/mySpace/coaches.php
Normal file
224
main/mySpace/coaches.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
ob_start();
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$nameTools = get_lang('Tutors');
|
||||
|
||||
api_block_anonymous_users();
|
||||
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
|
||||
|
||||
if (isset($_GET["id_student"])) {
|
||||
$interbreadcrumb[] = ["url" => "student.php", "name" => get_lang('Students')];
|
||||
}
|
||||
|
||||
Display::display_header($nameTools);
|
||||
|
||||
api_display_tool_title($nameTools);
|
||||
|
||||
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
|
||||
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
|
||||
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
|
||||
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
|
||||
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
|
||||
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
|
||||
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
|
||||
|
||||
/**
|
||||
* MAIN PART.
|
||||
*/
|
||||
if (isset($_POST['export'])) {
|
||||
$order_clause = api_is_western_name_order(PERSON_NAME_DATA_EXPORT) ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
|
||||
} else {
|
||||
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
|
||||
}
|
||||
|
||||
if (isset($_GET["id_student"])) {
|
||||
$id_student = intval($_GET["id_student"]);
|
||||
$sql_coachs = "SELECT DISTINCT srcru.user_id as id_coach
|
||||
FROM $tbl_session_rel_course_rel_user as srcru
|
||||
WHERE srcru.user_id='$id_student' AND srcru.status=2";
|
||||
} else {
|
||||
if (api_is_platform_admin()) {
|
||||
$sql_coachs = "SELECT DISTINCT
|
||||
srcru.user_id as id_coach, user_id, lastname, firstname
|
||||
FROM $tbl_user, $tbl_session_rel_course_rel_user srcru
|
||||
WHERE
|
||||
srcru.user_id=user_id AND
|
||||
srcru.status=2 ".$order_clause;
|
||||
} else {
|
||||
$sql_coachs = "SELECT DISTINCT user_id as id_coach, user.user_id, lastname, firstname
|
||||
FROM
|
||||
$tbl_user as user,
|
||||
$tbl_session_rel_course_user as srcu,
|
||||
$tbl_course_user as course_rel_user,
|
||||
$tbl_course as c
|
||||
WHERE
|
||||
c.id = course_rel_user.c_id AND
|
||||
c.id = srcu.c_id AND
|
||||
course_rel_user.status='1' AND
|
||||
course_rel_user.user_id='".api_get_user_id()."' AND
|
||||
srcu.user_id = user.user_id AND
|
||||
srcu.status = 2
|
||||
".$order_clause;
|
||||
}
|
||||
}
|
||||
|
||||
$result_coachs = Database::query($sql_coachs);
|
||||
|
||||
if (api_is_western_name_order()) {
|
||||
echo '<table class="table table-hover table-striped data_table">
|
||||
<tr>
|
||||
<th>'.get_lang('FirstName').'</th>
|
||||
<th>'.get_lang('LastName').'</th>
|
||||
<th>'.get_lang('ConnectionTime').'</th>
|
||||
<th>'.get_lang('AdminCourses').'</th>
|
||||
<th>'.get_lang('Students').'</th>
|
||||
</tr>';
|
||||
} else {
|
||||
echo '<table class="table table-hover table-striped data_table">
|
||||
<tr>
|
||||
<th>'.get_lang('LastName').'</th>
|
||||
<th>'.get_lang('FirstName').'</th>
|
||||
<th>'.get_lang('ConnectionTime').'</th>
|
||||
<th>'.get_lang('AdminCourses').'</th>
|
||||
<th>'.get_lang('Students').'</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
|
||||
$header[] = get_lang('FirstName', '');
|
||||
$header[] = get_lang('LastName', '');
|
||||
} else {
|
||||
$header[] = get_lang('LastName', '');
|
||||
$header[] = get_lang('FirstName', '');
|
||||
}
|
||||
$header[] = get_lang('ConnectionTime', '');
|
||||
|
||||
if (Database::num_rows($result_coachs) > 0) {
|
||||
while ($coachs = Database::fetch_array($result_coachs)) {
|
||||
$id_coach = $coachs["id_coach"];
|
||||
|
||||
if (isset($_GET["id_student"])) {
|
||||
$sql_infos_coach = "SELECT lastname, firstname
|
||||
FROM $tbl_user
|
||||
WHERE user_id='$id_coach'";
|
||||
$result_coachs_infos = Database::query($sql_infos_coach);
|
||||
$lastname = Database::result($result_coachs_infos, 0, "lastname");
|
||||
$firstname = Database::result($result_coachs_infos, 0, "firstname");
|
||||
} else {
|
||||
$lastname = $coachs["lastname"];
|
||||
$firstname = $coachs["firstname"];
|
||||
}
|
||||
|
||||
$sql_connection_time = "SELECT login_date, logout_date
|
||||
FROM $tbl_track_login
|
||||
WHERE login_user_id ='$id_coach' AND logout_date <> 'null'";
|
||||
$result_connection_time = Database::query($sql_connection_time);
|
||||
|
||||
$nb_seconds = 0;
|
||||
while ($connections = Database::fetch_array($result_connection_time)) {
|
||||
$login_date = $connections["login_date"];
|
||||
$logout_date = $connections["logout_date"];
|
||||
$timestamp_login_date = strtotime($login_date);
|
||||
$timestamp_logout_date = strtotime($logout_date);
|
||||
$nb_seconds += ($timestamp_logout_date - $timestamp_login_date);
|
||||
}
|
||||
|
||||
if ($nb_seconds == 0) {
|
||||
$s_connection_time = '';
|
||||
} else {
|
||||
$s_connection_time = api_time_to_hms($nb_seconds);
|
||||
}
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$css_class = "row_odd";
|
||||
if ($i % 20 == 0 && $i != 0) {
|
||||
if (api_is_western_name_order()) {
|
||||
echo '<tr>
|
||||
<th>'.get_lang('FirstName').'</th>
|
||||
<th>'.get_lang('LastName').'</th>
|
||||
<th>'.get_lang('ConnectionTime').'</th>
|
||||
<th>'.get_lang('AdminCourses').'</th>
|
||||
<th>'.get_lang('Students').'</th>
|
||||
</tr>';
|
||||
} else {
|
||||
echo '<tr>
|
||||
<th>'.get_lang('LastName').'</th>
|
||||
<th>'.get_lang('FirstName').'</th>
|
||||
<th>'.get_lang('ConnectionTime').'</th>
|
||||
<th>'.get_lang('AdminCourses').'</th>
|
||||
<th>'.get_lang('Students').'</th>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$css_class = "row_even";
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
if (api_is_western_name_order()) {
|
||||
echo '<tr class="'.$css_class.'">
|
||||
<td>'.$firstname.'</td><td>'.$lastname.'</td><td>'.$s_connection_time.'</td>
|
||||
<td>
|
||||
<a href="course.php?type=coach&user_id='.$id_coach.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="student.php?type=coach&user_id='.$id_coach.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'
|
||||
</a>
|
||||
</td>
|
||||
</tr>';
|
||||
} else {
|
||||
echo '<tr class="'.$css_class.'">
|
||||
<td>'.$lastname.'</td><td>'.$firstname.'</td>
|
||||
<td>'.$s_connection_time.'</td>
|
||||
<td>
|
||||
<a href="course.php?type=coach&user_id='.$id_coach.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>
|
||||
<td>
|
||||
<a href="student.php?type=coach&user_id='.$id_coach.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
|
||||
$data[$id_coach]["firstname"] = $firstname;
|
||||
$data[$id_coach]["lastname"] = $lastname;
|
||||
} else {
|
||||
$data[$id_coach]["lastname"] = $lastname;
|
||||
$data[$id_coach]["firstname"] = $firstname;
|
||||
}
|
||||
$data[$id_coach]["connection_time"] = $s_connection_time;
|
||||
}
|
||||
} else {
|
||||
// No results
|
||||
echo '<tr><td colspan="5">'.get_lang("NoResult").'</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
if (isset($_POST['export'])) {
|
||||
export_csv($header, $data, 'coaches.csv');
|
||||
}
|
||||
|
||||
echo "<br /><br />";
|
||||
echo "
|
||||
<br /><br />
|
||||
<form method='post' action='coaches.php'>
|
||||
<button type='submit' class='save' name='export' value='".get_lang('ExportExcel')."'>
|
||||
".get_lang('ExportExcel')."
|
||||
</button>
|
||||
<form>
|
||||
";
|
||||
Display::display_footer();
|
||||
268
main/mySpace/company_reports.php
Normal file
268
main/mySpace/company_reports.php
Normal file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Special report for corporate users.
|
||||
*/
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true);
|
||||
|
||||
if ($userNotAllowed) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => api_is_student_boss() ? '#' : 'index.php', 'name' => get_lang('MySpace')];
|
||||
$tool_name = get_lang('Report');
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : -1;
|
||||
|
||||
//jqgrid will use this URL to do the selects
|
||||
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report&session_id='.$sessionId;
|
||||
|
||||
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
|
||||
|
||||
//The order is important you need to check the the $column variable in the model.ajax.php file
|
||||
$columns = [
|
||||
get_lang('Course'),
|
||||
get_lang('User'),
|
||||
get_lang('Email'),
|
||||
get_lang('ManHours'),
|
||||
get_lang('CertificateGenerated'),
|
||||
get_lang('LearnpathsDone'),
|
||||
get_lang('CourseAdvance'),
|
||||
];
|
||||
|
||||
//Column config
|
||||
$column_model = [
|
||||
[
|
||||
'name' => 'course',
|
||||
'index' => 'title',
|
||||
'width' => '180',
|
||||
'align' => 'left',
|
||||
'wrap_cell' => 'true',
|
||||
'search' => 'false',
|
||||
],
|
||||
[
|
||||
'name' => 'user',
|
||||
'index' => 'user',
|
||||
'width' => '100',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
'wrap_cell' => 'true',
|
||||
'search' => 'false',
|
||||
],
|
||||
[
|
||||
'name' => 'email',
|
||||
'index' => 'email',
|
||||
'width' => '100',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
'wrap_cell' => 'true',
|
||||
'search' => 'false',
|
||||
],
|
||||
[
|
||||
'name' => 'time',
|
||||
'index' => 'time',
|
||||
'width' => '50',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
'search' => 'false',
|
||||
],
|
||||
[
|
||||
'name' => 'certificate',
|
||||
'index' => 'certificate',
|
||||
'width' => '50',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
'search' => 'false',
|
||||
],
|
||||
[
|
||||
'name' => 'progress_100',
|
||||
'index' => 'progress_100',
|
||||
'width' => '50',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
'search' => 'false',
|
||||
],
|
||||
[
|
||||
'name' => 'progress',
|
||||
'index' => 'progress',
|
||||
'width' => '50',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
'search' => 'false',
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($extra_fields)) {
|
||||
foreach ($extra_fields as $extra) {
|
||||
$col = [
|
||||
'name' => $extra['1'],
|
||||
'index' => 'extra_'.$extra['1'],
|
||||
'width' => '120',
|
||||
'sortable' => 'false',
|
||||
'wrap_cell' => 'true',
|
||||
];
|
||||
$column_model[] = $col;
|
||||
$columns[] = $extra['3'];
|
||||
}
|
||||
}
|
||||
|
||||
if (api_is_student_boss()) {
|
||||
$column_model[] = [
|
||||
'name' => 'group',
|
||||
'index' => 'group',
|
||||
'width' => '50',
|
||||
'align' => 'left',
|
||||
'sortable' => 'false',
|
||||
];
|
||||
$columns[] = get_lang('Group');
|
||||
}
|
||||
|
||||
// Autowidth
|
||||
$extra_params['autowidth'] = 'true';
|
||||
// height auto
|
||||
$extra_params['height'] = 'auto';
|
||||
|
||||
$htmlHeadXtra[] = '<script>
|
||||
$(function() {
|
||||
'.Display::grid_js(
|
||||
'user_course_report',
|
||||
$url,
|
||||
$columns,
|
||||
$column_model,
|
||||
$extra_params,
|
||||
[],
|
||||
null,
|
||||
true
|
||||
).'
|
||||
|
||||
var added_cols = [];
|
||||
var original_cols = [];
|
||||
|
||||
function clean_cols(grid, added_cols) {
|
||||
// Cleaning
|
||||
for (key in added_cols) {
|
||||
grid.hideCol(key);
|
||||
}
|
||||
grid.showCol(\'name\');
|
||||
grid.showCol(\'display_start_date\');
|
||||
grid.showCol(\'display_end_date\');
|
||||
grid.showCol(\'course_title\');
|
||||
}
|
||||
|
||||
function show_cols(grid, added_cols) {
|
||||
grid.showCol("name").trigger("reloadGrid");
|
||||
for (key in added_cols) {
|
||||
grid.showCol(key);
|
||||
}
|
||||
}
|
||||
|
||||
var grid = $("#user_course_report");
|
||||
var prmSearch = {
|
||||
multipleSearch : true,
|
||||
overlay : false,
|
||||
width: "auto",
|
||||
caption: "'.addslashes(get_lang('Search')).'",
|
||||
formclass: "data_table",
|
||||
onSearch : function() {
|
||||
var postdata = grid.jqGrid("getGridParam", "postData");
|
||||
if (postdata && postdata.filters) {
|
||||
filters = jQuery.parseJSON(postdata.filters);
|
||||
clean_cols(grid, added_cols);
|
||||
added_cols = [];
|
||||
$.each(filters, function(key, value) {
|
||||
if (key == "rules") {
|
||||
$.each(value, function(subkey, subvalue) {
|
||||
if (subvalue.data == undefined) {
|
||||
}
|
||||
added_cols[subvalue.field] = subvalue.field;
|
||||
});
|
||||
}
|
||||
});
|
||||
show_cols(grid, added_cols);
|
||||
}
|
||||
},
|
||||
onReset: function() {
|
||||
clean_cols(grid, added_cols);
|
||||
}
|
||||
}
|
||||
|
||||
grid.jqGrid(
|
||||
"navGrid",
|
||||
"#user_course_report_pager",
|
||||
{
|
||||
view:false,
|
||||
edit:false,
|
||||
add:false,
|
||||
del:false,
|
||||
search:true,
|
||||
excel:true
|
||||
},
|
||||
{height:280,reloadAfterSubmit:false}, // edit options
|
||||
{height:280,reloadAfterSubmit:false}, // add options
|
||||
{reloadAfterSubmit:false},
|
||||
prmSearch
|
||||
);
|
||||
|
||||
grid.searchGrid(prmSearch);
|
||||
|
||||
grid.jqGrid("navButtonAdd","#user_course_report_pager", {
|
||||
caption:"",
|
||||
onClickButton : function () {
|
||||
grid.jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
$actions = null;
|
||||
|
||||
if (api_is_student_boss()) {
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."mySpace/student.php"
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon("statistics.png", get_lang("CompanyReport"), [], ICON_SIZE_MEDIUM),
|
||||
"#"
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon(
|
||||
"certificate_list.png",
|
||||
get_lang("GradebookSeeListOfStudentsCertificates"),
|
||||
[],
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php"
|
||||
);
|
||||
}
|
||||
|
||||
$content = '<div class="actions">';
|
||||
|
||||
if (!empty($actions)) {
|
||||
$content .= $actions;
|
||||
}
|
||||
$content .= Display::url(
|
||||
get_lang('CompanyReportResumed'),
|
||||
api_get_path(WEB_CODE_PATH)."mySpace/company_reports_resumed.php",
|
||||
[
|
||||
'class' => 'btn btn-success',
|
||||
]
|
||||
);
|
||||
$content .= '</div>';
|
||||
$content .= '<h1 class="page-header">'.get_lang('CompanyReport').'</h1>';
|
||||
$content .= Display::grid_html('user_course_report');
|
||||
$tpl = new Template($tool_name);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
132
main/mySpace/company_reports_resumed.php
Normal file
132
main/mySpace/company_reports_resumed.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* Special report for corporate users.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$userNotAllowed = !api_is_student_boss() && !api_is_platform_admin(false, true);
|
||||
|
||||
if ($userNotAllowed) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => api_is_student_boss() ? '#' : 'index.php', 'name' => get_lang('MySpace')];
|
||||
|
||||
$tool_name = get_lang('Report');
|
||||
$this_section = SECTION_TRACKING;
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : -1;
|
||||
|
||||
// jqgrid will use this URL to do the selects
|
||||
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_user_course_report_resumed&session_id='.$sessionId;
|
||||
|
||||
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
|
||||
|
||||
// The order is important you need to check the the $column variable in the model.ajax.php file.
|
||||
$columns = [
|
||||
get_lang('Company'),
|
||||
get_lang('TrainingHoursAccumulated'),
|
||||
get_lang('CountOfSubscriptions'),
|
||||
get_lang('CountOfUsers'),
|
||||
get_lang('AverageHoursPerStudent'),
|
||||
get_lang('CountCertificates'),
|
||||
];
|
||||
|
||||
// Column config.
|
||||
$column_model = [
|
||||
['name' => 'extra_ruc', 'index' => 'extra_ruc', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'],
|
||||
['name' => 'training_hours', 'index' => 'training_hours', 'width' => '100', 'align' => 'left'],
|
||||
['name' => 'count_users', 'index' => 'count_users', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
|
||||
['name' => 'count_users_registered', 'index' => 'count_users_registered', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
|
||||
['name' => 'average_hours_per_user', 'index' => 'average_hours_per_user', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
|
||||
['name' => 'count_certificates', 'index' => 'count_certificates', 'width' => '100', 'align' => 'left', 'sortable' => 'false'],
|
||||
];
|
||||
|
||||
if (!empty($extra_fields)) {
|
||||
foreach ($extra_fields as $extra) {
|
||||
if ($extra['1'] == 'ruc') {
|
||||
continue;
|
||||
}
|
||||
$col = [
|
||||
'name' => $extra['1'],
|
||||
'index' => $extra['1'],
|
||||
'width' => '120',
|
||||
'sortable' => 'false',
|
||||
'wrap_cell' => 'true',
|
||||
];
|
||||
$column_model[] = $col;
|
||||
|
||||
$columns[] = $extra['3'];
|
||||
}
|
||||
}
|
||||
|
||||
// Autowidth.
|
||||
$extra_params['autowidth'] = 'true';
|
||||
//height auto
|
||||
$extra_params['height'] = 'auto';
|
||||
|
||||
$htmlHeadXtra[] = '<script>
|
||||
$(function() {
|
||||
'.Display::grid_js('user_course_report', $url, $columns, $column_model, $extra_params, [], 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:"",
|
||||
onClickButton : function () {
|
||||
jQuery("#user_course_report").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
$actions = null;
|
||||
|
||||
if (api_is_student_boss()) {
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."mySpace/student.php"
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon("statistics.png", get_lang("CompanyReport"), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php"
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon(
|
||||
"certificate_list.png",
|
||||
get_lang("GradebookSeeListOfStudentsCertificates"),
|
||||
[],
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
api_get_path(WEB_CODE_PATH)."gradebook/certificate_report.php"
|
||||
);
|
||||
}
|
||||
|
||||
$content = '<div class="actions">';
|
||||
|
||||
if (!empty($actions)) {
|
||||
$content .= $actions;
|
||||
}
|
||||
|
||||
if (!api_is_student_boss()) {
|
||||
$content .= Display::url(
|
||||
get_lang("CompanyReport"),
|
||||
api_get_path(WEB_CODE_PATH)."mySpace/company_reports.php",
|
||||
[
|
||||
'class' => 'btn btn-success',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$content .= '</div>';
|
||||
$content .= '<h1 class="page-header">'.get_lang('CompanyReportResumed').'</h1>';
|
||||
$content .= Display::grid_html('user_course_report');
|
||||
|
||||
$tpl = new Template($tool_name);
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->display_one_col_template();
|
||||
398
main/mySpace/course.php
Normal file
398
main/mySpace/course.php
Normal file
@@ -0,0 +1,398 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* Courses reporting.
|
||||
*/
|
||||
ob_start();
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : null;
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
|
||||
|
||||
if (isset($_GET["id_session"]) && $_GET["id_session"] != "") {
|
||||
$interbreadcrumb[] = ["url" => "session.php", "name" => get_lang('Sessions')];
|
||||
}
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && isset($_GET["type"]) && $_GET["type"] == "coach") {
|
||||
$interbreadcrumb[] = ["url" => "coaches.php", "name" => get_lang('Tutors')];
|
||||
}
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && isset($_GET["type"]) && $_GET["type"] == "student") {
|
||||
$interbreadcrumb[] = ["url" => "student.php", "name" => get_lang('Students')];
|
||||
}
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
|
||||
$interbreadcrumb[] = ["url" => "teachers.php", "name" => get_lang('Teachers')];
|
||||
}
|
||||
|
||||
function count_courses()
|
||||
{
|
||||
global $nb_courses;
|
||||
|
||||
return $nb_courses;
|
||||
}
|
||||
|
||||
// Checking if the current coach is the admin coach
|
||||
$showImportIcon = false;
|
||||
if (api_get_setting('add_users_by_coach') == 'true') {
|
||||
if (!api_is_platform_admin()) {
|
||||
$isGeneralCoach = SessionManager::user_is_general_coach(
|
||||
api_get_user_id(),
|
||||
$sessionId
|
||||
);
|
||||
if ($isGeneralCoach) {
|
||||
$showImportIcon = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Display::display_header(get_lang('Courses'));
|
||||
$user_id = 0;
|
||||
$a_courses = [];
|
||||
$menu_items = [];
|
||||
if (api_is_platform_admin(true, true)) {
|
||||
$title = '';
|
||||
if (empty($sessionId)) {
|
||||
if (isset($_GET['user_id'])) {
|
||||
$user_id = intval($_GET['user_id']);
|
||||
$user_info = api_get_user_info($user_id);
|
||||
$title = get_lang('AssignedCoursesTo').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
|
||||
$courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
|
||||
} else {
|
||||
$title = get_lang('YourCourseList');
|
||||
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
|
||||
}
|
||||
} else {
|
||||
$session_name = api_get_session_name($sessionId);
|
||||
$title = $session_name.' : '.get_lang('CourseListInSession');
|
||||
$courses = Tracking::get_courses_list_from_session($sessionId);
|
||||
}
|
||||
|
||||
$a_courses = array_keys($courses);
|
||||
|
||||
if (!api_is_session_admin()) {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
"index.php?view=drh_students&display=yourstudents"
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('course_na.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/session.php'
|
||||
);
|
||||
|
||||
$menu_items[] = Display::url(
|
||||
get_lang('QuestionStats'),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global.php'
|
||||
);
|
||||
|
||||
$menu_items[] = Display::url(
|
||||
get_lang('QuestionStatsDetailedReport'),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/question_stats_global_detail.php'
|
||||
);
|
||||
|
||||
if (api_can_login_as($user_id)) {
|
||||
$link = '<a
|
||||
href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::get_existing_token().'">'.
|
||||
Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a> ';
|
||||
$menu_items[] = $link;
|
||||
}
|
||||
}
|
||||
|
||||
$actionsLeft = $actionsRight = '';
|
||||
$nb_menu_items = count($menu_items);
|
||||
if ($nb_menu_items > 1) {
|
||||
foreach ($menu_items as $key => $item) {
|
||||
$actionsLeft .= $item;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($a_courses) > 0) {
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), [], 32),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print();']
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar = Display::toolbarAction('toolbar-course', [$actionsLeft, $actionsRight]);
|
||||
echo $toolbar;
|
||||
echo Display::page_header($title);
|
||||
}
|
||||
|
||||
if ($showImportIcon) {
|
||||
echo "<div align=\"right\">";
|
||||
echo '<a href="user_import.php?id_session='.$sessionId.'&action=export&type=xml">'.
|
||||
Display::return_icon('excel.gif', get_lang('ImportUserListXMLCSV')).' '.get_lang('ImportUserListXMLCSV').'</a>';
|
||||
echo "</div><br />";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
function get_count_courses()
|
||||
{
|
||||
$userId = api_get_user_id();
|
||||
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : null;
|
||||
$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
|
||||
$drhLoaded = false;
|
||||
|
||||
if (api_is_drh()) {
|
||||
if (api_drh_can_access_all_session_content()) {
|
||||
if (empty($sessionId)) {
|
||||
$count = SessionManager::getAllCoursesFollowedByUser(
|
||||
$userId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
$keyword
|
||||
);
|
||||
} else {
|
||||
$count = SessionManager::getCourseCountBySessionId(
|
||||
$sessionId,
|
||||
$keyword
|
||||
);
|
||||
}
|
||||
$drhLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($drhLoaded == false) {
|
||||
$isGeneralCoach = SessionManager::user_is_general_coach(
|
||||
api_get_user_id(),
|
||||
$sessionId
|
||||
);
|
||||
|
||||
if ($isGeneralCoach) {
|
||||
$courseList = SessionManager::getCoursesInSession($sessionId);
|
||||
$count = count($courseList);
|
||||
} else {
|
||||
$count = CourseManager::getCoursesFollowedByUser(
|
||||
$userId,
|
||||
COURSEMANAGER,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
$keyword,
|
||||
$sessionId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $from
|
||||
* @param $limit
|
||||
* @param $column
|
||||
* @param $direction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_courses($from, $limit, $column, $direction)
|
||||
{
|
||||
$userId = api_get_user_id();
|
||||
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
|
||||
$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
|
||||
$follow = isset($_GET['follow']) ? true : false;
|
||||
$drhLoaded = false;
|
||||
if (api_is_drh()) {
|
||||
if (api_drh_can_access_all_session_content()) {
|
||||
$courses = SessionManager::getAllCoursesFollowedByUser(
|
||||
$userId,
|
||||
$sessionId,
|
||||
$from,
|
||||
$limit,
|
||||
$column,
|
||||
$direction,
|
||||
false,
|
||||
$keyword
|
||||
);
|
||||
$drhLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($drhLoaded == false) {
|
||||
$isGeneralCoach = SessionManager::user_is_general_coach(
|
||||
api_get_user_id(),
|
||||
$sessionId
|
||||
);
|
||||
|
||||
// General coach can see all reports
|
||||
if ($isGeneralCoach) {
|
||||
$courseList = SessionManager::getCoursesInSession($sessionId);
|
||||
$courses = [];
|
||||
if (!empty($courseList)) {
|
||||
foreach ($courseList as $courseId) {
|
||||
$courses[] = api_get_course_info_by_id($courseId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$courses = CourseManager::getCoursesFollowedByUser(
|
||||
$userId,
|
||||
COURSEMANAGER,
|
||||
$from,
|
||||
$limit,
|
||||
$column,
|
||||
$direction,
|
||||
false,
|
||||
$keyword,
|
||||
$sessionId,
|
||||
$follow
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$courseList = [];
|
||||
if (!empty($courses)) {
|
||||
foreach ($courses as $data) {
|
||||
$courseCode = $data['code'];
|
||||
$courseInfo = api_get_course_info($courseCode);
|
||||
if (empty($sessionId)) {
|
||||
$userList = CourseManager::get_user_list_from_course_code($data['code']);
|
||||
} else {
|
||||
$userList = CourseManager::get_user_list_from_course_code(
|
||||
$data['code'],
|
||||
$sessionId,
|
||||
null,
|
||||
null,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
$userIdList = [];
|
||||
if (!empty($userList)) {
|
||||
foreach ($userList as $user) {
|
||||
$userIdList[] = $user['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$messagesInCourse = 0;
|
||||
$assignmentsInCourse = 0;
|
||||
$avgTimeSpentInCourse = 0;
|
||||
$avgProgressInCourse = 0;
|
||||
$countStudents = 0;
|
||||
$avgScoreInCourse = 0;
|
||||
|
||||
if (count($userIdList) > 0) {
|
||||
$countStudents = count($userIdList);
|
||||
// tracking data
|
||||
$avgProgressInCourse = Tracking::get_avg_student_progress($userIdList, $courseCode, [], $sessionId);
|
||||
$avgScoreInCourse = Tracking::get_avg_student_score($userIdList, $courseCode, [], $sessionId);
|
||||
$avgTimeSpentInCourse = Tracking::get_time_spent_on_the_course($userIdList, $courseInfo['real_id'], $sessionId);
|
||||
$messagesInCourse = Tracking::count_student_messages($userIdList, $courseCode, $sessionId);
|
||||
$assignmentsInCourse = Tracking::count_student_assignments($userIdList, $courseCode, $sessionId);
|
||||
$avgTimeSpentInCourse = api_time_to_hms($avgTimeSpentInCourse / $countStudents);
|
||||
$avgProgressInCourse = round($avgProgressInCourse / $countStudents, 2);
|
||||
|
||||
if (is_numeric($avgScoreInCourse)) {
|
||||
$avgScoreInCourse = round($avgScoreInCourse / $countStudents, 2).'%';
|
||||
}
|
||||
}
|
||||
|
||||
$thematic = new Thematic();
|
||||
$tematic_advance = $thematic->get_total_average_of_thematic_advances($courseCode, $sessionId);
|
||||
$tematicAdvanceProgress = '-';
|
||||
if (!empty($tematic_advance)) {
|
||||
$tematicAdvanceProgress = '<a title="'.get_lang('GoToThematicAdvance').'" href="'.api_get_path(WEB_CODE_PATH).'course_progress/index.php?cidReq='.$courseCode.'&id_session='.$sessionId.'">'.
|
||||
$tematic_advance.'%</a>';
|
||||
}
|
||||
|
||||
$courseIcon = '<a href="'.api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?cidReq='.$courseCode.'&id_session='.$sessionId.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'
|
||||
</a>';
|
||||
$title = Display::url(
|
||||
$data['title'],
|
||||
$courseInfo['course_public_url'].'?id_session='.$sessionId
|
||||
);
|
||||
|
||||
$attendanceLink = Display::url(
|
||||
Display::return_icon('attendance_list.png', get_lang('Attendance'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCode.'&id_session='.$sessionId.'&action=calendar_logins'
|
||||
);
|
||||
|
||||
$courseList[] = [
|
||||
$title,
|
||||
$countStudents,
|
||||
is_null($avgTimeSpentInCourse) ? '-' : $avgTimeSpentInCourse,
|
||||
$tematicAdvanceProgress,
|
||||
is_null($avgProgressInCourse) ? '-' : $avgProgressInCourse.'%',
|
||||
is_null($avgScoreInCourse) ? '-' : $avgScoreInCourse,
|
||||
is_null($messagesInCourse) ? '-' : $messagesInCourse,
|
||||
is_null($assignmentsInCourse) ? '-' : $assignmentsInCourse,
|
||||
$attendanceLink,
|
||||
$courseIcon,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $courseList;
|
||||
}
|
||||
|
||||
$table = new SortableTable(
|
||||
'tracking_course',
|
||||
'get_count_courses',
|
||||
'get_courses',
|
||||
1,
|
||||
10
|
||||
);
|
||||
|
||||
$table->set_header(0, get_lang('CourseTitle'), false);
|
||||
$table->set_header(1, get_lang('NbStudents'), false);
|
||||
$table->set_header(2, get_lang('TimeSpentInTheCourse').Display::return_icon('info.png', get_lang('TimeOfActiveByTraining'), ['align' => 'absmiddle', 'hspace' => '3px']), false);
|
||||
$table->set_header(3, get_lang('ThematicAdvance'), false);
|
||||
$table->set_header(4, get_lang('AvgStudentsProgress').Display::return_icon('info.png', get_lang('AvgAllUsersInAllCourses'), ['align' => 'absmiddle', 'hspace' => '3px']), false);
|
||||
$table->set_header(5, get_lang('AvgCourseScore').Display::return_icon('info.png', get_lang('AvgAllUsersInAllCourses'), ['align' => 'absmiddle', 'hspace' => '3px']), false);
|
||||
$table->set_header(6, get_lang('AvgMessages'), false);
|
||||
$table->set_header(7, get_lang('AvgAssignments'), false);
|
||||
$table->set_header(8, get_lang('Attendances'), false);
|
||||
$table->set_header(9, get_lang('Details'), false);
|
||||
|
||||
$form = new FormValidator('search_course', 'get', api_get_path(WEB_CODE_PATH).'mySpace/course.php');
|
||||
$form->addElement('text', 'keyword', get_lang('Keyword'));
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
$form->addElement('hidden', 'session_id', $sessionId);
|
||||
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
|
||||
$params = [
|
||||
'session_id' => $sessionId,
|
||||
'keyword' => $keyword,
|
||||
];
|
||||
$table->set_additional_parameters($params);
|
||||
|
||||
$form->setDefaults($params);
|
||||
$form->display();
|
||||
$table->display();
|
||||
|
||||
Display::display_footer();
|
||||
278
main/mySpace/current_courses.php
Normal file
278
main/mySpace/current_courses.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* Report for current courses followed by the user.
|
||||
*/
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$filename = 'reporting.xlsx';
|
||||
|
||||
if (!api_is_allowed_to_create_course()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$user_id = api_get_user_id();
|
||||
$my_courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
|
||||
$array = [];
|
||||
|
||||
$i = 0;
|
||||
$session_id = 0;
|
||||
|
||||
if (!empty($my_courses)) {
|
||||
foreach ($my_courses as $course) {
|
||||
$course_code = $course['code'];
|
||||
$course_id = $course['real_id'];
|
||||
$course_info = api_get_course_info($course_code);
|
||||
|
||||
//Only show open courses
|
||||
if ($course_info['visibility'] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$teachers = CourseManager::get_teacher_list_from_course_code($course_code);
|
||||
$teacher_list = [];
|
||||
|
||||
if (!empty($teachers)) {
|
||||
foreach ($teachers as $teacher) {
|
||||
$teacher_list[] = $teacher['firstname'].' '.$teacher['lastname'];
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_students = CourseManager::get_student_list_from_course_code($course_code, false);
|
||||
|
||||
//Cleaning students only REAL students
|
||||
$students = [];
|
||||
foreach ($tmp_students as $student) {
|
||||
$user_info = api_get_user_info($student['user_id']);
|
||||
if ($user_info['status'] != STUDENT) {
|
||||
continue;
|
||||
}
|
||||
$students[] = $student['user_id'];
|
||||
}
|
||||
|
||||
$t_lp = Database::get_course_table(TABLE_LP_MAIN);
|
||||
$sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp
|
||||
WHERE c_id = $course_id AND lp.session_id = 0";
|
||||
$rs_lp = Database::query($sql_lp);
|
||||
$t_lpi = Database::get_course_table(TABLE_LP_ITEM);
|
||||
$t_news = Database::get_course_table(TABLE_ANNOUNCEMENT);
|
||||
|
||||
$total_tools_list = Tracking::get_tools_most_used_by_course(
|
||||
$course_id,
|
||||
$session_id
|
||||
);
|
||||
|
||||
$total_tools = 0;
|
||||
foreach ($total_tools_list as $tool) {
|
||||
$total_tools += $tool['count_access_tool'];
|
||||
}
|
||||
|
||||
if (Database::num_rows($rs_lp) > 0) {
|
||||
while ($learnpath = Database::fetch_array($rs_lp)) {
|
||||
$lp_id = $learnpath['id'];
|
||||
|
||||
$lp_items =
|
||||
$array[$i]['lp'] = '<a href="'.api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?cidReq='.$course_code.'&action=view&lp_id='.$lp_id.'" target="_blank">'.$learnpath['name'].'</a>';
|
||||
|
||||
$array[$i]['teachers'] = '';
|
||||
if (!empty($teacher_list)) {
|
||||
$array[$i]['teachers'] = implode(', ', $teacher_list);
|
||||
}
|
||||
|
||||
$array[$i]['course_name'] = $course['title'];
|
||||
$count_students_accessing = 0;
|
||||
$count_students_complete_all_activities = 0;
|
||||
$count_students_complete_all_activities_at_50 = 0;
|
||||
$total_time_spent = 0;
|
||||
$total_average_progress = 0;
|
||||
|
||||
if (!empty($students)) {
|
||||
foreach ($students as $student_id) {
|
||||
$avg_student_progress = Tracking::get_avg_student_progress($student_id, $course_code, [$lp_id], $session_id);
|
||||
$myavg_temp = Tracking::get_avg_student_score($student_id, $course_code, [$lp_id], $session_id);
|
||||
$avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, [$lp_id], $session_id);
|
||||
|
||||
if (intval($avg_progress_in_course) == 100) {
|
||||
$count_students_complete_all_activities++;
|
||||
}
|
||||
if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) {
|
||||
$count_students_complete_all_activities_at_50++;
|
||||
}
|
||||
$total_average_progress += $avg_progress_in_course;
|
||||
|
||||
$time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_id, $session_id);
|
||||
$total_time_spent += $time_spent;
|
||||
if (!empty($time_spent)) {
|
||||
$count_students_accessing++;
|
||||
}
|
||||
}
|
||||
//$total_tools += $nb_assignments + $messages + $links + $chat_last_connection + $documents;
|
||||
}
|
||||
|
||||
$student_count = count($students);
|
||||
|
||||
$array[$i]['count_students'] = $student_count;
|
||||
$array[$i]['count_students_accessing'] = 0;
|
||||
$array[$i]['count_students_accessing_percentage'] = 0;
|
||||
$array[$i]['count_students_complete_all_activities_at_50'] = 0;
|
||||
$array[$i]['count_students_complete_all_activities'] = 0;
|
||||
$array[$i]['average_percentage_activities_completed_per_student'] = 0;
|
||||
$array[$i]['total_time_spent'] = 0;
|
||||
$array[$i]['average_time_spent_per_student'] = 0;
|
||||
$array[$i]['total_time_spent'] = 0;
|
||||
$array[$i]['average_time_spent_per_student'] = 0;
|
||||
//$array[$i]['tools_used'] = 0;
|
||||
$array[$i]['learnpath_docs'] = 0;
|
||||
$array[$i]['learnpath_exercises'] = 0;
|
||||
$array[$i]['learnpath_links'] = 0;
|
||||
$array[$i]['learnpath_forums'] = 0;
|
||||
$array[$i]['learnpath_assignments'] = 0;
|
||||
|
||||
//registering the number of each category of
|
||||
//items in learning path
|
||||
$sql_lpi = "SELECT lpi.item_type FROM $t_lpi lpi
|
||||
WHERE c_id = $course_id AND lpi.lp_id = $lp_id
|
||||
ORDER BY item_type";
|
||||
$res_lpi = Database::query($sql_lpi);
|
||||
while ($row_lpi = Database::fetch_array($res_lpi)) {
|
||||
switch ($row_lpi['item_type']) {
|
||||
case 'document':
|
||||
$array[$i]['learnpath_docs']++;
|
||||
break;
|
||||
case 'quiz':
|
||||
$array[$i]['learnpath_exercises']++;
|
||||
break;
|
||||
case 'link':
|
||||
$array[$i]['learnpath_links']++;
|
||||
break;
|
||||
case 'forum':
|
||||
case 'thread':
|
||||
$array[$i]['learnpath_forums']++;
|
||||
break;
|
||||
case 'student_publication':
|
||||
$array[$i]['learnpath_assignments']++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Count announcements
|
||||
$array[$i]['total_announcements'] = 0;
|
||||
$sql_news = "SELECT count(id) FROM $t_news WHERE c_id = $course_id ";
|
||||
$res_news = Database::query($sql_news);
|
||||
while ($row_news = Database::fetch_array($res_news)) {
|
||||
$array[$i]['total_announcements'] = $row_news[0];
|
||||
}
|
||||
|
||||
//@todo don't know what means this value
|
||||
$count_students_complete_all_activities_at_50 = 0;
|
||||
|
||||
if (!empty($student_count)) {
|
||||
$array[$i]['count_students_accessing'] = $count_students_accessing;
|
||||
$array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count * 100, 0);
|
||||
$array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities;
|
||||
$array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count * 100, 0);
|
||||
|
||||
$array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities / $student_count * 100, 2);
|
||||
$array[$i]['total_time_spent'] = 0;
|
||||
$array[$i]['average_time_spent_per_student'] = 0;
|
||||
|
||||
if (!empty($total_time_spent)) {
|
||||
$array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
|
||||
$array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
|
||||
}
|
||||
//$array[$i]['tools_used'] = $total_tools;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$headers = [
|
||||
get_lang('LearningPath'),
|
||||
get_lang('Teachers'),
|
||||
get_lang('Courses'),
|
||||
get_lang('NumberOfStudents'),
|
||||
get_lang('NumberStudentsAccessingCourse'),
|
||||
get_lang('PercentageStudentsAccessingCourse'),
|
||||
get_lang('NumberStudentsCompleteAllActivities'),
|
||||
get_lang('PercentageStudentsCompleteAllActivities'),
|
||||
get_lang('AverageOfActivitiesCompletedPerStudent'),
|
||||
get_lang('TotalTimeSpentInTheCourse'),
|
||||
get_lang('AverageTimePerStudentInCourse'),
|
||||
get_lang('NumberOfDocumentsInLearnpath'),
|
||||
get_lang('NumberOfExercisesInLearnpath'),
|
||||
get_lang('NumberOfLinksInLearnpath'),
|
||||
get_lang('NumberOfForumsInLearnpath'),
|
||||
get_lang('NumberOfAssignmentsInLearnpath'),
|
||||
get_lang('NumberOfAnnouncementsInCourse'),
|
||||
];
|
||||
|
||||
if (isset($_GET['export'])) {
|
||||
global $charset;
|
||||
$spreadsheet = new PHPExcel();
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
$line = 0;
|
||||
$column = 0; //skip the first column (row titles)
|
||||
|
||||
foreach ($headers as $header) {
|
||||
$worksheet->setCellValueByColumnAndRow($column, $line, $header);
|
||||
$column++;
|
||||
}
|
||||
$line++;
|
||||
foreach ($array as $row) {
|
||||
$column = 0;
|
||||
foreach ($row as $item) {
|
||||
$worksheet->setCellValueByColumnAndRow(
|
||||
$column,
|
||||
$line,
|
||||
html_entity_decode(strip_tags($item))
|
||||
);
|
||||
$column++;
|
||||
}
|
||||
$line++;
|
||||
}
|
||||
$line++;
|
||||
|
||||
$file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
|
||||
$writer = new PHPExcel_Writer_Excel2007($spreadsheet);
|
||||
$writer->save($file);
|
||||
DocumentManager::file_send_for_download($file, true, $filename);
|
||||
exit;
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
Display::display_header(get_lang('CurrentCourses'));
|
||||
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$row++;
|
||||
|
||||
foreach ($array as $row_table) {
|
||||
$column = 0;
|
||||
foreach ($row_table as $cell) {
|
||||
$table->setCellContents($row, $column, $cell);
|
||||
//$table->updateCellAttributes($row, $column, 'align="center"');
|
||||
$column++;
|
||||
}
|
||||
$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
|
||||
$row++;
|
||||
}
|
||||
|
||||
echo '<div class="actions">';
|
||||
echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace">'.Display::return_icon('back.png', get_lang('Back'), [], 32).'</a>';
|
||||
echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php?export=1">'.Display::return_icon('export_excel.png', get_lang('CurrentCoursesReport'), [], 32).'</a> ';
|
||||
echo '</div>';
|
||||
echo '<div style="overflow:auto;">';
|
||||
echo $table->toHtml();
|
||||
echo '</div>';
|
||||
|
||||
Display::display_footer();
|
||||
292
main/mySpace/exercise_category_report.php
Normal file
292
main/mySpace/exercise_category_report.php
Normal file
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_protect_admin_script();
|
||||
|
||||
$exportCSV = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false;
|
||||
|
||||
// the section (for the tabs)
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$csv_content = [];
|
||||
$nameTools = get_lang('MySpace');
|
||||
|
||||
$is_platform_admin = api_is_platform_admin();
|
||||
$is_drh = api_is_drh();
|
||||
$is_session_admin = api_is_session_admin();
|
||||
|
||||
$currentUrl = api_get_self();
|
||||
$courseId = isset($_GET['course_id']) ? (int) $_GET['course_id'] : 0;
|
||||
$defaults = [];
|
||||
$defaults['start_date'] = isset($_GET['start_date']) ? Security::remove_XSS($_GET['start_date']) : '';
|
||||
$defaults['course_id'] = $courseId;
|
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$htmlHeadXtra[] = '<script>
|
||||
$(function() {
|
||||
$("#exercise_course_id").on("change", function(e) {
|
||||
var data = $(this).select2(\'data\');
|
||||
var option = data[0];
|
||||
//Then I take the values like if I work with an array
|
||||
var value = option.id;
|
||||
var selectedDate = $("#start_date").datepicker({ dateFormat: \'dd,MM,yyyy\' }).val();
|
||||
window.location.replace("'.$currentUrl.'?start_date="+selectedDate+"&course_id="+value);
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
$form = new FormValidator('exercise', 'get');
|
||||
$form->addDatePicker('start_date', get_lang('StartDate'));
|
||||
if (empty($courseId)) {
|
||||
$form->addSelectAjax(
|
||||
'course_id',
|
||||
get_lang('Course'),
|
||||
null,
|
||||
[
|
||||
'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$courseInfo = api_get_course_info_by_id($courseId);
|
||||
if (!empty($courseInfo)) {
|
||||
$form->addHidden('course_id', $courseId);
|
||||
$courseLabel = Display::url(
|
||||
$courseInfo['name'].' ('.$courseInfo['code'].')',
|
||||
$courseInfo['course_public_url'],
|
||||
['target' => '_blank']
|
||||
);
|
||||
$form->addLabel(get_lang('Course'), $courseLabel);
|
||||
$exerciseList = ExerciseLib::get_all_exercises_for_course_id(
|
||||
$courseInfo,
|
||||
0,
|
||||
$courseId,
|
||||
true
|
||||
);
|
||||
|
||||
if (!empty($exerciseList)) {
|
||||
$options = [];
|
||||
foreach ($exerciseList as $exercise) {
|
||||
$options[$exercise['iid']] = $exercise['title'];
|
||||
}
|
||||
$form->addSelect('exercise_id', get_lang('Exercises'), $options);
|
||||
} else {
|
||||
$form->addLabel(get_lang('Exercises'), Display::return_message(get_lang('NoExercises')));
|
||||
}
|
||||
} else {
|
||||
Display::addFlash(Display::return_message(get_lang('CourseDoesNotExist'), 'warning'));
|
||||
}
|
||||
}
|
||||
|
||||
$form->setDefaults($defaults);
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
|
||||
Display::display_header($nameTools);
|
||||
$form->display();
|
||||
|
||||
$extraFields = api_get_configuration_value('exercise_category_report_user_extra_fields');
|
||||
|
||||
if ($form->validate() && !empty($courseInfo)) {
|
||||
$values = $form->getSubmitValues();
|
||||
$exerciseId = isset($values['exercise_id']) ? $values['exercise_id'] : 0;
|
||||
$startDate = Security::remove_XSS($values['start_date']);
|
||||
$exportFilename = 'exercise_results_report_'.$exerciseId.'_'.$courseInfo['code'];
|
||||
$url = api_get_path(WEB_AJAX_PATH).
|
||||
'model.ajax.php?a=get_exercise_results_report&exercise_id='.$exerciseId.
|
||||
'&start_date='.$startDate.'&cidReq='.$courseInfo['code'].
|
||||
'&course_id='.$courseId.
|
||||
'&export_filename='.$exportFilename;
|
||||
|
||||
$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
|
||||
$columns = [
|
||||
get_lang('FirstName'),
|
||||
get_lang('LastName'),
|
||||
get_lang('LoginName'),
|
||||
];
|
||||
|
||||
if (!empty($extraFields) && isset($extraFields['fields'])) {
|
||||
$extraField = new ExtraField('user');
|
||||
foreach ($extraFields['fields'] as $variable) {
|
||||
$info = $extraField->get_handler_field_info_by_field_variable($variable);
|
||||
if ($info) {
|
||||
$columns[] = $info['display_text'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$columns[] = get_lang('Session');
|
||||
$columns[] = get_lang('SessionStartDate');
|
||||
$columns[] = get_lang('StartDate');
|
||||
$columns[] = get_lang('Score');
|
||||
|
||||
if (!empty($categoryList)) {
|
||||
foreach ($categoryList as $categoryInfo) {
|
||||
$columns[] = $categoryInfo['title'];
|
||||
}
|
||||
}
|
||||
$columns[] = get_lang('Actions');
|
||||
|
||||
$columnModel = [
|
||||
['name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'true'],
|
||||
[
|
||||
'name' => 'lastname',
|
||||
'index' => 'lastname',
|
||||
'width' => '50',
|
||||
'align' => 'left',
|
||||
'formatter' => 'action_formatter',
|
||||
'search' => 'true',
|
||||
],
|
||||
[
|
||||
'name' => 'login',
|
||||
'index' => 'username',
|
||||
'width' => '40',
|
||||
'align' => 'left',
|
||||
'search' => 'true',
|
||||
'hidden' => 'true',
|
||||
],
|
||||
];
|
||||
|
||||
if (!empty($extraFields) && isset($extraFields['fields'])) {
|
||||
$extraField = new ExtraField('user');
|
||||
foreach ($extraFields['fields'] as $variable) {
|
||||
$columnModel[] = [
|
||||
'name' => $variable,
|
||||
'index' => $variable,
|
||||
'width' => '40',
|
||||
'align' => 'left',
|
||||
'search' => 'false',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$columnModel[] = [
|
||||
'name' => 'session',
|
||||
'index' => 'session',
|
||||
'width' => '40',
|
||||
'align' => 'left',
|
||||
'search' => 'false',
|
||||
];
|
||||
$columnModel[] = [
|
||||
'name' => 'session_access_start_date',
|
||||
'index' => 'session_access_start_date',
|
||||
'width' => '50',
|
||||
'align' => 'center',
|
||||
'search' => 'true',
|
||||
];
|
||||
$columnModel[] = [
|
||||
'name' => 'exe_date',
|
||||
'index' => 'exe_date',
|
||||
'width' => '60',
|
||||
'align' => 'left',
|
||||
'search' => 'true',
|
||||
];
|
||||
$columnModel[] = [
|
||||
'name' => 'score',
|
||||
'index' => 'exe_result',
|
||||
'width' => '50',
|
||||
'align' => 'center',
|
||||
'search' => 'true',
|
||||
];
|
||||
|
||||
if (!empty($categoryList)) {
|
||||
foreach ($categoryList as $categoryInfo) {
|
||||
$columnModel[] = [
|
||||
'name' => 'category_'.$categoryInfo['id'],
|
||||
'index' => 'category_'.$categoryInfo['id'],
|
||||
'width' => '50',
|
||||
'align' => 'center',
|
||||
'search' => 'true',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$columnModel[] = [
|
||||
'name' => 'actions',
|
||||
'index' => 'actions',
|
||||
'width' => '60',
|
||||
'align' => 'left',
|
||||
'search' => 'false',
|
||||
'sortable' => 'false',
|
||||
'hidden' => 'true',
|
||||
];
|
||||
|
||||
$extra_params['autowidth'] = 'true';
|
||||
|
||||
//height auto
|
||||
$extra_params['height'] = 'auto';
|
||||
$actionLinks = '
|
||||
// add username as title in lastname filed - ref 4226
|
||||
function action_formatter(cellvalue, options, rowObject) {
|
||||
// rowObject is firstname,lastname,login,... get the third word
|
||||
var loginx = "'.api_htmlentities(sprintf(get_lang("LoginX"), ":::"), ENT_QUOTES).'";
|
||||
var tabLoginx = loginx.split(/:::/);
|
||||
// tabLoginx[0] is before and tabLoginx[1] is after :::
|
||||
// may be empty string but is defined
|
||||
return "<span title=\""+tabLoginx[0]+rowObject[2]+tabLoginx[1]+"\">"+cellvalue+"</span>";
|
||||
}';
|
||||
$tableId = 'results'; ?>
|
||||
<script>
|
||||
$(function() {
|
||||
<?php
|
||||
echo Display::grid_js(
|
||||
'results',
|
||||
$url,
|
||||
$columns,
|
||||
$columnModel,
|
||||
$extra_params,
|
||||
[],
|
||||
$actionLinks,
|
||||
true
|
||||
); ?>
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
||||
echo '<script>
|
||||
$(function() {
|
||||
var myUrl = jQuery("#'.$tableId.'").jqGrid(\'getGridParam\', \'url\');
|
||||
myUrl += "&export_format=xls&oper=excel";
|
||||
var postData = jQuery("#'.$tableId.'").jqGrid(\'getGridParam\', \'postData\');
|
||||
$.each(postData, function(key, value) {
|
||||
myUrl += "&"+key+"="+encodeURIComponent(value);
|
||||
});
|
||||
|
||||
$("#excel_export").attr("href", myUrl);
|
||||
|
||||
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').'",
|
||||
onClickButton : function() {
|
||||
jQuery("#'.$tableId.'").jqGrid(
|
||||
"excelExport",{
|
||||
"url":"'.$url.'&export_format=xls"
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
$items = [
|
||||
[
|
||||
'url' => ' ',
|
||||
'url_attributes' => ['id' => 'excel_export'],
|
||||
'content' => Display::return_icon('export_excel.png', get_lang('ExportExcel')),
|
||||
],
|
||||
];
|
||||
|
||||
echo Display::actions($items);
|
||||
echo Display::grid_html('results');
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
410
main/mySpace/index.php
Normal file
410
main/mySpace/index.php
Normal file
@@ -0,0 +1,410 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Homepage for the MySpace directory.
|
||||
*/
|
||||
|
||||
// resetting the course id
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery.easy-pie-chart/dist/jquery.easypiechart.js"></script>';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
ob_start();
|
||||
$nameTools = get_lang('MySpace');
|
||||
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false;
|
||||
$display = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
|
||||
$csv_content = [];
|
||||
$user_id = api_get_user_id();
|
||||
$session_id = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
|
||||
$is_coach = api_is_coach($session_id);
|
||||
$is_platform_admin = api_is_platform_admin();
|
||||
$is_drh = api_is_drh();
|
||||
$is_session_admin = api_is_session_admin();
|
||||
$skipData = api_get_configuration_value('tracking_skip_generic_data');
|
||||
|
||||
$logInfo = [
|
||||
'tool' => SECTION_TRACKING,
|
||||
];
|
||||
Event::registerLog($logInfo);
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if ($is_session_admin) {
|
||||
header('location:session.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get views
|
||||
$views = ['admin', 'teacher', 'coach', 'drh'];
|
||||
$view = 'teacher';
|
||||
if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
|
||||
$view = $_GET['view'];
|
||||
}
|
||||
|
||||
$menu_items = [];
|
||||
$pluginCalendar = api_get_plugin_setting('learning_calendar', 'enabled') === 'true';
|
||||
$calendarMenuAdded = false;
|
||||
|
||||
if ($is_platform_admin) {
|
||||
if ($view === 'admin') {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('TeacherInterface'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?view=teacher'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('star_na.png', get_lang('AdminInterface'), [], 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'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'tracking/exams.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('session.png', get_lang('SessionFilterReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/session_filter.php'
|
||||
);
|
||||
} else {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon(
|
||||
'teacher_na.png',
|
||||
get_lang('TeacherInterface'),
|
||||
[],
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
''
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('star.png', get_lang('AdminInterface'), [], 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'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'tracking/exams.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('session.png', get_lang('SessionFilterReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/session_filter.php'
|
||||
);
|
||||
|
||||
if ($pluginCalendar) {
|
||||
$lpCalendar = LearningCalendarPlugin::create();
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('agenda.png', $lpCalendar->get_lang('LearningCalendar'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_PLUGIN_PATH).'learning_calendar/start.php'
|
||||
);
|
||||
$calendarMenuAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_drh) {
|
||||
$view = 'drh';
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('user_na.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM),
|
||||
'course.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
'session.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('empty_evaluation.png', get_lang('CompanyReport'), [], ICON_SIZE_MEDIUM),
|
||||
'company_reports.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('evaluation_rate.png', get_lang('CompanyReportResumed'), [], ICON_SIZE_MEDIUM),
|
||||
'company_reports_resumed.php'
|
||||
);
|
||||
}
|
||||
|
||||
$actionsRight = '';
|
||||
$actionsLeft = '';
|
||||
if ($display === 'useroverview' || $display === 'sessionoverview' || $display === 'courseoverview') {
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon(
|
||||
'export_csv.png',
|
||||
get_lang('ExportAsCSV'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
api_get_self().'?display='.$display.'&export=csv&view='.$view
|
||||
);
|
||||
}
|
||||
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon(
|
||||
'printer.png',
|
||||
get_lang('Print'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print()']
|
||||
);
|
||||
|
||||
if (!empty($session_id) &&
|
||||
!in_array(
|
||||
$display,
|
||||
['accessoverview', 'lpprogressoverview', 'progressoverview', 'exerciseprogress', 'surveyoverview']
|
||||
)
|
||||
) {
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon(
|
||||
'back.png',
|
||||
get_lang('Back'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
'index.php'
|
||||
);
|
||||
if (!api_is_platform_admin()) {
|
||||
if (api_get_setting('add_users_by_coach') === 'true') {
|
||||
if ($is_coach) {
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon(
|
||||
'excel.png',
|
||||
get_lang('ImportUserList'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
'user_import.php?id_session='.$session_id.'&action=export&type=xml'
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Display::url(
|
||||
Display::return_icon(
|
||||
'excel.png',
|
||||
get_lang('ImportUserList'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
'user_import.php?id_session='.$session_id.'&action=export&type=xml'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon(
|
||||
'statistics.png',
|
||||
get_lang('MyStats'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
|
||||
);
|
||||
|
||||
if ($pluginCalendar && api_is_teacher() && $calendarMenuAdded === false) {
|
||||
$lpCalendar = LearningCalendarPlugin::create();
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('agenda.png', $lpCalendar->get_lang('LearningCalendar'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_PLUGIN_PATH).'learning_calendar/start.php'
|
||||
);
|
||||
}
|
||||
|
||||
if (api_is_platform_admin(true) || api_is_student_boss()) {
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon(
|
||||
"certificate_list.png",
|
||||
get_lang('GradebookSeeListOfStudentsCertificates'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
api_get_path(WEB_CODE_PATH).'gradebook/certificate_report.php'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Actions menu
|
||||
$nb_menu_items = count($menu_items);
|
||||
if (empty($session_id) ||
|
||||
in_array(
|
||||
$display,
|
||||
['accessoverview', 'lpprogressoverview', 'progressoverview', 'exerciseprogress', 'surveyoverview']
|
||||
)
|
||||
) {
|
||||
if ($nb_menu_items > 1) {
|
||||
foreach ($menu_items as $key => $item) {
|
||||
$actionsLeft .= $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$userId = api_get_user_id();
|
||||
$stats = Tracking::getStats($userId, true);
|
||||
|
||||
$numberStudents = $stats['student_count'];
|
||||
$students = $stats['student_list'];
|
||||
$numberStudentBosses = $stats['student_bosses'];
|
||||
$numberTeachers = $stats['teachers'];
|
||||
$countHumanResourcesUsers = $stats['drh'];
|
||||
$countAssignedCourses = $stats['assigned_courses'];
|
||||
$countCourses = $stats['courses'];
|
||||
$sessions = $stats['session_list'];
|
||||
|
||||
$sessionIdList = [];
|
||||
if (!empty($sessions)) {
|
||||
foreach ($sessions as $session) {
|
||||
$sessionIdList[] = $session['id'];
|
||||
}
|
||||
}
|
||||
|
||||
// Sessions for the user
|
||||
$countSessions = count($sessions);
|
||||
$total_time_spent = 0;
|
||||
$total_courses = 0;
|
||||
$avgTotalProgress = 0;
|
||||
$nb_inactive_students = 0;
|
||||
$numberAssignments = 0;
|
||||
$inactiveTime = time() - (3600 * 24 * 7);
|
||||
$daysAgo = 7;
|
||||
$studentIds = [];
|
||||
$avg_courses_per_student = 0;
|
||||
|
||||
$view = new Template($nameTools);
|
||||
$view->assign('students', $numberStudents);
|
||||
$view->assign('studentbosses', $numberStudentBosses);
|
||||
$view->assign('numberTeachers', $numberTeachers);
|
||||
$view->assign('humanresources', $countHumanResourcesUsers);
|
||||
$view->assign(
|
||||
'total_user',
|
||||
$numberStudents + $numberStudentBosses + $numberTeachers + $countHumanResourcesUsers
|
||||
);
|
||||
$view->assign('studentboss', STUDENT_BOSS);
|
||||
$view->assign('drh', DRH);
|
||||
$view->assign('stats', $stats);
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_user',
|
||||
'get',
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/student.php'
|
||||
);
|
||||
$form = Tracking::setUserSearchForm($form);
|
||||
|
||||
$totalTimeSpent = null;
|
||||
$averageScore = null;
|
||||
$posts = null;
|
||||
|
||||
if ($skipData === false) {
|
||||
$averageTimeSpentPerStudent = '00:00:00';
|
||||
|
||||
if (!empty($students)) {
|
||||
// Students
|
||||
$studentIds = array_values($students);
|
||||
$progress = Tracking::get_avg_student_progress($studentIds);
|
||||
$countAssignments = Tracking::count_student_assignments($studentIds);
|
||||
// average progress
|
||||
$avgTotalProgress = $progress / $numberStudents;
|
||||
// average assignments
|
||||
$numberAssignments = $countAssignments / $numberStudents;
|
||||
$avg_courses_per_student = $countCourses / $numberStudents;
|
||||
$totalTimeSpent = Tracking::get_time_spent_on_the_platform($studentIds, 'ever');
|
||||
$averageTimeSpentPerStudent = api_time_to_hms($totalTimeSpent / $numberStudents);
|
||||
$posts = Tracking::count_student_messages($studentIds);
|
||||
$averageScore = Tracking::getAverageStudentScore($studentIds);
|
||||
}
|
||||
|
||||
if ($export_csv) {
|
||||
//csv part
|
||||
$csv_content[] = [get_lang('Students')];
|
||||
$csv_content[] = [get_lang('InactivesStudents'), $nb_inactive_students];
|
||||
$csv_content[] = [get_lang('AverageTimeSpentOnThePlatform'), $averageTimeSpentPerStudent];
|
||||
$csv_content[] = [get_lang('AverageCoursePerStudent'), round($avg_courses_per_student, 3)];
|
||||
$csv_content[] = [
|
||||
get_lang('AverageProgressInLearnpath'),
|
||||
is_null($avgTotalProgress)
|
||||
? null
|
||||
: round($avgTotalProgress, 2).'%',
|
||||
];
|
||||
$csv_content[] = [
|
||||
get_lang('AverageResultsToTheExercices'),
|
||||
is_null($averageScore)
|
||||
? null
|
||||
: round($averageScore, 2).'%',
|
||||
];
|
||||
$csv_content[] = [get_lang('AveragePostsInForum'), $posts];
|
||||
$csv_content[] = [get_lang('AverageAssignments'), $numberAssignments];
|
||||
$csv_content[] = [];
|
||||
} else {
|
||||
$lastConnectionDate = api_get_utc_datetime(strtotime('15 days ago'));
|
||||
$countActiveUsers = SessionManager::getCountUserTracking(
|
||||
null,
|
||||
1,
|
||||
null,
|
||||
[],
|
||||
[]
|
||||
);
|
||||
$countSleepingTeachers = SessionManager::getTeacherTracking(
|
||||
api_get_user_id(),
|
||||
1,
|
||||
$lastConnectionDate,
|
||||
true,
|
||||
$sessionIdList
|
||||
);
|
||||
|
||||
$countSleepingStudents = SessionManager::getCountUserTracking(
|
||||
null,
|
||||
1,
|
||||
$lastConnectionDate,
|
||||
$sessionIdList,
|
||||
$studentIds
|
||||
);
|
||||
$report['AverageCoursePerStudent'] = is_null($avg_courses_per_student)
|
||||
? ''
|
||||
: round($avg_courses_per_student, 3);
|
||||
$report['InactivesStudents'] = $nb_inactive_students;
|
||||
$report['AverageTimeSpentOnThePlatform'] = $averageTimeSpentPerStudent;
|
||||
$report['AverageProgressInLearnpath'] = is_null($avgTotalProgress)
|
||||
? ''
|
||||
: round($avgTotalProgress, 2).'%';
|
||||
$report['AvgCourseScore'] = is_null($averageScore) ? '0' : round($averageScore, 2).'%';
|
||||
$report['AveragePostsInForum'] = is_null($posts) ? '0' : round($posts, 2);
|
||||
$report['AverageAssignments'] = is_null($numberAssignments) ? '' : round($numberAssignments, 2);
|
||||
$view->assign('report', $report);
|
||||
}
|
||||
}
|
||||
|
||||
$view->assign('header', $nameTools);
|
||||
$view->assign('form', $form->returnForm());
|
||||
$view->assign('actions', Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]));
|
||||
$view->assign('title', get_lang('Students').' ('.$numberStudents.')');
|
||||
|
||||
$template = $view->get_template('my_space/index.tpl');
|
||||
$content = $view->fetch($template);
|
||||
$view->assign('content', $content);
|
||||
$view->display_one_col_template();
|
||||
|
||||
// Send the csv file if asked
|
||||
if ($export_csv) {
|
||||
ob_end_clean();
|
||||
Export::arrayToCsv($csv_content, 'reporting_index');
|
||||
exit;
|
||||
}
|
||||
310
main/mySpace/lp_tracking.php
Normal file
310
main/mySpace/lp_tracking.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
|
||||
use Chamilo\CourseBundle\Entity\CLpItemView;
|
||||
|
||||
/**
|
||||
* Learning paths reporting.
|
||||
*/
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$cidReset = true;
|
||||
$from_myspace = false;
|
||||
$from_link = '';
|
||||
if (isset($_GET['from']) && 'myspace' == $_GET['from']) {
|
||||
$from_link = '&from=myspace';
|
||||
$this_section = SECTION_TRACKING;
|
||||
} else {
|
||||
$this_section = SECTION_COURSES;
|
||||
}
|
||||
|
||||
$session_id = isset($_REQUEST['id_session']) ? (int) $_REQUEST['id_session'] : api_get_session_id();
|
||||
$export_csv = isset($_GET['export']) && 'csv' == $_GET['export'];
|
||||
$user_id = isset($_GET['student_id']) ? (int) $_GET['student_id'] : api_get_user_id();
|
||||
$courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : api_get_course_id();
|
||||
$origin = api_get_origin();
|
||||
$lp_id = (int) $_GET['lp_id'];
|
||||
$csv_content = [];
|
||||
$courseInfo = api_get_course_info($courseCode);
|
||||
|
||||
if (empty($courseInfo) || empty($lp_id)) {
|
||||
api_not_allowed('learnpath' !== api_get_origin());
|
||||
}
|
||||
$userInfo = api_get_user_info($user_id);
|
||||
$name = $userInfo['complete_name'];
|
||||
$isBoss = UserManager::userIsBossOfStudent(api_get_user_id(), $user_id);
|
||||
|
||||
if (!$isBoss &&
|
||||
!api_is_platform_admin(true) &&
|
||||
!api_is_drh() &&
|
||||
!api_is_course_tutor() &&
|
||||
!CourseManager::is_course_teacher(api_get_user_id(), $courseCode) &&
|
||||
!Tracking::is_allowed_to_coach_student(api_get_user_id(), $user_id)
|
||||
) {
|
||||
api_not_allowed(api_get_origin() !== 'learnpath');
|
||||
}
|
||||
|
||||
if ('user_course' === $origin) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_COURSE_PATH).$courseInfo['directory'],
|
||||
'name' => $courseInfo['name'],
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => "../user/user.php?cidReq=$courseCode",
|
||||
'name' => get_lang('Users'),
|
||||
];
|
||||
} elseif ($origin === 'tracking_course') {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => "../tracking/courseLog.php?cidReq=$courseCode&id_session=$session_id",
|
||||
'name' => get_lang('Tracking'),
|
||||
];
|
||||
} else {
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
$interbreadcrumb[] = ['url' => 'student.php', 'name' => get_lang('MyStudents')];
|
||||
$interbreadcrumb[] = ['url' => "myStudents.php?student=$user_id", 'name' => get_lang('StudentDetails')];
|
||||
$nameTools = get_lang('DetailsStudentInCourse');
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
'url' => "myStudents.php?student=$user_id&course=$courseCode&details=true&origin=$origin",
|
||||
'name' => get_lang('DetailsStudentInCourse'),
|
||||
];
|
||||
$nameTools = get_lang('LearningPathDetails');
|
||||
$sql = 'SELECT name FROM '.Database::get_course_table(TABLE_LP_MAIN).'
|
||||
WHERE c_id = '.$courseInfo['real_id'].' AND id='.$lp_id;
|
||||
$rs = Database::query($sql);
|
||||
$lp_title = Database::result($rs, 0, 0);
|
||||
|
||||
$origin = 'tracking';
|
||||
|
||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
||||
switch ($action) {
|
||||
case 'export_stats':
|
||||
if (!api_is_allowed_to_edit(false, false, true)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
$tpl = new Template(null, false, false);
|
||||
$itemId = isset($_REQUEST['extend_id']) ? $_REQUEST['extend_id'] : 0;
|
||||
$itemViewId = isset($_REQUEST['extend_attempt_id']) ? $_REQUEST['extend_attempt_id'] : 0;
|
||||
$em = Database::getManager();
|
||||
|
||||
$repo = $em->getRepository('ChamiloCourseBundle:CLpItemView');
|
||||
/** @var CLpItemView $itemView */
|
||||
$itemView = $repo->find($itemViewId);
|
||||
|
||||
if (!$itemView) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$view = $em->getRepository('ChamiloCourseBundle:CLpView')->find($itemView->getLpViewId());
|
||||
$lp = $em->getRepository('ChamiloCourseBundle:CLp')->find($view->getLpId());
|
||||
|
||||
$duration = learnpathItem::getScormTimeFromParameter('js', $itemView->getTotalTime());
|
||||
$endTime = $itemView->getStartTime() + $itemView->getTotalTime();
|
||||
|
||||
$list1 = learnpath::get_iv_interactions_array($itemViewId, $courseInfo['real_id']);
|
||||
$counter = 0;
|
||||
$table = new HTML_Table();
|
||||
|
||||
$total = 0;
|
||||
$numberChoices = 0;
|
||||
$questionCounter = 0;
|
||||
|
||||
$studentName = '';
|
||||
$questions = [];
|
||||
$categories = [];
|
||||
foreach ($list1 as $id => $interaction) {
|
||||
$counter++;
|
||||
if ($counter === 1) {
|
||||
continue;
|
||||
} elseif ($counter === 2) {
|
||||
$studentName = $interaction['student_response_formatted'];
|
||||
} else {
|
||||
$data = $interaction['student_response_formatted'];
|
||||
|
||||
switch ($interaction['type']) {
|
||||
case 'fill-in':
|
||||
$questionCounter++;
|
||||
$questions[$questionCounter]['question'] = $data;
|
||||
break;
|
||||
case 'choice':
|
||||
$questions[$questionCounter]['options'][] = $interaction;
|
||||
$numberChoices++;
|
||||
break;
|
||||
case 'matching':
|
||||
$list = explode(',', $data);
|
||||
if (!empty($list)) {
|
||||
foreach ($list as &$item) {
|
||||
$item = cut($item, 30);
|
||||
}
|
||||
$interaction['student_response_formatted'] = implode('<br />', $list);
|
||||
}
|
||||
$questions[$questionCounter]['options'][] = $interaction;
|
||||
$numberChoices++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$counter = 1;
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$row = 0;
|
||||
$scoreDisplay = new ScoreDisplay();
|
||||
$globalTotal = 0;
|
||||
$globalTotalCount = 0;
|
||||
foreach ($questions as $data) {
|
||||
// Question title
|
||||
$table->setCellContents($row, 0, $data['question']);
|
||||
$table->setCellAttributes($row, 0, ['colspan' => '3', 'style' => 'text-align:center; font-weight:bold']);
|
||||
$choiceCounter = 1;
|
||||
$row++;
|
||||
$total = 0;
|
||||
// Question options
|
||||
foreach ($data['options'] as $option) {
|
||||
if ($option['result'] === 'correct') {
|
||||
$total++;
|
||||
$globalTotal++;
|
||||
}
|
||||
$table->setCellContents($row, 0, 'Q'.$choiceCounter);
|
||||
$table->setCellContents($row, 1, $option['student_response_formatted']);
|
||||
$result = Display::return_icon('icon_check.png', null, [], ICON_SIZE_SMALL);
|
||||
if ($option['result'] === 'wrong') {
|
||||
$result = Display::return_icon('icon_error.png', null, [], ICON_SIZE_SMALL);
|
||||
}
|
||||
|
||||
$table->setCellContents($row, 2, $result);
|
||||
$choiceCounter++;
|
||||
$row++;
|
||||
}
|
||||
|
||||
// Question total
|
||||
$table->setCellContents($row, 0, get_lang('Total'));
|
||||
$table->setCellContents($row, 1, $data['question']);
|
||||
|
||||
$totalOptions = count($data['options']);
|
||||
$arrayScore = [0 => $total, 1 => $totalOptions];
|
||||
$scoreToString = $scoreDisplay->display_score($arrayScore);
|
||||
$table->setCellContents($row, 2, $scoreToString);
|
||||
|
||||
$table->setCellAttributes($row, 0, ['style' => 'font-weight:bold']);
|
||||
$table->setCellAttributes($row, 1, ['style' => 'font-weight:bold']);
|
||||
$table->setCellAttributes($row, 2, ['style' => 'font-weight:bold']);
|
||||
|
||||
$categories[] = [
|
||||
'name' => $data['question'],
|
||||
'score' => $scoreDisplay->display_score($arrayScore, SCORE_DIV),
|
||||
'score_numeric' => $scoreDisplay->display_score($arrayScore, SCORE_NUMERIC),
|
||||
'score_percentage' => $scoreDisplay->display_score($arrayScore, SCORE_PERCENT),
|
||||
];
|
||||
$tpl->assign('categories', $categories);
|
||||
|
||||
$globalTotalCount += $totalOptions;
|
||||
$row++;
|
||||
}
|
||||
|
||||
$globalScoreTotal = [0 => $globalTotal, 1 => $globalTotalCount];
|
||||
$score = $scoreDisplay->display_score($globalScoreTotal);
|
||||
$generalScore[] = [
|
||||
'score' => $scoreDisplay->display_score($globalScoreTotal, SCORE_DIV),
|
||||
'score_numeric' => $scoreDisplay->display_score($globalScoreTotal, SCORE_NUMERIC),
|
||||
'score_percentage' => $scoreDisplay->display_score($globalScoreTotal, SCORE_PERCENT),
|
||||
];
|
||||
$tpl->assign('general_score', $generalScore);
|
||||
$tpl->assign('global_total', $score);
|
||||
|
||||
$tableToString = $table->toHtml();
|
||||
|
||||
$duration = learnpathItem::getScormTimeFromParameter('js', $itemView->getTotalTime());
|
||||
|
||||
$dataLpInfo = [
|
||||
'name' => $lp->getName(),
|
||||
'attempt' => $itemView->getViewCount(),
|
||||
'score' => $score,
|
||||
'duration' => $duration,
|
||||
'start_time' => api_get_local_time($itemView->getStartTime()),
|
||||
'start_date' => api_get_local_time($itemView->getStartTime(), null, null, null, false),
|
||||
'end_time' => api_get_local_time($endTime),
|
||||
'candidate' => $studentName,
|
||||
];
|
||||
|
||||
$tpl->assign('data', $dataLpInfo);
|
||||
$contentText = $tpl->fetch($tpl->get_template('my_space/pdf_tracking_lp.tpl'));
|
||||
|
||||
$content = $contentText.'<pagebreak>'.$tableToString;
|
||||
|
||||
$pdf = new PDF('A4', 'P', ['margin_footer' => 4, 'top' => 40, 'bottom' => 25]);
|
||||
|
||||
$table = new HTML_Table(['class' => 'table', 'style' => 'display: block; margin-bottom: 50px;']);
|
||||
$logo = ChamiloApi::getPlatformLogo(
|
||||
api_get_visual_theme(),
|
||||
[
|
||||
'title' => '',
|
||||
'style' => 'max-width:180px, margin-bottom: 100px;',
|
||||
'id' => 'header-logo',
|
||||
]
|
||||
);
|
||||
$table->setCellContents(0, 0, $logo);
|
||||
|
||||
$addLogo = (isset($_GET['add_logo']) && (int) $_GET['add_logo'] === 1);
|
||||
if ($addLogo) {
|
||||
$secondLogo = api_get_path(SYS_PATH).'custompages/url-images/'.api_get_current_access_url_id().'_url_image_2.png';
|
||||
$logo2 = Display::img($secondLogo, null, ['style' => 'height:70px;']);
|
||||
$table->setCellContents(0, 1, $logo2);
|
||||
}
|
||||
|
||||
$table->setCellAttributes(0, 1, ['style' => 'display:block;float:right;text-align:right']);
|
||||
$pdf->set_custom_header($table->toHtml());
|
||||
|
||||
$background = api_get_path(SYS_PATH).'custompages/url-images/'.api_get_current_access_url_id().'_pdf_background.png';
|
||||
$content = '<html><body style="background-image-resize: 5; background-position: top left; background-image: url('.$background.');">'.$content.'</body></html>';
|
||||
|
||||
@$pdf->content_to_pdf(
|
||||
$content,
|
||||
null,
|
||||
$courseInfo['code'].'_'.$lp->getName().'_'.api_get_local_time(),
|
||||
$courseInfo['code'],
|
||||
'D',
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
true
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$output = require_once api_get_path(SYS_CODE_PATH).'lp/lp_stats.php';
|
||||
|
||||
$actions = [];
|
||||
$actions[] = Display::url(
|
||||
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM),
|
||||
'javascript:history.back();'
|
||||
);
|
||||
$actions[] = Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM),
|
||||
'javascript:window.print();'
|
||||
);
|
||||
$actions[] = Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?export=csv&'.Security::remove_XSS($_SERVER['QUERY_STRING'])
|
||||
);
|
||||
|
||||
Display::display_header($nameTools);
|
||||
echo Display::toolbarAction(
|
||||
'actions',
|
||||
[implode(PHP_EOL, $actions)]
|
||||
);
|
||||
|
||||
$table_title = $session_id
|
||||
? Display::return_icon('session.png', get_lang('Session')).PHP_EOL.api_get_session_name($session_id).PHP_EOL
|
||||
: PHP_EOL;
|
||||
$table_title .= Display::return_icon('course.png', get_lang('Course')).PHP_EOL.$courseInfo['name'].PHP_EOL
|
||||
.Display::return_icon('user.png', get_lang('User')).' '.$name;
|
||||
|
||||
echo Display::page_header($table_title);
|
||||
echo Display::page_subheader(
|
||||
Display::return_icon('learnpath.png', get_lang('ToolLearnpath')).PHP_EOL.$lp_title
|
||||
);
|
||||
echo $output;
|
||||
Display::display_footer();
|
||||
2469
main/mySpace/myStudents.php
Normal file
2469
main/mySpace/myStudents.php
Normal file
File diff suppressed because it is too large
Load Diff
58
main/mySpace/my_career.php
Normal file
58
main/mySpace/my_career.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Fhaculty\Graph\Graph;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
if (false == api_get_configuration_value('allow_career_diagram')) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = api_get_js('jsplumb2.js');
|
||||
|
||||
$sessionCategories = UserManager::get_sessions_by_category(api_get_user_id(), false);
|
||||
|
||||
$content = '';
|
||||
$extraFieldValue = new ExtraFieldValue('session');
|
||||
$extraFieldValueCareer = new ExtraFieldValue('career');
|
||||
$career = new Career();
|
||||
foreach ($sessionCategories as $category) {
|
||||
$sessions = $category['sessions'];
|
||||
foreach ($sessions as $session) {
|
||||
$sessionId = $session['session_id'];
|
||||
// Getting session extra field 'external_career_id'
|
||||
$item = $extraFieldValue->get_values_by_handler_and_field_variable(
|
||||
$sessionId,
|
||||
'external_career_id'
|
||||
);
|
||||
if ($item && isset($item['value']) && !empty($item['value'])) {
|
||||
// External career id
|
||||
$externalCareerId = $item['value'];
|
||||
// Getting career id from external career id
|
||||
$itemCareer = $extraFieldValueCareer->get_item_id_from_field_variable_and_field_value(
|
||||
'external_career_id',
|
||||
$externalCareerId
|
||||
);
|
||||
if ($itemCareer && !empty($itemCareer['item_id'])) {
|
||||
$careerId = $itemCareer['item_id'];
|
||||
$careerInfo = $career->find($careerId);
|
||||
if (!empty($careerInfo)) {
|
||||
$diagram = $extraFieldValueCareer->get_values_by_handler_and_field_variable(
|
||||
$careerId,
|
||||
'career_diagram'
|
||||
);
|
||||
if ($diagram && !empty($diagram['value'])) {
|
||||
/** @var Graph $graph */
|
||||
$graph = UnserializeApi::unserialize('career', $diagram['value']);
|
||||
$content .= Career::renderDiagram($careerInfo, $graph);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$view = new Template('');
|
||||
$view->assign('content', $content);
|
||||
$view->display_one_col_template();
|
||||
212
main/mySpace/progress_in_session_report.php
Normal file
212
main/mySpace/progress_in_session_report.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Generate a session report during a period.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$toolName = get_lang('ProgressInSessionReport');
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_CODE_PATH).'mySpace/index.php',
|
||||
'name' => get_lang('Reporting'),
|
||||
];
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_CODE_PATH).'mySpace/session.php',
|
||||
'name' => get_lang('FollowedSessions'),
|
||||
];
|
||||
|
||||
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
|
||||
|
||||
$script = '<script>
|
||||
var sessionId = '.$sessionId.';
|
||||
$(function() {
|
||||
$(".export").click(function(e) {
|
||||
var actionFrm = $(this).attr("href");
|
||||
submitFrm(actionFrm, e);
|
||||
});
|
||||
|
||||
$("#session_progress_report_submitReport").click(function(e) {
|
||||
var actionFrm = "'.api_get_self().'";
|
||||
submitFrm(actionFrm, e);
|
||||
});
|
||||
|
||||
if (sessionId > 0) {
|
||||
$("#session_progress_report_submitReport").click();
|
||||
}
|
||||
})
|
||||
|
||||
function submitFrm(actionFrm, e) {
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
$("#session_progress_report").attr("action", actionFrm);
|
||||
$("#session_progress_report").submit();
|
||||
}
|
||||
</script>';
|
||||
|
||||
$actions = null;
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('back.png', get_lang('Back'),
|
||||
null,
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
'../mySpace/session.php'
|
||||
);
|
||||
|
||||
if (api_is_platform_admin()) {
|
||||
$sessionList = SessionManager::get_sessions_list();
|
||||
} elseif (api_is_drh()) {
|
||||
$sessionList = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
|
||||
} elseif (api_is_session_admin()) {
|
||||
$sessionList = SessionManager::getSessionsFollowedByUser(api_get_user_id(), SESSIONADMIN);
|
||||
} else {
|
||||
$sessionList = Tracking::get_sessions_coached_by_user(api_get_user_id());
|
||||
}
|
||||
|
||||
$form = new FormValidator('session_progress_report');
|
||||
$selectSession = $form->addSelect('session_id', get_lang('Session'), [0 => get_lang('None')]);
|
||||
|
||||
foreach ($sessionList as $sessionInfo) {
|
||||
$selectSession->addOption($sessionInfo['name'], $sessionInfo['id']);
|
||||
}
|
||||
|
||||
$form->addDateRangePicker(
|
||||
'date_range',
|
||||
get_lang('DateRange'),
|
||||
false,
|
||||
['id' => 'date_range']
|
||||
);
|
||||
$form->addButtonFilter(get_lang('Filter'), 'submitReport');
|
||||
|
||||
if (!empty($sessionId)) {
|
||||
$form->setDefaults(['session_id' => $sessionId]);
|
||||
}
|
||||
|
||||
$users = [];
|
||||
$courses = [];
|
||||
$sessionName = '';
|
||||
if ($form->validate()) {
|
||||
$formValues = $form->getSubmitValues();
|
||||
$sessionId = $formValues['session_id'];
|
||||
$startDate = $formValues['date_range_start'];
|
||||
$endDate = $formValues['date_range_end'];
|
||||
$accessSessionCourse = CourseManager::getAccessCourse(
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
$startDate,
|
||||
$endDate,
|
||||
$sessionId
|
||||
);
|
||||
|
||||
if (!empty($accessSessionCourse)) {
|
||||
$session = api_get_session_entity($sessionId);
|
||||
$sessionName = $session->getName();
|
||||
|
||||
foreach ($accessSessionCourse as $access) {
|
||||
$user = api_get_user_entity($access['user_id']);
|
||||
|
||||
$studentLink = Display::url(
|
||||
UserManager::formatUserFullName($user),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$user->getId().'&origin=session_report'
|
||||
);
|
||||
|
||||
$users[$user->getId()] = [
|
||||
'complete_name' => $studentLink,
|
||||
'time_in_platform' => api_time_to_hms(
|
||||
Tracking::get_time_spent_on_the_course($user->getId(), $access['c_id'], $sessionId, $startDate, $endDate)
|
||||
),
|
||||
];
|
||||
$course = api_get_course_entity($access['c_id']);
|
||||
$courses[$course->getCode()] = $course->getCode();
|
||||
}
|
||||
|
||||
if (!empty($courses)) {
|
||||
foreach ($courses as $courseCode => $name) {
|
||||
foreach ($users as $userId => $user) {
|
||||
$progress = Tracking::get_avg_student_progress(
|
||||
$userId,
|
||||
$courseCode,
|
||||
[],
|
||||
$sessionId,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
$startDate,
|
||||
$endDate
|
||||
);
|
||||
$infoGradeCertificate = UserManager::get_info_gradebook_certificate(
|
||||
$courseCode,
|
||||
$sessionId,
|
||||
$userId,
|
||||
$startDate,
|
||||
$endDate
|
||||
);
|
||||
$users[$userId][$courseCode.'_progress'] = is_numeric($progress) ? "$progress %" : '0 %';
|
||||
$users[$userId][$courseCode.'_certificate'] = $infoGradeCertificate ? get_lang('Yes') : get_lang('No');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['export']) && !empty($users)) {
|
||||
$fileName = 'progress_in_session_'.api_get_local_time();
|
||||
|
||||
$dataToExport = [];
|
||||
$dataToExport['headers'][] = get_lang('StudentName');
|
||||
$dataToExport['headers'][] = get_lang('TimeSpentOnThePlatform');
|
||||
|
||||
foreach ($courses as $courseCode) {
|
||||
$dataToExport['headers'][] = get_lang('Progress').' '.$courseCode;
|
||||
$dataToExport['headers'][] = get_lang('Certificate').' '.$courseCode;
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
$dataToExport[] = $user;
|
||||
}
|
||||
|
||||
switch ($_GET['export']) {
|
||||
case 'xls':
|
||||
Export::export_table_xls_html($dataToExport, $fileName);
|
||||
break;
|
||||
case 'csv':
|
||||
Export::arrayToCsv($dataToExport, $fileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$view = new Template($toolName);
|
||||
$view->assign('form', $form->returnForm());
|
||||
$view->assign('script', $script);
|
||||
if (!empty($users)) {
|
||||
$view->assign('sessionName', $sessionName);
|
||||
$view->assign('courses', $courses);
|
||||
$view->assign('users', $users);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], 32),
|
||||
api_get_self().'?export=csv',
|
||||
['class' => 'export']
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?export=xls',
|
||||
['class' => 'export']
|
||||
);
|
||||
}
|
||||
$template = $view->get_template('my_space/progress_in_session_report.tpl');
|
||||
$content = $view->fetch($template);
|
||||
$view->assign(
|
||||
'actions',
|
||||
Display::toolbarAction('toolbar', [$actions])
|
||||
);
|
||||
$view->assign('header', $toolName);
|
||||
$view->assign('content', $content);
|
||||
$view->display_one_col_template();
|
||||
78
main/mySpace/progression.php
Normal file
78
main/mySpace/progression.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* Progress report.
|
||||
*
|
||||
* @deprecated seems there's no link to this page
|
||||
* Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
|
||||
*/
|
||||
|
||||
// TODO: This file seems to be unfinished and unused.
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$nameTools = get_lang('Progression');
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
api_block_anonymous_users();
|
||||
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
|
||||
Display::display_header($nameTools);
|
||||
|
||||
// Database Table Definitions
|
||||
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
|
||||
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
|
||||
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
|
||||
$tbl_track_exercice = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
|
||||
|
||||
/*
|
||||
MAIN CODE
|
||||
*/
|
||||
$sql_course = "SELECT title, code, id
|
||||
FROM $tbl_course as course
|
||||
ORDER BY title ASC";
|
||||
$result_course = Database::query($sql_course);
|
||||
|
||||
if (Database::num_rows($result_course) > 0) {
|
||||
if (isset($_POST['export'])) {
|
||||
$export_result = export_csv($header, $data, 'test.csv'); // TODO: There is no data for exporting yet.
|
||||
echo Display::return_message($export_result, 'error');
|
||||
}
|
||||
echo '<table class="table table-hover table-striped data_table">
|
||||
<tr>
|
||||
<th>'.get_lang('Course').'</th>
|
||||
<th>'.get_lang('TempsFrequentation').'</th>
|
||||
<th>'.get_lang('Progression').'</th>
|
||||
<th>'.get_lang('MoyenneTest').'</th>
|
||||
</tr>';
|
||||
$header = [get_lang('Course'), get_lang('TempsFrequentation'), get_lang('Progression'), get_lang('MoyenneTest')];
|
||||
while ($a_course = Database::fetch_array($result_course)) {
|
||||
// TODO: This query is to be checked, there are no HotPotatoes tests results.
|
||||
$sql_moy_test = "SELECT exe_result,exe_weighting
|
||||
FROM $tbl_track_exercice
|
||||
WHERE c_id = ".$a_course['id'];
|
||||
$result_moy_test = Database::query($sql_moy_test);
|
||||
$result = 0;
|
||||
$weighting = 0;
|
||||
while ($moy_test = Database::fetch_array($result_moy_test)) {
|
||||
$result = $result + $moy_test['exe_result'];
|
||||
$weighting = $weighting + $moy_test['exe_weighting'];
|
||||
}
|
||||
if (0 != $weighting) {
|
||||
$moyenne_test = round(($result * 100) / $weighting);
|
||||
} else {
|
||||
$moyenne_test = null;
|
||||
}
|
||||
echo '<tr><td>'.$a_course['title'].'</td><td> </td><td> </td><td>'.(is_null($moyenne_test) ? '' : $moyenne_test.'%').'</td> </tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
echo "<br /><br />";
|
||||
echo "<form method='post'><input type='submit' name='export' value='".get_lang('ExportExcel')."'/><form>";
|
||||
} else {
|
||||
echo get_lang('NoCourse');
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
206
main/mySpace/question_stats_global.php
Normal file
206
main/mySpace/question_stats_global.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
|
||||
$courseIdList = $_REQUEST['courses'] ?? [];
|
||||
$exercises = $_REQUEST['exercises'] ?? [];
|
||||
$groups = $_REQUEST['groups'] ?? [];
|
||||
$users = $_REQUEST['users'] ?? [];
|
||||
|
||||
$courseOptions = [];
|
||||
$exerciseList = [];
|
||||
$selectedExercises = [];
|
||||
$groupList = [];
|
||||
$allGroups = [];
|
||||
$allUsers = [];
|
||||
if (!empty($courseIdList)) {
|
||||
foreach ($courseIdList as $courseId) {
|
||||
$courseId = (int) $courseId;
|
||||
$courseInfo = api_get_course_info_by_id($courseId);
|
||||
$courseGroups = GroupManager::get_group_list(null, $courseInfo);
|
||||
if (!empty($courseGroups)) {
|
||||
$courseGroups = array_column($courseGroups, 'name', 'iid');
|
||||
array_walk(
|
||||
$courseGroups,
|
||||
function (&$name, $key) use ($courseInfo) {
|
||||
$name = $name.' - '.$courseInfo['title'];
|
||||
}
|
||||
);
|
||||
$allGroups = $allGroups + $courseGroups;
|
||||
}
|
||||
|
||||
$courseUsers = CourseManager::get_user_list_from_course_code($courseInfo['code']);
|
||||
if (!empty($courseUsers)) {
|
||||
array_walk(
|
||||
$courseUsers,
|
||||
function (&$data, $key) {
|
||||
$data = api_get_person_name($data['firstname'], $data['lastname']);
|
||||
}
|
||||
);
|
||||
|
||||
$allUsers = $allUsers + $courseUsers;
|
||||
}
|
||||
|
||||
$courseExerciseList = ExerciseLib::get_all_exercises(
|
||||
$courseInfo,
|
||||
0,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
3
|
||||
);
|
||||
|
||||
if (!empty($courseExerciseList)) {
|
||||
foreach ($courseExerciseList as $exercise) {
|
||||
$exerciseId = $exercise['iid'];
|
||||
if (in_array($exerciseId, $exercises)) {
|
||||
$selectedExercises[$courseId][] = $exerciseId;
|
||||
}
|
||||
}
|
||||
$exerciseList += array_column($courseExerciseList, 'title', 'iid');
|
||||
}
|
||||
$courseOptions[$courseId] = $courseInfo['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$exerciseList = array_unique($exerciseList);
|
||||
if (!empty($exerciseList)) {
|
||||
array_walk($exerciseList, function (&$title) {
|
||||
$title = Exercise::get_formated_title_variable($title);
|
||||
});
|
||||
}
|
||||
|
||||
$form = new FormValidator('search_form', 'GET', api_get_self());
|
||||
$form->addSelectAjax(
|
||||
'courses',
|
||||
get_lang('Course'),
|
||||
$courseOptions,
|
||||
[
|
||||
'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course',
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
|
||||
if (!empty($allGroups)) {
|
||||
$form->addSelect(
|
||||
'groups',
|
||||
get_lang('Groups'),
|
||||
$allGroups,
|
||||
[
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($allUsers)) {
|
||||
$form->addSelect(
|
||||
'users',
|
||||
get_lang('Users'),
|
||||
$allUsers,
|
||||
[
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($courseIdList)) {
|
||||
$form->addSelect(
|
||||
'exercises',
|
||||
get_lang('Exercise'),
|
||||
$exerciseList,
|
||||
[
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$form->setDefaults(['course_id_list' => array_keys($courseOptions)]);
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
|
||||
$tableContent = '';
|
||||
if ($form->validate()) {
|
||||
$headers = [
|
||||
get_lang('Course'),
|
||||
get_lang('Exercise'),
|
||||
get_lang('Question'),
|
||||
get_lang('WrongAnswer').' / '.get_lang('Total'),
|
||||
'%',
|
||||
];
|
||||
|
||||
$scoreDisplay = new ScoreDisplay();
|
||||
$exercises = $form->getSubmitValue('exercises');
|
||||
if ($exercises) {
|
||||
$orderedData = [];
|
||||
foreach ($selectedExercises as $courseId => $selectedExerciseList) {
|
||||
foreach ($selectedExerciseList as $exerciseId) {
|
||||
$questions = ExerciseLib::getWrongQuestionResults($courseId, $exerciseId, null, $groups, $users);
|
||||
foreach ($questions as $data) {
|
||||
$questionId = (int) $data['question_id'];
|
||||
$total = ExerciseLib::getTotalQuestionAnswered(
|
||||
$courseId,
|
||||
$exerciseId,
|
||||
$questionId,
|
||||
null,
|
||||
$groups,
|
||||
$users
|
||||
);
|
||||
$orderedData[] = [
|
||||
$courseOptions[$courseId],
|
||||
$exerciseList[$exerciseId],
|
||||
$data['question'],
|
||||
$data['count'].' / '.$total,
|
||||
$scoreDisplay->display_score([$data['count'], $total], SCORE_AVERAGE),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$table = new SortableTableFromArray(
|
||||
$orderedData,
|
||||
0,
|
||||
100,
|
||||
'question_tracking'
|
||||
);
|
||||
$table->hideNavigation = true;
|
||||
$table->column = 4;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->set_header($column, $header, false);
|
||||
$column++;
|
||||
}
|
||||
$tableContent = $table->return_table();
|
||||
}
|
||||
}
|
||||
|
||||
$nameTools = get_lang('ExerciseManagement');
|
||||
$htmlHeadXtra[] = '<script>
|
||||
$(function() {
|
||||
$("#search_form").submit();
|
||||
$("#search_form_courses").on("change", function (e) {
|
||||
$("#search_form_exercises").parent().parent().parent().hide();
|
||||
$("#search_form_exercises").each(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
Display::display_header($nameTools, get_lang('Exercise'));
|
||||
$form->display();
|
||||
echo $tableContent;
|
||||
|
||||
Display::display_footer();
|
||||
214
main/mySpace/question_stats_global_detail.php
Normal file
214
main/mySpace/question_stats_global_detail.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
|
||||
|
||||
$courseIdList = isset($_REQUEST['courses']) ? $_REQUEST['courses'] : [];
|
||||
$exercises = isset($_REQUEST['exercises']) ? $_REQUEST['exercises'] : [];
|
||||
|
||||
$courseOptions = [];
|
||||
$exerciseList = [];
|
||||
$selectedExercises = [];
|
||||
if (!empty($courseIdList)) {
|
||||
foreach ($courseIdList as $courseId) {
|
||||
$courseInfo = api_get_course_info_by_id($courseId);
|
||||
$courseExerciseList = ExerciseLib::get_all_exercises(
|
||||
$courseInfo,
|
||||
0,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
3
|
||||
);
|
||||
|
||||
if (!empty($courseExerciseList)) {
|
||||
foreach ($courseExerciseList as $exercise) {
|
||||
$exerciseId = $exercise['iid'];
|
||||
if (in_array($exerciseId, $exercises)) {
|
||||
$selectedExercises[$courseId][] = $exerciseId;
|
||||
}
|
||||
}
|
||||
$exerciseList += array_column($courseExerciseList, 'title', 'iid');
|
||||
}
|
||||
$courseOptions[$courseId] = $courseInfo['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$exerciseList = array_unique($exerciseList);
|
||||
if (!empty($exerciseList)) {
|
||||
array_walk($exerciseList, function (&$title) {
|
||||
$title = Exercise::get_formated_title_variable($title);
|
||||
});
|
||||
}
|
||||
|
||||
$form = new FormValidator('search_form', 'GET', api_get_self());
|
||||
$form->addSelectAjax(
|
||||
'courses',
|
||||
get_lang('Course'),
|
||||
$courseOptions,
|
||||
[
|
||||
'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course',
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
|
||||
if (!empty($courseIdList)) {
|
||||
$form->addSelect(
|
||||
'exercises',
|
||||
get_lang('Exercise'),
|
||||
$exerciseList,
|
||||
[
|
||||
'multiple' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$form->setDefaults(['course_id_list' => array_keys($courseOptions)]);
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
|
||||
$tableContent = '';
|
||||
|
||||
function getCourseSessionRow($courseId, Exercise $exercise, $sessionId, $title)
|
||||
{
|
||||
$correctCount = ExerciseLib::getExerciseResultsCount('correct', $courseId, $exercise, $sessionId);
|
||||
$wrongCount = ExerciseLib::getExerciseResultsCount('wrong', $courseId, $exercise, $sessionId);
|
||||
$correctCountStudent = ExerciseLib::getExerciseResultsCount(
|
||||
'correct_student',
|
||||
$courseId,
|
||||
$exercise,
|
||||
$sessionId
|
||||
);
|
||||
$wrongCountStudent = ExerciseLib::getExerciseResultsCount(
|
||||
'wrong_student',
|
||||
$courseId,
|
||||
$exercise,
|
||||
$sessionId
|
||||
);
|
||||
|
||||
//$questions = ExerciseLib::getWrongQuestionResults($courseId, $exerciseId, $sessionId);
|
||||
return [
|
||||
'title' => $title,
|
||||
'correct_count' => $correctCount,
|
||||
'wrong_count' => $wrongCount,
|
||||
'correct_count_student' => $correctCountStudent,
|
||||
'wrong_count_student' => $wrongCountStudent,
|
||||
];
|
||||
}
|
||||
|
||||
if ($form->validate()) {
|
||||
$headers = [
|
||||
get_lang('Session'),
|
||||
get_lang('SuccessfulAttempt'),
|
||||
get_lang('FailedAttempt'),
|
||||
get_lang('StudentWithSuccessfulAttempt'),
|
||||
get_lang('StudentWithFailedAttempt'),
|
||||
];
|
||||
$scoreDisplay = new ScoreDisplay();
|
||||
$exercises = $form->getSubmitValue('exercises');
|
||||
$exerciseTable = Database::get_course_table(TABLE_QUIZ_TEST);
|
||||
if ($exercises) {
|
||||
foreach ($selectedExercises as $courseId => $courseExerciseList) {
|
||||
$sessions = SessionManager::get_session_by_course($courseId);
|
||||
$courseTitle = $courseOptions[$courseId];
|
||||
|
||||
foreach ($courseExerciseList as $exerciseId) {
|
||||
$exerciseObj = new Exercise($courseId);
|
||||
$result = $exerciseObj->read($exerciseId, false);
|
||||
if (false === $result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$exerciseTitle = $exerciseList[$exerciseId];
|
||||
$tableContent .= Display::page_subheader2($courseTitle.' - '.$exerciseTitle);
|
||||
$orderedData = [];
|
||||
$total = [];
|
||||
$correctCount = 0;
|
||||
$wrongCount = 0;
|
||||
$correctCountStudent = 0;
|
||||
$wrongCountStudent = 0;
|
||||
|
||||
foreach ($sessions as $session) {
|
||||
$sessionId = $session['id'];
|
||||
$row = getCourseSessionRow($courseId, $exerciseObj, $sessionId, $session['name']);
|
||||
$correctCount += $row['correct_count'];
|
||||
$wrongCount += $row['wrong_count'];
|
||||
$correctCountStudent += $row['correct_count_student'];
|
||||
$wrongCountStudent += $row['wrong_count_student'];
|
||||
|
||||
$orderedData[] = [
|
||||
$row['title'],
|
||||
$row['correct_count'],
|
||||
$row['wrong_count'],
|
||||
$row['correct_count_student'],
|
||||
$row['wrong_count_student'],
|
||||
];
|
||||
}
|
||||
|
||||
// Course base
|
||||
$row = getCourseSessionRow($courseId, $exerciseObj, 0, get_lang('BaseCourse'));
|
||||
$orderedData[] = [
|
||||
$row['title'],
|
||||
$row['correct_count'],
|
||||
$row['wrong_count'],
|
||||
$row['correct_count_student'],
|
||||
$row['wrong_count_student'],
|
||||
];
|
||||
|
||||
$correctCount += $row['correct_count'];
|
||||
$wrongCount += $row['wrong_count'];
|
||||
$correctCountStudent += $row['correct_count_student'];
|
||||
$wrongCountStudent += $row['wrong_count_student'];
|
||||
$orderedData[] = [
|
||||
get_lang('Total'),
|
||||
$correctCount,
|
||||
$wrongCount,
|
||||
$correctCountStudent,
|
||||
$wrongCountStudent,
|
||||
];
|
||||
|
||||
/*$table = new SortableTableFromArray(
|
||||
$orderedData,
|
||||
10,
|
||||
1000,
|
||||
uniqid('question_tracking_')
|
||||
);*/
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$table->setHeaders($headers);
|
||||
$table->setData($orderedData);
|
||||
$tableContent .= $table->toHtml();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nameTools = get_lang('ExerciseManagement');
|
||||
$htmlHeadXtra[] = '<script>
|
||||
$(function() {
|
||||
$("#search_form").submit();
|
||||
$("#search_form_courses").on("change", function (e) {
|
||||
$("#search_form_exercises").parent().parent().parent().hide();
|
||||
$("#search_form_exercises").each(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
Display::display_header($nameTools, get_lang('Exercise'));
|
||||
$form->display();
|
||||
echo $tableContent;
|
||||
|
||||
Display::display_footer();
|
||||
641
main/mySpace/session.php
Normal file
641
main/mySpace/session.php
Normal file
@@ -0,0 +1,641 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
ob_start();
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
$export_csv = false;
|
||||
if (isset($_REQUEST['export']) && 'csv' == $_REQUEST['export']) {
|
||||
$export_csv = true;
|
||||
}
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : '';
|
||||
|
||||
$id_coach = api_get_user_id();
|
||||
if (isset($_REQUEST['id_coach']) && '' != $_REQUEST['id_coach']) {
|
||||
$id_coach = (int) $_REQUEST['id_coach'];
|
||||
}
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$studentId = isset($_GET['student']) ? (int) $_GET['student'] : 0;
|
||||
$sessionId = isset($_GET['sid']) ? (int) $_GET['sid'] : 0;
|
||||
$hideConnectionTime = isset($_REQUEST['hide_connection_time']) ? (int) $_REQUEST['hide_connection_time'] : 0;
|
||||
$currentUrl = api_get_self().'?student='.$studentId.'&sid='.$sessionId;
|
||||
|
||||
switch ($action) {
|
||||
case 'export_to_pdf':
|
||||
$allStudents = isset($_GET['all_students']) && 1 === (int) $_GET['all_students'] ? true : false;
|
||||
$sessionToExport = isset($_GET['session_to_export']) ? (int) $_GET['session_to_export'] : 0;
|
||||
$type = isset($_GET['type']) ? $_GET['type'] : 'attendance';
|
||||
$sessionInfo = api_get_session_info($sessionToExport);
|
||||
if (empty($sessionInfo)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$courses = Tracking::get_courses_list_from_session($sessionToExport);
|
||||
$studentList = [$studentId];
|
||||
if ($allStudents) {
|
||||
$users = SessionManager::get_users_by_session($sessionToExport, 0);
|
||||
$studentList = array_column($users, 'user_id');
|
||||
}
|
||||
|
||||
$totalCourses = count($courses);
|
||||
$scoreDisplay = ScoreDisplay::instance();
|
||||
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
|
||||
$pdfList = [];
|
||||
foreach ($studentList as $studentId) {
|
||||
$studentInfo = api_get_user_info($studentId);
|
||||
$timeSpent = 0;
|
||||
$numberVisits = 0;
|
||||
$progress = 0;
|
||||
$timeSpentPerCourse = [];
|
||||
$progressPerCourse = [];
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$courseId = $course['c_id'];
|
||||
$courseTimeSpent = Tracking::get_time_spent_on_the_course($studentId, $courseId, $sessionToExport);
|
||||
$timeSpentPerCourse[$courseId] = $courseTimeSpent;
|
||||
$timeSpent += $courseTimeSpent;
|
||||
$sql = "SELECT DISTINCT count(course_access_id) as count
|
||||
FROM $table
|
||||
WHERE
|
||||
c_id = $courseId AND
|
||||
session_id = $sessionToExport AND
|
||||
user_id = $studentId";
|
||||
$result = Database::query($sql);
|
||||
$row = Database::fetch_array($result);
|
||||
$numberVisits += $row['count'];
|
||||
$courseProgress = Tracking::get_avg_student_progress(
|
||||
$studentId,
|
||||
$course['code'],
|
||||
[],
|
||||
$sessionToExport
|
||||
);
|
||||
$progressPerCourse[$courseId] = $courseProgress;
|
||||
$progress += $courseProgress;
|
||||
}
|
||||
|
||||
$average = round($progress / $totalCourses, 1);
|
||||
$average = empty($average) ? '0%' : $average.'%';
|
||||
$first = Tracking::get_first_connection_date($studentId);
|
||||
$last = Tracking::get_last_connection_date($studentId);
|
||||
$timeSpentContent = '';
|
||||
$pdfTitle = get_lang('AttestationOfAttendance');
|
||||
if ('attendance' === $type) {
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$column = 0;
|
||||
$row = 0;
|
||||
$headers = [
|
||||
get_lang('TimeSpent'),
|
||||
get_lang('NumberOfVisits'),
|
||||
get_lang('GlobalProgress'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexionDate'),
|
||||
];
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$column++;
|
||||
}
|
||||
$table->setCellContents(1, 0, api_time_to_hms($timeSpent));
|
||||
$table->setCellContents(1, 1, $numberVisits);
|
||||
$table->setCellContents(1, 2, $average);
|
||||
$table->setCellContents(1, 3, $first);
|
||||
$table->setCellContents(1, 4, $last);
|
||||
$timeSpentContent = $table->toHtml();
|
||||
} else {
|
||||
$pdfTitle = get_lang('CertificateOfAchievement');
|
||||
}
|
||||
|
||||
$courseTable = '';
|
||||
if (!empty($courses)) {
|
||||
$courseTable .= '<table class="table table-hover table-striped data_table">';
|
||||
$courseTable .= '<thead>';
|
||||
$courseTable .= '<tr>
|
||||
<th>'.get_lang('FormationUnit').'</th>';
|
||||
|
||||
if (!$hideConnectionTime) {
|
||||
$courseTable .= '<th>'.get_lang('ConnectionTime').'</th>';
|
||||
}
|
||||
|
||||
$courseTable .= '<th>'.get_lang('Progress').'</th>';
|
||||
|
||||
if ('attendance' === $type) {
|
||||
$courseTable .= '<th>'.get_lang('Score').'</th>';
|
||||
}
|
||||
$courseTable .= '</tr>';
|
||||
$courseTable .= '</thead>';
|
||||
$courseTable .= '<tbody>';
|
||||
|
||||
$totalCourseTime = 0;
|
||||
$totalAttendance = [0, 0];
|
||||
$totalScore = 0;
|
||||
$totalProgress = 0;
|
||||
$gradeBookTotal = [0, 0];
|
||||
$totalEvaluations = '0/0 (0%)';
|
||||
|
||||
foreach ($courses as $course) {
|
||||
$courseId = $course['c_id'];
|
||||
$courseInfoItem = api_get_course_info_by_id($courseId);
|
||||
$courseId = $courseInfoItem['real_id'];
|
||||
$courseCodeItem = $courseInfoItem['code'];
|
||||
|
||||
$isSubscribed = CourseManager::is_user_subscribed_in_course(
|
||||
$studentId,
|
||||
$courseCodeItem,
|
||||
true,
|
||||
$sessionToExport
|
||||
);
|
||||
|
||||
if ($isSubscribed) {
|
||||
$timeInSeconds = $timeSpentPerCourse[$courseId];
|
||||
$totalCourseTime += $timeInSeconds;
|
||||
$time_spent_on_course = api_time_to_hms($timeInSeconds);
|
||||
$progress = $progressPerCourse[$courseId];
|
||||
$totalProgress += $progress;
|
||||
|
||||
$bestScore = Tracking::get_avg_student_score(
|
||||
$studentId,
|
||||
$courseCodeItem,
|
||||
[],
|
||||
$sessionToExport,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
if (is_numeric($bestScore)) {
|
||||
$totalScore += $bestScore;
|
||||
}
|
||||
|
||||
$progress = empty($progress) ? '0%' : $progress.'%';
|
||||
$score = empty($bestScore) ? '0%' : $bestScore.'%';
|
||||
|
||||
$courseTable .= '<tr>
|
||||
<td>
|
||||
<a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sessionToExport.'">'.
|
||||
$courseInfoItem['title'].'</a>
|
||||
</td>';
|
||||
if (!$hideConnectionTime) {
|
||||
$courseTable .= '<td >'.$time_spent_on_course.'</td>';
|
||||
}
|
||||
$courseTable .= '<td >'.$progress.'</td>';
|
||||
if ('attendance' === $type) {
|
||||
$courseTable .= '<td >'.$score.'</td>';
|
||||
}
|
||||
$courseTable .= '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
$totalAttendanceFormatted = $scoreDisplay->display_score($totalAttendance);
|
||||
$totalScoreFormatted = $scoreDisplay->display_score([$totalScore / $totalCourses, 100], SCORE_AVERAGE);
|
||||
$totalProgressFormatted = $scoreDisplay->display_score(
|
||||
[$totalProgress / $totalCourses, 100],
|
||||
SCORE_AVERAGE
|
||||
);
|
||||
$totalEvaluations = $scoreDisplay->display_score($gradeBookTotal);
|
||||
$totalTimeFormatted = api_time_to_hms($totalCourseTime);
|
||||
$courseTable .= '
|
||||
<tr>
|
||||
<th>'.get_lang('Total').'</th>';
|
||||
if (!$hideConnectionTime) {
|
||||
$courseTable .= '<th>'.$totalTimeFormatted.'</th>';
|
||||
}
|
||||
$courseTable .= '<th>'.$totalProgressFormatted.'</th>';
|
||||
if ('attendance' === $type) {
|
||||
$courseTable .= '<th>'.$totalScoreFormatted.'</th>';
|
||||
}
|
||||
$courseTable .= '</tr>';
|
||||
$courseTable .= '</tbody></table>';
|
||||
}
|
||||
|
||||
$tpl = new Template('', false, false, false, true, false, false);
|
||||
$tpl->assign('title', $pdfTitle);
|
||||
$tpl->assign('session_title', $sessionInfo['name']);
|
||||
$tpl->assign('session_info', $sessionInfo);
|
||||
$sessionCategoryTitle = '';
|
||||
if (isset($sessionInfo['session_category_id'])) {
|
||||
$sessionCategory = SessionManager::get_session_category($sessionInfo['session_category_id']);
|
||||
if ($sessionCategory) {
|
||||
$sessionCategoryTitle = $sessionCategory['name'];
|
||||
}
|
||||
}
|
||||
$dateData = SessionManager::parseSessionDates($sessionInfo, false);
|
||||
$dateToString = $dateData['access'];
|
||||
$tpl->assign('session_display_dates', $dateToString);
|
||||
$tpl->assign('session_category_title', $sessionCategoryTitle);
|
||||
$tpl->assign('student', $studentInfo['complete_name']);
|
||||
$tpl->assign('student_info', $studentInfo);
|
||||
$tpl->assign('student_info_extra_fields', UserManager::get_extra_user_data($studentInfo['user_id']));
|
||||
$tpl->assign('table_progress', $timeSpentContent);
|
||||
$tpl->assign(
|
||||
'subtitle',
|
||||
sprintf(
|
||||
get_lang('InSessionXYouHadTheFollowingResults'),
|
||||
$sessionInfo['name']
|
||||
)
|
||||
);
|
||||
$tpl->assign('table_course', $courseTable);
|
||||
$template = 'pdf_export_student.tpl';
|
||||
if ('achievement' === $type) {
|
||||
$template = 'certificate_achievement.tpl';
|
||||
}
|
||||
$content = $tpl->fetch($tpl->get_template('my_space/'.$template));
|
||||
|
||||
$params = [
|
||||
'pdf_title' => get_lang('Resume'),
|
||||
'session_info' => $sessionInfo,
|
||||
'course_info' => '',
|
||||
'pdf_date' => '',
|
||||
'student_info' => $studentInfo,
|
||||
'show_grade_generated_date' => true,
|
||||
'show_real_course_teachers' => false,
|
||||
'show_teacher_as_myself' => false,
|
||||
'orientation' => 'P',
|
||||
];
|
||||
@$pdf = new PDF('A4', $params['orientation'], $params);
|
||||
$pdf->setBackground($tpl->theme);
|
||||
$mode = 'D';
|
||||
|
||||
$pdfName = $sessionInfo['name'].'_'.$studentInfo['complete_name'];
|
||||
if ($allStudents) {
|
||||
$mode = 'F';
|
||||
$pdfName = $studentInfo['complete_name'];
|
||||
}
|
||||
$pdf->set_footer();
|
||||
$result = @$pdf->content_to_pdf(
|
||||
$content,
|
||||
'',
|
||||
$pdfName,
|
||||
null,
|
||||
$mode,
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
$pdfList[] = $result;
|
||||
}
|
||||
|
||||
if (empty($pdfList)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
// Creating a ZIP file.
|
||||
$tempZipFile = api_get_path(SYS_ARCHIVE_PATH).uniqid('report_session_'.$sessionToExport, true).'.zip';
|
||||
|
||||
$zip = new PclZip($tempZipFile);
|
||||
foreach ($pdfList as $file) {
|
||||
$zip->add(
|
||||
$file,
|
||||
PCLZIP_OPT_REMOVE_PATH,
|
||||
api_get_path(SYS_ARCHIVE_PATH)
|
||||
);
|
||||
}
|
||||
$name = $sessionInfo['name'].'_'.api_get_utc_datetime().'.zip';
|
||||
DocumentManager::file_send_for_download($tempZipFile, true, $name);
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
Display::display_header(get_lang('Sessions'));
|
||||
|
||||
if (api_is_platform_admin(true, true)) {
|
||||
$a_sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
|
||||
|
||||
if (!api_is_session_admin()) {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
'index.php?view=drh_students&display=yourstudents'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM),
|
||||
'course.php'
|
||||
);
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('session_na.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
);
|
||||
} else {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'session_admin_teachers.php'
|
||||
);
|
||||
}
|
||||
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('works.png', get_lang('WorksReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/works_in_session_report.php'
|
||||
);
|
||||
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('attendance_list.png', get_lang('ProgressInSessionReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/progress_in_session_report.php'
|
||||
);
|
||||
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('clock.png', get_lang('TeacherTimeReportBySession'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'admin/teachers_time_by_session_report.php'
|
||||
);
|
||||
|
||||
if (!api_is_session_admin()) {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('1day.png', get_lang('SessionsPlanCalendar'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."calendar/planification.php"
|
||||
);
|
||||
}
|
||||
|
||||
if (api_is_drh()) {
|
||||
$menu_items[] = Display::url(
|
||||
Display::return_icon('session.png', get_lang('SessionFilterReport'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/session_filter.php'
|
||||
);
|
||||
}
|
||||
|
||||
$actionsLeft = '';
|
||||
$nb_menu_items = count($menu_items);
|
||||
if ($nb_menu_items > 1) {
|
||||
foreach ($menu_items as $key => $item) {
|
||||
$actionsLeft .= $item;
|
||||
}
|
||||
}
|
||||
$actionsRight = '';
|
||||
if (count($a_sessions) > 0) {
|
||||
$actionsRight = Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), [], 32),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print();']
|
||||
);
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], 32),
|
||||
api_get_self().'?export=csv'
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar = Display::toolbarAction(
|
||||
'toolbar-session',
|
||||
[$actionsLeft, $actionsRight]
|
||||
);
|
||||
echo $toolbar;
|
||||
|
||||
echo Display::page_header(get_lang('YourSessionsList'));
|
||||
} elseif (api_is_teacher()) {
|
||||
$actionsRight = Display::url(
|
||||
Display::return_icon('clock.png', get_lang('TeacherTimeReportBySession'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH).'admin/teachers_time_by_session_report.php'
|
||||
);
|
||||
|
||||
$toolbar = Display::toolbarAction(
|
||||
'toolbar-session',
|
||||
['', $actionsRight]
|
||||
);
|
||||
echo $toolbar;
|
||||
|
||||
echo Display::page_header(get_lang('YourSessionsList'));
|
||||
} else {
|
||||
$a_sessions = Tracking::get_sessions_coached_by_user($id_coach);
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_course',
|
||||
'post',
|
||||
api_get_path(WEB_CODE_PATH).'mySpace/session.php'
|
||||
);
|
||||
$form->addElement('text', 'keyword', get_lang('Keyword'));
|
||||
|
||||
$extraFieldSession = new ExtraField('session');
|
||||
$extraFieldSession->addElements(
|
||||
$form,
|
||||
null,
|
||||
[],
|
||||
true
|
||||
);
|
||||
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
$keyword = '';
|
||||
$result = SessionManager::getGridColumns('my_space');
|
||||
|
||||
$columns = $result['columns'];
|
||||
$columnModel = $result['column_model'];
|
||||
|
||||
$filterToString = '';
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
$keyword = Security::remove_XSS($form->getSubmitValue('keyword'));
|
||||
$extraField = new ExtraField('session');
|
||||
$extraFields = $extraField->get_all(null, 'option_order');
|
||||
$extraFields = array_column($extraFields, 'variable');
|
||||
$filter = new stdClass();
|
||||
|
||||
foreach ($columnModel as $col) {
|
||||
if (isset($values[$col['index']]) && !empty($values[$col['index']]) &&
|
||||
in_array(str_replace('extra_', '', $col['index']), $extraFields)
|
||||
) {
|
||||
$rule = new stdClass();
|
||||
$index = $col['index'];
|
||||
$rule->field = $index;
|
||||
$rule->op = 'in';
|
||||
$data = $values[$index];
|
||||
if (is_array($data) && array_key_exists($index, $data)) {
|
||||
$data = $data[$index];
|
||||
}
|
||||
$rule->data = Security::remove_XSS($data);
|
||||
$filter->rules[] = $rule;
|
||||
$filter->groupOp = 'AND';
|
||||
}
|
||||
}
|
||||
$filterToString = json_encode($filter);
|
||||
}
|
||||
$form->setDefaults(['keyword' => $keyword]);
|
||||
|
||||
$url = api_get_path(WEB_AJAX_PATH).
|
||||
'model.ajax.php?a=get_sessions_tracking&_search=true&_force_search=true&filters='.$filterToString.'&keyword='.$keyword;
|
||||
|
||||
// Column config
|
||||
$extraParams = [
|
||||
'autowidth' => 'true',
|
||||
'height' => 'auto',
|
||||
];
|
||||
|
||||
/*$extraParams['postData'] = [
|
||||
'filters' => [
|
||||
'groupOp' => 'AND',
|
||||
'rules' => $result['rules'],
|
||||
],
|
||||
];*/
|
||||
|
||||
$urlAjaxExtraField = api_get_path(WEB_AJAX_PATH).'extra_field.ajax.php?1=1';
|
||||
$allowOrder = api_get_configuration_value('session_list_order');
|
||||
$orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
|
||||
|
||||
?>
|
||||
<script>
|
||||
function setSearchSelect(columnName) {
|
||||
$("#sessions").jqGrid('setColProp', columnName, {
|
||||
});
|
||||
}
|
||||
var added_cols = [];
|
||||
var original_cols = [];
|
||||
function clean_cols(grid, added_cols) {
|
||||
// Cleaning
|
||||
for (key in added_cols) {
|
||||
grid.hideCol(key);
|
||||
}
|
||||
grid.showCol('name');
|
||||
grid.showCol('display_start_date');
|
||||
grid.showCol('display_end_date');
|
||||
grid.showCol('course_title');
|
||||
}
|
||||
|
||||
function show_cols(grid, added_cols) {
|
||||
grid.showCol('name').trigger('reloadGrid');
|
||||
for (key in added_cols) {
|
||||
grid.showCol(key);
|
||||
}
|
||||
}
|
||||
|
||||
var second_filters = [];
|
||||
|
||||
$(function() {
|
||||
date_pick_today = function(elem) {
|
||||
$(elem).datetimepicker({dateFormat: "yy-mm-dd"});
|
||||
$(elem).datetimepicker('setDate', (new Date()));
|
||||
}
|
||||
date_pick_one_month = function(elem) {
|
||||
$(elem).datetimepicker({dateFormat: "yy-mm-dd"});
|
||||
next_month = Date.today().next().month();
|
||||
$(elem).datetimepicker('setDate', next_month);
|
||||
}
|
||||
|
||||
// Great hack
|
||||
register_second_select = function(elem) {
|
||||
second_filters[$(elem).val()] = $(elem);
|
||||
}
|
||||
|
||||
fill_second_select = function(elem) {
|
||||
$(elem).on("change", function() {
|
||||
composed_id = $(this).val();
|
||||
field_id = composed_id.split("#")[0];
|
||||
id = composed_id.split("#")[1];
|
||||
$.ajax({
|
||||
url: "<?php echo $urlAjaxExtraField; ?>&a=get_second_select_options",
|
||||
dataType: "json",
|
||||
data: "type=session&field_id="+field_id+"&option_value_id="+id,
|
||||
success: function(data) {
|
||||
my_select = second_filters[field_id];
|
||||
my_select.empty();
|
||||
$.each(data, function(index, value) {
|
||||
my_select.append($("<option/>", {
|
||||
value: index,
|
||||
text: value
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
<?php
|
||||
echo Display::grid_js(
|
||||
'sessions',
|
||||
$url,
|
||||
$columns,
|
||||
$columnModel,
|
||||
$extraParams,
|
||||
[],
|
||||
null,
|
||||
true
|
||||
);
|
||||
?>
|
||||
|
||||
setSearchSelect("status");
|
||||
|
||||
var grid = $("#sessions"),
|
||||
prmSearch = {
|
||||
multipleSearch : true,
|
||||
overlay : false,
|
||||
width: 'auto',
|
||||
caption: '<?php echo addslashes(get_lang('Search')); ?>',
|
||||
formclass:'data_table',
|
||||
onSearch : function() {
|
||||
var postdata = grid.jqGrid('getGridParam', 'postData');
|
||||
if (postdata && postdata.filters) {
|
||||
filters = jQuery.parseJSON(postdata.filters);
|
||||
clean_cols(grid, added_cols);
|
||||
added_cols = [];
|
||||
$.each(filters, function(key, value) {
|
||||
if (key == 'rules') {
|
||||
$.each(value, function(subkey, subvalue) {
|
||||
added_cols[subvalue.field] = subvalue.field;
|
||||
});
|
||||
}
|
||||
});
|
||||
show_cols(grid, added_cols);
|
||||
}
|
||||
},
|
||||
onReset: function() {
|
||||
clean_cols(grid, added_cols);
|
||||
}
|
||||
};
|
||||
|
||||
original_cols = grid.jqGrid('getGridParam', 'colModel');
|
||||
|
||||
grid.jqGrid('navGrid','#sessions_pager',
|
||||
{edit:false,add:false,del:false},
|
||||
{height:280,reloadAfterSubmit:false}, // edit options
|
||||
{height:280,reloadAfterSubmit:false}, // add options
|
||||
{reloadAfterSubmit:false},// del options
|
||||
prmSearch
|
||||
);
|
||||
|
||||
<?php
|
||||
// Create the searching dialog.
|
||||
//echo 'grid.searchGrid(prmSearch);';
|
||||
?>
|
||||
// Fixes search table.
|
||||
var searchDialogAll = $("#fbox_"+grid[0].id);
|
||||
searchDialogAll.addClass("table");
|
||||
var searchDialog = $("#searchmodfbox_"+grid[0].id);
|
||||
searchDialog.addClass("ui-jqgrid ui-widget ui-widget-content ui-corner-all");
|
||||
searchDialog.css({position:"adsolute", "z-index":"100", "float":"left", "top":"55%", "left" : "25%", "padding" : "5px", "border": "1px solid #CCC"})
|
||||
var gbox = $("#gbox_"+grid[0].id);
|
||||
gbox.before(searchDialog);
|
||||
gbox.css({clear:"left"});
|
||||
|
||||
// Select first elements by default
|
||||
$('.input-elm').each(function() {
|
||||
$(this).find('option:first').attr('selected', 'selected');
|
||||
});
|
||||
|
||||
$('.delete-rule').each(function(){
|
||||
$(this).click(function(){
|
||||
$('.input-elm').each(function(){
|
||||
$(this).find('option:first').attr('selected', 'selected');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
||||
$form->display();
|
||||
echo Display::grid_html('sessions');
|
||||
Display::display_footer();
|
||||
287
main/mySpace/session_admin_teachers.php
Normal file
287
main/mySpace/session_admin_teachers.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Teacher report.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$nameTools = get_lang('Teachers');
|
||||
$this_section = SECTION_TRACKING;
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
|
||||
if (isset($_GET['user_id']) && '' != $_GET['user_id'] && !isset($_GET['type'])) {
|
||||
$interbreadcrumb[] = ['url' => 'teachers.php', 'name' => get_lang('Teachers')];
|
||||
}
|
||||
|
||||
if (isset($_GET['user_id']) && '' != $_GET['user_id'] && isset($_GET['type']) && 'coach' === $_GET['type']) {
|
||||
$interbreadcrumb[] = ['url' => 'coaches.php', 'name' => get_lang('Tutors')];
|
||||
}
|
||||
|
||||
function get_count_users()
|
||||
{
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$sessions = SessionManager::getSessionsForAdmin(api_get_user_id(), [], false, [], 'all');
|
||||
$coachesList = [];
|
||||
$students = [];
|
||||
|
||||
foreach ($sessions as $session) {
|
||||
$sessionId = $session['id'];
|
||||
$courseList = SessionManager::getCoursesInSession($sessionId);
|
||||
if (!empty($courseList)) {
|
||||
foreach ($courseList as $courseId) {
|
||||
$coaches = CourseManager::get_coachs_from_course($sessionId, $courseId);
|
||||
foreach ($coaches as $coach) {
|
||||
if (!empty($keyword)) {
|
||||
if (false === stripos($coach['full_name'], $keyword)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array($coach['user_id'], $coachesList)) {
|
||||
$coachesList[] = $coach['user_id'];
|
||||
$students[] = $coach;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count($students);
|
||||
}
|
||||
|
||||
function get_users($from, $limit, $column, $direction)
|
||||
{
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
|
||||
|
||||
$is_western_name_order = api_is_western_name_order();
|
||||
$coach_id = api_get_user_id();
|
||||
|
||||
$sessions = SessionManager::getSessionsForAdmin(api_get_user_id(), [], false, [], 'all');
|
||||
$coachesList = [];
|
||||
$students = [];
|
||||
|
||||
foreach ($sessions as $session) {
|
||||
$sessionId = $session['id'];
|
||||
$courseList = SessionManager::getCoursesInSession($sessionId);
|
||||
$courses = [];
|
||||
if (!empty($courseList)) {
|
||||
foreach ($courseList as $courseId) {
|
||||
$coaches = CourseManager::get_coachs_from_course($sessionId, $courseId);
|
||||
foreach ($coaches as $coach) {
|
||||
if (!empty($keyword)) {
|
||||
if (false === stripos($coach['full_name'], $keyword)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array($coach['user_id'], $coachesList)) {
|
||||
$coachesList[] = $coach['user_id'];
|
||||
$students[] = $coach;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$all_datas = [];
|
||||
$url = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php';
|
||||
foreach ($students as $student_data) {
|
||||
$student_id = $student_data['user_id'];
|
||||
$student_data = api_get_user_info($student_id);
|
||||
if (isset($_GET['id_session'])) {
|
||||
$courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']);
|
||||
}
|
||||
|
||||
$avg_time_spent = $avg_student_score = $avg_student_progress = 0;
|
||||
$nb_courses_student = 0;
|
||||
if (!empty($courses)) {
|
||||
foreach ($courses as $course_code) {
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
|
||||
$avg_time_spent += Tracking::get_time_spent_on_the_course(
|
||||
$student_id,
|
||||
$courseId,
|
||||
$_GET['id_session']
|
||||
);
|
||||
$my_average = Tracking::get_avg_student_score($student_id, $course_code);
|
||||
if (is_numeric($my_average)) {
|
||||
$avg_student_score += $my_average;
|
||||
}
|
||||
$avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
|
||||
$nb_courses_student++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nb_courses_student > 0) {
|
||||
$avg_time_spent = $avg_time_spent / $nb_courses_student;
|
||||
$avg_student_score = $avg_student_score / $nb_courses_student;
|
||||
$avg_student_progress = $avg_student_progress / $nb_courses_student;
|
||||
} else {
|
||||
$avg_time_spent = null;
|
||||
$avg_student_score = null;
|
||||
$avg_student_progress = null;
|
||||
}
|
||||
|
||||
$urlDetails = $url."?student=$student_id&origin=teacher_details";
|
||||
if (isset($_GET['id_coach']) && 0 != intval($_GET['id_coach'])) {
|
||||
$urlDetails = $url."?student=$student_id&id_coach=$coach_id&id_session=$sessionId";
|
||||
}
|
||||
|
||||
$row = [];
|
||||
if ($is_western_name_order) {
|
||||
$row[] = Display::url($student_data['firstname'], $urlDetails);
|
||||
$row[] = Display::url($student_data['lastname'], $urlDetails);
|
||||
} else {
|
||||
$row[] = $student_data['lastname'];
|
||||
$row[] = $student_data['firstname'];
|
||||
}
|
||||
$string_date = Tracking::get_last_connection_date($student_id, true);
|
||||
$first_date = Tracking::get_first_connection_date($student_id);
|
||||
$row[] = $first_date;
|
||||
$row[] = $string_date;
|
||||
|
||||
$detailsLink = Display::url(
|
||||
Display::return_icon('2rightarrow.png', get_lang('Details').' '.$student_data['username']),
|
||||
$urlDetails,
|
||||
['id' => 'details_'.$student_data['username']]
|
||||
);
|
||||
$row[] = $detailsLink;
|
||||
$all_datas[] = $row;
|
||||
}
|
||||
|
||||
return $all_datas;
|
||||
}
|
||||
|
||||
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();
|
||||
$actionsLeft = '';
|
||||
if (api_is_drh()) {
|
||||
$menu_items = [
|
||||
Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
|
||||
),
|
||||
Display::url(Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM), 'student.php'),
|
||||
Display::url(
|
||||
Display::return_icon('teacher_na.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
),
|
||||
Display::url(Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM), 'course.php'),
|
||||
Display::url(
|
||||
Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
'session.php'
|
||||
),
|
||||
];
|
||||
|
||||
$nb_menu_items = count($menu_items);
|
||||
if ($nb_menu_items > 1) {
|
||||
foreach ($menu_items as $key => $item) {
|
||||
$actionsLeft .= $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$actionsRight = Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), [], ICON_SIZE_MEDIUM),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print();']
|
||||
);
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?export=csv&keyword='.$keyword
|
||||
);
|
||||
|
||||
$toolbar = Display::toolbarAction('toolbar-teachers', [$actionsLeft, $actionsRight]);
|
||||
|
||||
$table = new SortableTable(
|
||||
'tracking_teachers',
|
||||
'get_count_users',
|
||||
'get_users',
|
||||
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
|
||||
10
|
||||
);
|
||||
|
||||
$params = [
|
||||
'keyword' => $keyword,
|
||||
'active' => $active,
|
||||
'sleeping_days' => $sleepingDays,
|
||||
];
|
||||
$table->set_additional_parameters($params);
|
||||
|
||||
if ($is_western_name_order) {
|
||||
$table->set_header(0, get_lang('FirstName'), false);
|
||||
$table->set_header(1, get_lang('LastName'), false);
|
||||
} else {
|
||||
$table->set_header(0, get_lang('LastName'), false);
|
||||
$table->set_header(1, get_lang('FirstName'), false);
|
||||
}
|
||||
|
||||
$table->set_header(2, get_lang('FirstLogin'), false);
|
||||
$table->set_header(3, get_lang('LastConnexion'), false);
|
||||
$table->set_header(4, get_lang('Details'), false);
|
||||
|
||||
if ($export_csv) {
|
||||
if ($is_western_name_order) {
|
||||
$csv_header[] = [
|
||||
get_lang('FirstName'),
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
} else {
|
||||
$csv_header[] = [
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH).'mySpace/session_admin_teachers.php');
|
||||
$form->addElement('text', 'keyword', get_lang('Keyword'));
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
|
||||
if ($export_csv) {
|
||||
// send the csv file if asked
|
||||
$content = $table->get_table_data();
|
||||
foreach ($content as &$row) {
|
||||
$row[3] = strip_tags($row[3]);
|
||||
unset($row[4]);
|
||||
}
|
||||
$csv_content = array_merge($csv_header, $content);
|
||||
ob_end_clean();
|
||||
Export::arrayToCsv($csv_content, 'reporting_teacher_list');
|
||||
exit;
|
||||
} else {
|
||||
Display::display_header($nameTools);
|
||||
echo $toolbar;
|
||||
$page_title = get_lang('Teachers');
|
||||
echo Display::page_subheader($page_title);
|
||||
$form->display();
|
||||
$table->display();
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
421
main/mySpace/session_filter.php
Normal file
421
main/mySpace/session_filter.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Report for current courses followed by the user.
|
||||
*/
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
if (!api_is_allowed_to_create_course() && !api_is_drh()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$allowCustomCertificate = 'true' === api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate');
|
||||
$plugin = CustomCertificatePlugin::create();
|
||||
|
||||
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
|
||||
$tblSession = Database::get_main_table(TABLE_MAIN_SESSION);
|
||||
$tblSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
|
||||
$tblSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
|
||||
|
||||
define('NO_DATE_FILTER', 0);
|
||||
define('DATE_BEGIN_FILTER', 1);
|
||||
define('DATE_END_FILTER', 2);
|
||||
define('ALL_DATE_FILTER', 3);
|
||||
|
||||
$certificateList = [];
|
||||
$urlParam = '';
|
||||
$form = new FormValidator('search_user', 'GET', api_get_self());
|
||||
$innerJoinSessionRelUser = '';
|
||||
$whereCondictionDRH = '';
|
||||
$whereCondictionMultiUrl = '';
|
||||
if (api_is_drh()) {
|
||||
$innerJoinSessionRelUser = "INNER JOIN $tblSessionRelUser as session_rel_user
|
||||
ON (s.id = session_rel_user.session_id)";
|
||||
$whereCondictionDRH = "WHERE session_rel_user.user_id = ".api_get_user_id();
|
||||
$whereCondictionMultiUrl = " AND session_rel_user.user_id = ".api_get_user_id();
|
||||
}
|
||||
|
||||
// Select of sessions.
|
||||
$sql = "SELECT s.id, name FROM $tblSession s
|
||||
$innerJoinSessionRelUser
|
||||
$whereCondictionDRH
|
||||
ORDER BY name";
|
||||
|
||||
if (api_is_multiple_url_enabled()) {
|
||||
$tblSessionRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
|
||||
$accessUrlId = api_get_current_access_url_id();
|
||||
if ($accessUrlId != -1) {
|
||||
$sql = "SELECT s.id, name FROM $tblSession s
|
||||
INNER JOIN $tblSessionRelAccessUrl as session_rel_url
|
||||
ON (s.id = session_rel_url.session_id)
|
||||
$innerJoinSessionRelUser
|
||||
WHERE access_url_id = $accessUrlId
|
||||
$whereCondictionMultiUrl
|
||||
ORDER BY name";
|
||||
}
|
||||
}
|
||||
$result = Database::query($sql);
|
||||
$Sessions = Database::store_result($result);
|
||||
$options = [];
|
||||
$options['0'] = '';
|
||||
foreach ($Sessions as $enreg) {
|
||||
$options[$enreg['id']] = $enreg['name'];
|
||||
}
|
||||
|
||||
$form->addElement('select', 'session_id', get_lang('SessionList'), $options, ['id' => 'session-id']);
|
||||
$form->addDatePicker('date_begin', get_lang('DateStart'), ['id' => 'date-begin']);
|
||||
$form->addDatePicker('date_end', get_lang('DateEnd'), ['id' => 'date-end']);
|
||||
|
||||
// EXTRA FIELDS
|
||||
$extraField = new ExtraField('user');
|
||||
$returnParams = $extraField->addElements(
|
||||
$form,
|
||||
0,
|
||||
[],
|
||||
true,
|
||||
false,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$form->addElement('hidden', 'formSent', 1);
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
$form->addButtonExport(get_lang('ExportAsCSV'), 'export');
|
||||
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
$exportToCsv = isset($values['export']);
|
||||
$sessionId = (int) $_REQUEST['session_id'];
|
||||
$dateBegin = isset($_REQUEST['date_begin']) ? strtotime($_REQUEST['date_begin']) : null;
|
||||
$dateEnd = isset($_REQUEST['date_end']) ? strtotime($_REQUEST['date_end'].' 23:59:59') : null;
|
||||
|
||||
$filterDate = 0;
|
||||
if (!empty($dateBegin)) {
|
||||
$filterDate += DATE_BEGIN_FILTER;
|
||||
}
|
||||
if (!empty($dateEnd)) {
|
||||
$filterDate += DATE_END_FILTER;
|
||||
}
|
||||
|
||||
$filterCheckList = [];
|
||||
$extraField = new ExtraField('user');
|
||||
$extraFieldsAll = $extraField->get_all(['filter = ?' => 1], 'option_order');
|
||||
foreach ($extraFieldsAll as $field) {
|
||||
if (!empty($_REQUEST['extra_'.$field['variable']])) {
|
||||
$filterCheckList[$field['id']] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
$result = Database::select(
|
||||
'c.id, c.code',
|
||||
"$tbl_course c INNER JOIN $tblSessionRelCourse r ON c.id = r.c_id",
|
||||
[
|
||||
'where' => [
|
||||
"r.session_id = ? " => [$sessionId],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($result as $value) {
|
||||
$courseId = $value['id'];
|
||||
$courseCode = $value['code'];
|
||||
|
||||
$cats = Category::load(
|
||||
null,
|
||||
null,
|
||||
$courseCode,
|
||||
null,
|
||||
null,
|
||||
$sessionId,
|
||||
'ORDER BY id'
|
||||
);
|
||||
|
||||
if (empty($cats)) {
|
||||
// first time
|
||||
$cats = Category::load(
|
||||
0,
|
||||
null,
|
||||
$courseCode,
|
||||
null,
|
||||
null,
|
||||
$sessionId,
|
||||
'ORDER BY id'
|
||||
);
|
||||
}
|
||||
|
||||
$selectCat = (int) $cats[0]->get_id();
|
||||
$certificateListAux = [];
|
||||
if (!empty($selectCat)) {
|
||||
$certificateListAux = GradebookUtils::get_list_users_certificates($selectCat);
|
||||
}
|
||||
|
||||
foreach ($certificateListAux as $value) {
|
||||
$createdAt = strtotime(api_get_local_time($value['created_at']));
|
||||
$value['category_id'] = $selectCat;
|
||||
$value['c_id'] = $courseId;
|
||||
$value['course_code'] = $courseCode;
|
||||
switch ($filterDate) {
|
||||
case NO_DATE_FILTER:
|
||||
$certificateList[] = $value;
|
||||
break;
|
||||
case DATE_BEGIN_FILTER:
|
||||
if ($createdAt >= $dateBegin) {
|
||||
$certificateList[] = $value;
|
||||
}
|
||||
break;
|
||||
case DATE_END_FILTER:
|
||||
if ($createdAt <= $dateEnd) {
|
||||
$certificateList[] = $value;
|
||||
}
|
||||
break;
|
||||
case ALL_DATE_FILTER:
|
||||
if ($createdAt >= $dateBegin && $createdAt <= $dateEnd) {
|
||||
$certificateList[] = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Filter extra field
|
||||
foreach ($certificateList as $key => $value) {
|
||||
foreach ($filterCheckList as $fieldId => $field) {
|
||||
$extraFieldValue = new ExtraFieldValue('user');
|
||||
$extraFieldValueData = $extraFieldValue->get_values_by_handler_and_field_id(
|
||||
$value['user_id'],
|
||||
$fieldId
|
||||
);
|
||||
|
||||
if (empty($extraFieldValueData)) {
|
||||
unset($certificateList[$key]);
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($field['field_type']) {
|
||||
case ExtraField::FIELD_TYPE_TEXT:
|
||||
case ExtraField::FIELD_TYPE_ALPHANUMERIC:
|
||||
$pos = stripos($extraFieldValueData['value'], $_REQUEST['extra_'.$field['variable']]);
|
||||
if ($pos === false) {
|
||||
unset($certificateList[$key]);
|
||||
}
|
||||
break;
|
||||
case ExtraField::FIELD_TYPE_RADIO:
|
||||
$valueRadio = $_REQUEST['extra_'.$field['variable']]['extra_'.$field['variable']];
|
||||
if ($extraFieldValueData['value'] != $valueRadio) {
|
||||
unset($certificateList[$key]);
|
||||
}
|
||||
break;
|
||||
case ExtraField::FIELD_TYPE_SELECT:
|
||||
if ($extraFieldValueData['value'] != $_REQUEST['extra_'.$field['variable']]) {
|
||||
unset($certificateList[$key]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$params = [
|
||||
'session_id' => (int) $_REQUEST['session_id'],
|
||||
'date_begin' => Security::remove_XSS($_REQUEST['date_begin']),
|
||||
'date_end' => Security::remove_XSS($_REQUEST['date_end']),
|
||||
];
|
||||
|
||||
foreach ($filterCheckList as $field) {
|
||||
$params['extra_'.$field['variable']] = Security::remove_XSS($_REQUEST['extra_'.$field['variable']]);
|
||||
}
|
||||
$urlParam = http_build_query($params);
|
||||
|
||||
$dataToExport = [];
|
||||
if ($exportToCsv) {
|
||||
$headers = [
|
||||
get_lang('Session'),
|
||||
get_lang('Course'),
|
||||
get_lang('FirstName'),
|
||||
get_lang('LastName'),
|
||||
get_lang('Score'),
|
||||
get_lang('Date'),
|
||||
];
|
||||
|
||||
$extraField = new ExtraField('user');
|
||||
foreach ($extraFieldsAll as $field) {
|
||||
$headers[] = $field['display_text'];
|
||||
}
|
||||
$dataToExport[] = $headers;
|
||||
|
||||
$sessionInfo = api_get_session_info($sessionId);
|
||||
foreach ($certificateList as $index => $value) {
|
||||
$categoryId = $value['category_id'];
|
||||
$courseCode = $value['course_code'];
|
||||
$courseInfo = api_get_course_info($courseCode);
|
||||
$extraFields = [];
|
||||
foreach ($extraFieldsAll as $field) {
|
||||
$extraFieldValue = new ExtraFieldValue('user');
|
||||
$extraFieldValueData = $extraFieldValue->get_values_by_handler_and_field_id(
|
||||
$value['user_id'],
|
||||
$field['id']
|
||||
);
|
||||
$fieldValue = isset($extraFieldValueData['value']) ? $extraFieldValueData['value'] : '';
|
||||
if ('true' === $fieldValue) {
|
||||
$fieldValue = get_lang('Yes');
|
||||
}
|
||||
if ('false' === $fieldValue) {
|
||||
$fieldValue = get_lang('No');
|
||||
}
|
||||
$extraFields[] = $fieldValue;
|
||||
}
|
||||
|
||||
$list = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $categoryId);
|
||||
foreach ($list as $valueCertificate) {
|
||||
$item = [];
|
||||
$item[] = $sessionInfo['name'];
|
||||
$item[] = $courseInfo['title'];
|
||||
$item[] = $value['firstname'];
|
||||
$item[] = $value['lastname'];
|
||||
$item[] = $valueCertificate['score_certificate'];
|
||||
$item[] = api_get_local_time($valueCertificate['created_at']);
|
||||
$item = array_merge($item, $extraFields);
|
||||
$dataToExport[] = $item;
|
||||
}
|
||||
}
|
||||
Export::arrayToCsv($dataToExport, 'export');
|
||||
}
|
||||
}
|
||||
|
||||
$htmlHeadXtra[] = "<script>
|
||||
$(function () {
|
||||
$('#export_pdf').click(function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var session_id = $('#session-id').val();
|
||||
var date_begin = $('#date-begin').val();
|
||||
var date_end = $('#date-end').val();
|
||||
|
||||
if (confirm('".$plugin->get_lang('OnlyCustomCertificates')."')) {
|
||||
var url = '".api_get_path(WEB_PLUGIN_PATH)."' +
|
||||
'customcertificate/src/export_pdf_all_in_one.php?' +
|
||||
'".$urlParam."&' +
|
||||
'export_pdf=1';
|
||||
|
||||
$(location).attr('href',url);
|
||||
}
|
||||
});
|
||||
|
||||
$('#export_zip').click(function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var session_id = $('#session-id').val();
|
||||
var date_begin = $('#date-begin').val();
|
||||
var date_end = $('#date-end').val();
|
||||
if (confirm('".$plugin->get_lang('OnlyCustomCertificates')."')) {
|
||||
var url = '".api_get_path(WEB_PLUGIN_PATH)."' +
|
||||
'customcertificate/src/export_pdf_all_in_one.php?' +
|
||||
'".$urlParam."&' +
|
||||
'export_zip=1';
|
||||
|
||||
$(location).attr('href',url);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>";
|
||||
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
Display::display_header(get_lang('CertificatesSessions'));
|
||||
echo Display::page_header(get_lang('CertificatesSessions'));
|
||||
$actions = '';
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('back.png', get_lang('Back'), [], 32),
|
||||
api_get_path(WEB_CODE_PATH).'mySpace'
|
||||
);
|
||||
|
||||
if ($allowCustomCertificate) {
|
||||
$url = api_get_path(WEB_PLUGIN_PATH).'customcertificate/src/export_pdf_all_in_one.php';
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('pdf.png', get_lang('ExportAllCertificatesToPDF'), [], ICON_SIZE_MEDIUM),
|
||||
$url,
|
||||
['id' => 'export_pdf']
|
||||
);
|
||||
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('file_zip.png', get_lang('ExportAllCertificatesToZIP'), [], ICON_SIZE_MEDIUM),
|
||||
$url,
|
||||
['id' => 'export_zip']
|
||||
);
|
||||
}
|
||||
|
||||
echo Display::toolbarAction('actions', [$actions]);
|
||||
echo $form->returnForm();
|
||||
|
||||
if (0 == count($certificateList)) {
|
||||
echo Display::return_message(get_lang('NoResultsAvailable'), 'warning');
|
||||
} else {
|
||||
echo '<table class="table table-hover table-striped data_table">';
|
||||
echo '<tbody>';
|
||||
foreach ($certificateList as $index => $value) {
|
||||
$categoryId = $value['category_id'];
|
||||
$courseCode = $value['course_code'];
|
||||
$courseInfo = api_get_course_info($courseCode);
|
||||
echo '<tr>';
|
||||
echo '<td width="50%" class="actions">';
|
||||
echo get_lang('Student').' : ';
|
||||
echo api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].')';
|
||||
echo '</td>';
|
||||
echo '<td width="50%" class="actions">'.$courseInfo['title'].'</td>';
|
||||
echo '</tr>';
|
||||
echo '<tr><td colspan="2">
|
||||
<table class="table table-hover table-striped data_table">
|
||||
<tbody>';
|
||||
|
||||
$list = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $categoryId);
|
||||
foreach ($list as $valueCertificate) {
|
||||
echo '<tr>';
|
||||
echo '<td width="50%">'.get_lang('Score').' : '.$valueCertificate['score_certificate'].'</td>';
|
||||
echo '<td width="30%">';
|
||||
echo get_lang('Date').' : '.api_convert_and_format_date($valueCertificate['created_at']);
|
||||
echo '</td>';
|
||||
echo '<td width="20%">';
|
||||
$url = api_get_path(WEB_PATH).'certificates/index.php?'.
|
||||
'id='.$valueCertificate['id'].
|
||||
'&user_id='.$value['user_id'];
|
||||
$certificateUrl = Display::url(
|
||||
get_lang('Certificate'),
|
||||
$url,
|
||||
['target' => '_blank', 'class' => 'btn btn-default']
|
||||
);
|
||||
echo $certificateUrl.PHP_EOL;
|
||||
|
||||
$url .= '&action=export';
|
||||
$pdf = Display::url(
|
||||
Display::return_icon('pdf.png', get_lang('Download')),
|
||||
$url,
|
||||
['target' => '_blank']
|
||||
);
|
||||
echo $pdf.PHP_EOL;
|
||||
|
||||
echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?'.
|
||||
'sec_token='.$token.
|
||||
'&'.api_get_cidreq().
|
||||
'&action=delete'.
|
||||
'&cat_id='.$categoryId.
|
||||
'&certificate_id='.$valueCertificate['id'].'">
|
||||
'.Display::return_icon('delete.png', get_lang('Delete')).'
|
||||
</a>'.PHP_EOL;
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
55
main/mySpace/slider.css
Normal file
55
main/mySpace/slider.css
Normal file
@@ -0,0 +1,55 @@
|
||||
div#cev_cont_results {
|
||||
margin: 0;
|
||||
padding-right:18px;
|
||||
}
|
||||
div#cev_cont_header
|
||||
{
|
||||
margin: 0;
|
||||
padding-left:18px;
|
||||
padding-right:18px;
|
||||
}
|
||||
div#cev_cont_stats
|
||||
{
|
||||
margin: 0;
|
||||
padding-left:18px;
|
||||
padding-right:18px;
|
||||
}
|
||||
div.slider
|
||||
{
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
div#cev_cont .ui-tabs-nav .ui-helper-reset .ui-helper-clearfix .ui-widget-header .ui-corner-all
|
||||
{
|
||||
margin: 0;
|
||||
padding-left:18px;
|
||||
padding-right:18px;
|
||||
}
|
||||
|
||||
div.slider_menu a
|
||||
{
|
||||
color: #3757F7;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not required, for styling only
|
||||
*/
|
||||
|
||||
div#slider_wrapper
|
||||
{
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
div.title
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.slider p
|
||||
{
|
||||
padding: 0 0 1em 0;
|
||||
margin: 0;
|
||||
}
|
||||
43
main/mySpace/slider.js
Normal file
43
main/mySpace/slider.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// Set the initial height
|
||||
var sliderHeight = "80px";
|
||||
|
||||
// Set the initial slider state
|
||||
var slider_state = "close";
|
||||
|
||||
function sliderAction()
|
||||
{
|
||||
if (slider_state == "close") {
|
||||
sliderOpen();
|
||||
slider_state = "open"
|
||||
$(".slider_menu").html('<a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_out.png"></a>');
|
||||
} else if (slider_state == "open") {
|
||||
sliderClose();
|
||||
slider_state = "close";
|
||||
$(".slider_menu").html('<a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_in.png"></a>');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function sliderOpen()
|
||||
{
|
||||
var open_height = $(".slider").attr("box_h") + "px";
|
||||
$(".slider").animate({"height": open_height}, {duration: "slow" });
|
||||
}
|
||||
|
||||
function sliderClose()
|
||||
{
|
||||
$(".slider").animate({"height": "0px"}, {duration: "fast" });
|
||||
$(".slider").animate({"height": sliderHeight}, {duration: "fast" });
|
||||
}
|
||||
|
||||
$(function() {
|
||||
// Show the slider content
|
||||
$('.slider').show();
|
||||
$('.slider').each(function () {
|
||||
var current = $(this);
|
||||
current.attr("box_h", current.height());
|
||||
});
|
||||
|
||||
$(".slider").css("height", sliderHeight);
|
||||
});
|
||||
513
main/mySpace/student.php
Normal file
513
main/mySpace/student.php
Normal file
@@ -0,0 +1,513 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Report on students subscribed to courses I am teaching.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) ||
|
||||
api_is_teacher() ||
|
||||
api_is_student_boss();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$nameTools = get_lang('Students');
|
||||
|
||||
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'];
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$active = isset($_GET['active']) ? (int) $_GET['active'] : 1;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? (int) $_GET['sleeping_days'] : null;
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$webCodePath = api_get_path(WEB_CODE_PATH);
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_is_student_boss() ? '#' : 'index.php',
|
||||
'name' => get_lang('MySpace'),
|
||||
];
|
||||
|
||||
if (isset($_GET['user_id']) && '' != $_GET['user_id'] && !isset($_GET['type'])) {
|
||||
$interbreadcrumb[] = [
|
||||
'url' => 'teachers.php',
|
||||
'name' => get_lang('Teachers'),
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($_GET['user_id']) && '' != $_GET['user_id'] && isset($_GET['type']) && 'coach' === $_GET['type']) {
|
||||
$interbreadcrumb[] = ['url' => 'coaches.php', 'name' => get_lang('Tutors')];
|
||||
}
|
||||
|
||||
function get_count_users(): int
|
||||
{
|
||||
$users = get_users(null, null, 0, 3, true);
|
||||
|
||||
return $users['count_users'];
|
||||
}
|
||||
|
||||
function get_users($from, $limit, $column = 0, $direction = 3, $getCount = false): array
|
||||
{
|
||||
global $export_csv;
|
||||
$active = $_GET['active'] ?? 1;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? (int) $_GET['sleeping_days'] : null;
|
||||
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
|
||||
|
||||
$webCodePath = api_get_path(WEB_CODE_PATH);
|
||||
|
||||
$lastConnectionDate = null;
|
||||
if (!empty($sleepingDays)) {
|
||||
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
|
||||
}
|
||||
|
||||
// Filter by Extra Fields
|
||||
$useExtraFields = false;
|
||||
$extraFieldResult = [];
|
||||
foreach ($_GET as $key => $value) {
|
||||
if (substr($key, 0, 6) == 'extra_') {
|
||||
$variable = substr($key, 6);
|
||||
if (UserManager::is_extra_field_available($variable) && !empty($value)) {
|
||||
if (is_array($value)) {
|
||||
$value = $value[$key];
|
||||
}
|
||||
$useExtraFields = true;
|
||||
$extraFieldResult[] = UserManager::get_extra_user_data_by_value(
|
||||
$variable,
|
||||
$value,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$filterUsers = [];
|
||||
if ($useExtraFields) {
|
||||
if (count($extraFieldResult) > 1) {
|
||||
for ($i = 0; $i < count($extraFieldResult) - 1; $i++) {
|
||||
if (is_array($extraFieldResult[$i + 1])) {
|
||||
$filterUsers = array_intersect($extraFieldResult[$i], $extraFieldResult[$i + 1]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$filterUsers = $extraFieldResult[0];
|
||||
}
|
||||
}
|
||||
|
||||
$is_western_name_order = api_is_western_name_order();
|
||||
$coach_id = api_get_user_id();
|
||||
$column = 'u.user_id';
|
||||
$drhLoaded = false;
|
||||
$students = [];
|
||||
|
||||
if (api_is_drh()) {
|
||||
if (api_drh_can_access_all_session_content()) {
|
||||
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
|
||||
'drh_all',
|
||||
api_get_user_id(),
|
||||
$getCount,
|
||||
$from,
|
||||
$limit,
|
||||
$column,
|
||||
$direction,
|
||||
$keyword,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
null,
|
||||
null,
|
||||
api_is_student_boss() ? null : STUDENT,
|
||||
$filterUsers
|
||||
);
|
||||
$drhLoaded = true;
|
||||
}
|
||||
$allowDhrAccessToAllStudents = api_get_configuration_value('drh_allow_access_to_all_students');
|
||||
if ($allowDhrAccessToAllStudents) {
|
||||
$conditions = ['status' => STUDENT];
|
||||
if (isset($active)) {
|
||||
$conditions['active'] = (int) $active;
|
||||
}
|
||||
$students = UserManager::get_user_list(
|
||||
$conditions,
|
||||
[],
|
||||
$from,
|
||||
$limit,
|
||||
null,
|
||||
$keyword,
|
||||
$lastConnectionDate,
|
||||
$getCount,
|
||||
$filterUsers
|
||||
);
|
||||
$drhLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
$checkSessionVisibility = api_get_configuration_value('show_users_in_active_sessions_in_tracking');
|
||||
if (false === $drhLoaded) {
|
||||
$students = UserManager::getUsersFollowedByUser(
|
||||
api_get_user_id(),
|
||||
api_is_student_boss() ? null : STUDENT,
|
||||
false,
|
||||
false,
|
||||
$getCount,
|
||||
$from,
|
||||
$limit,
|
||||
$column,
|
||||
$direction,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER,
|
||||
$keyword,
|
||||
$checkSessionVisibility,
|
||||
$filterUsers
|
||||
);
|
||||
}
|
||||
|
||||
if ($getCount) {
|
||||
return ['count_users' => (int) $students];
|
||||
}
|
||||
|
||||
$url = $webCodePath.'mySpace/myStudents.php';
|
||||
|
||||
$all_datas = [];
|
||||
foreach ($students as $student_data) {
|
||||
$student_id = $student_data['user_id'];
|
||||
$student_data = api_get_user_info($student_id);
|
||||
|
||||
if (isset($_GET['id_session'])) {
|
||||
$courses = Tracking::get_course_list_in_session_from_student($student_id, $sessionId);
|
||||
}
|
||||
|
||||
$avg_time_spent = $avg_student_score = $avg_student_progress = 0;
|
||||
$nb_courses_student = 0;
|
||||
if (!empty($courses)) {
|
||||
foreach ($courses as $course_code) {
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
|
||||
if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
|
||||
$avg_time_spent += Tracking::get_time_spent_on_the_course(
|
||||
$student_id,
|
||||
$courseId,
|
||||
$_GET['id_session']
|
||||
);
|
||||
$my_average = Tracking::get_avg_student_score($student_id, $course_code);
|
||||
if (is_numeric($my_average)) {
|
||||
$avg_student_score += $my_average;
|
||||
}
|
||||
$avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
|
||||
$nb_courses_student++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nb_courses_student > 0) {
|
||||
$avg_time_spent = $avg_time_spent / $nb_courses_student;
|
||||
$avg_student_score = $avg_student_score / $nb_courses_student;
|
||||
$avg_student_progress = $avg_student_progress / $nb_courses_student;
|
||||
} else {
|
||||
$avg_time_spent = null;
|
||||
$avg_student_score = null;
|
||||
$avg_student_progress = null;
|
||||
}
|
||||
|
||||
$urlDetails = $url."?student=$student_id";
|
||||
if (isset($_GET['id_coach']) && 0 != intval($_GET['id_coach'])) {
|
||||
$urlDetails = $url."?student=$student_id&id_coach=$coach_id&id_session=$sessionId";
|
||||
}
|
||||
|
||||
$row = [];
|
||||
if (!$export_csv) {
|
||||
$row[] = $student_id;
|
||||
}
|
||||
if ($is_western_name_order) {
|
||||
$first = Display::url($student_data['firstname'], $urlDetails);
|
||||
$last = Display::url($student_data['lastname'], $urlDetails);
|
||||
} else {
|
||||
$first = Display::url($student_data['lastname'], $urlDetails);
|
||||
$last = Display::url($student_data['firstname'], $urlDetails);
|
||||
}
|
||||
|
||||
if ($export_csv) {
|
||||
$first = strip_tags($first);
|
||||
$last = strip_tags($last);
|
||||
}
|
||||
|
||||
$row[] = $first;
|
||||
$row[] = $last;
|
||||
|
||||
$string_date = Tracking::get_last_connection_date($student_id, !$export_csv);
|
||||
$first_date = Tracking::get_first_connection_date($student_id);
|
||||
$row[] = $first_date;
|
||||
$row[] = $string_date;
|
||||
|
||||
if (!$export_csv) {
|
||||
$detailsLink = Display::url(
|
||||
Display::return_icon('2rightarrow.png', get_lang('Details').' '.$student_data['username']),
|
||||
$urlDetails,
|
||||
['id' => 'details_'.$student_data['username']]
|
||||
);
|
||||
|
||||
$userIsFollowed = UserManager::is_user_followed_by_drh($student_id, api_get_user_id());
|
||||
$lostPasswordLink = '';
|
||||
if ((api_is_drh() && $userIsFollowed) || api_is_platform_admin()) {
|
||||
$lostPasswordLink = ' '.Display::url(
|
||||
Display::return_icon('edit.png', get_lang('Edit')),
|
||||
$webCodePath.'mySpace/user_edit.php?user_id='.$student_id
|
||||
);
|
||||
}
|
||||
|
||||
$row[] = $lostPasswordLink.$detailsLink;
|
||||
}
|
||||
$all_datas[] = $row;
|
||||
}
|
||||
|
||||
return $all_datas;
|
||||
}
|
||||
|
||||
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();
|
||||
$actionsLeft = '';
|
||||
|
||||
if (api_is_drh()) {
|
||||
$menu_items = [
|
||||
Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'auth/my_progress.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('user_na.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM),
|
||||
'course.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
'session.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('skills.png', get_lang('Skills'), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'social/my_skills_report.php'
|
||||
),
|
||||
];
|
||||
|
||||
$actionsLeft .= implode('', $menu_items);
|
||||
} elseif (api_is_student_boss()) {
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'auth/my_progress.php'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('user_na.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('skills.png', get_lang('Skills'), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'social/my_skills_report.php'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('CompanyReport'), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'mySpace/company_reports.php'
|
||||
);
|
||||
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('calendar-user.png', get_lang('MyStudentsSchedule'), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'mySpace/calendar_plan.php'
|
||||
);
|
||||
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon(
|
||||
'certificate_list.png',
|
||||
get_lang('GradebookSeeListOfStudentsCertificates'),
|
||||
[],
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
$webCodePath.'gradebook/certificate_report.php'
|
||||
);
|
||||
}
|
||||
|
||||
$actionsRight = Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), [], ICON_SIZE_MEDIUM),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print();']
|
||||
);
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?export=csv&keyword='.$keyword
|
||||
);
|
||||
|
||||
$toolbar = Display::toolbarAction('toolbar-student', [$actionsLeft, $actionsRight]);
|
||||
|
||||
$itemPerPage = 10;
|
||||
$perPage = api_get_configuration_value('my_space_users_items_per_page');
|
||||
if ($perPage) {
|
||||
$itemPerPage = (int) $perPage;
|
||||
}
|
||||
|
||||
$table = new SortableTable(
|
||||
'tracking_student',
|
||||
'get_count_users',
|
||||
'get_users',
|
||||
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
|
||||
$itemPerPage
|
||||
);
|
||||
|
||||
$params = [
|
||||
'keyword' => $keyword,
|
||||
'active' => $active,
|
||||
'sleeping_days' => $sleepingDays,
|
||||
];
|
||||
$table->set_additional_parameters($params);
|
||||
|
||||
$table->set_header(0, ' ', false);
|
||||
|
||||
if ($is_western_name_order) {
|
||||
$table->set_header(1, get_lang('FirstName'), false);
|
||||
$table->set_header(2, get_lang('LastName'), false);
|
||||
} else {
|
||||
$table->set_header(2, get_lang('LastName'), false);
|
||||
$table->set_header(1, get_lang('FirstName'), false);
|
||||
}
|
||||
|
||||
$table->set_header(3, get_lang('FirstLogin'), false);
|
||||
$table->set_header(4, get_lang('LastConnexion'), false);
|
||||
$table->set_header(5, get_lang('Details'), false);
|
||||
|
||||
// Only show empty actions bar if delete users has been blocked
|
||||
$actionsList = [];
|
||||
$actionsList['send_emails'] = get_lang('SendEmail');
|
||||
$table->set_form_actions($actionsList);
|
||||
|
||||
if ($export_csv) {
|
||||
if ($is_western_name_order) {
|
||||
$csv_header[] = [
|
||||
get_lang('FirstName'),
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
} else {
|
||||
$csv_header[] = [
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_user',
|
||||
'get',
|
||||
$webCodePath.'mySpace/student.php'
|
||||
);
|
||||
$form = Tracking::setUserSearchForm($form, true);
|
||||
$form->setDefaults($params);
|
||||
|
||||
if ($export_csv) {
|
||||
// send the csv file if asked
|
||||
$content = $table->get_table_data();
|
||||
$csv_content = array_merge($csv_header, $content);
|
||||
Export::arrayToCsv($csv_content, 'reporting_student_list');
|
||||
exit;
|
||||
} else {
|
||||
|
||||
// It sends the email to selected users
|
||||
if (isset($_POST['action']) && 'send_message' == $_POST['action']) {
|
||||
$subject = $_POST['subject'] ?? '';
|
||||
$message = $_POST['message'] ?? '';
|
||||
$users = $_POST['uid'] ?? '';
|
||||
if (!empty($subject) && !empty($message) && !empty($users)) {
|
||||
foreach ($users as $uid) {
|
||||
MessageManager::send_message_simple(
|
||||
$uid,
|
||||
$subject,
|
||||
$message,
|
||||
api_get_user_id()
|
||||
);
|
||||
}
|
||||
Display::addFlash(Display::return_message(get_lang('MessageSent')));
|
||||
}
|
||||
}
|
||||
|
||||
$script = '<script>
|
||||
$(function() {
|
||||
$("#form_tracking_student_id input[type=\"checkbox\"]").on("click", function() {
|
||||
$("#compose_message").hide();
|
||||
});
|
||||
});
|
||||
function action_click(element, table_id) {
|
||||
this.event.preventDefault();
|
||||
var amIChecked = false;
|
||||
$(".hd-users").remove();
|
||||
$("#form_tracking_student_id input[type=\"checkbox\"]").each(function() {
|
||||
if (this.checked) {
|
||||
amIChecked = true;
|
||||
var input = $("<input>", {
|
||||
type: "hidden",
|
||||
name: "uid[]",
|
||||
value: this.value,
|
||||
class: "hd-users",
|
||||
});
|
||||
$("#students_messages").append(input);
|
||||
}
|
||||
});
|
||||
if (!amIChecked) {
|
||||
alert("'.get_lang('YouMustSelectAtLeastOneDestinee').'");
|
||||
return false;
|
||||
}
|
||||
$("#compose_message").show();
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
';
|
||||
|
||||
Display::display_header($nameTools);
|
||||
$token = Security::get_token();
|
||||
echo $toolbar;
|
||||
echo Display::page_subheader($nameTools);
|
||||
if (isset($active)) {
|
||||
if ($active) {
|
||||
$activeLabel = get_lang('ActiveUsers');
|
||||
} else {
|
||||
$activeLabel = get_lang('InactiveUsers');
|
||||
}
|
||||
echo Display::page_subheader2($activeLabel);
|
||||
}
|
||||
$form->display();
|
||||
$table->display();
|
||||
|
||||
$frmMessage = new FormValidator(
|
||||
'students_messages',
|
||||
'post',
|
||||
api_get_self()
|
||||
);
|
||||
$frmMessage->addHtml('<div id="compose_message" style="display:none;">');
|
||||
$frmMessage->addText('subject', get_lang('Subject'));
|
||||
$frmMessage->addRule('subject', 'obligatorio', 'required');
|
||||
$frmMessage->addHtmlEditor('message', get_lang('Message'));
|
||||
$frmMessage->addButtonSend(get_lang('Send'));
|
||||
$frmMessage->addHidden('sec_token', $token);
|
||||
$frmMessage->addHidden('action', 'send_message');
|
||||
$frmMessage->addHtml('</div>');
|
||||
$frmMessage->display();
|
||||
|
||||
echo $script;
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
575
main/mySpace/student_follow_export.php
Normal file
575
main/mySpace/student_follow_export.php
Normal file
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\CourseBundle\Entity\CLpCategory;
|
||||
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
require_once '../work/work.lib.php';
|
||||
|
||||
api_block_anonymous_users(false);
|
||||
|
||||
$allowedToTrackUser = api_is_platform_admin(true, true) ||
|
||||
api_is_allowed_to_edit(null, true) ||
|
||||
api_is_session_admin() ||
|
||||
api_is_drh() ||
|
||||
api_is_student_boss() ||
|
||||
api_is_course_admin() ||
|
||||
api_is_teacher();
|
||||
|
||||
if (!$allowedToTrackUser) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
$httpRequest = HttpRequest::createFromGlobals();
|
||||
|
||||
$studentInfo = api_get_user_info($httpRequest->query->getInt('student'));
|
||||
|
||||
if (empty($studentInfo)) {
|
||||
api_not_allowed();
|
||||
}
|
||||
|
||||
function getCoursesInSession(int $studentId): array
|
||||
{
|
||||
$coursesInSessions = [];
|
||||
|
||||
$courseRelUser = Database::select(
|
||||
'c_id',
|
||||
Database::get_main_table(TABLE_MAIN_COURSE_USER),
|
||||
[
|
||||
'where' => [
|
||||
'relation_type <> ? AND user_id = ?' => [COURSE_RELATION_TYPE_RRHH, $studentId],
|
||||
],
|
||||
]
|
||||
);
|
||||
$sessionRelCourseRelUser = Database::select(
|
||||
['session_id', 'c_id'],
|
||||
Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER),
|
||||
[
|
||||
'where' => [
|
||||
'user_id = ?' => $studentId,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($courseRelUser as $row) {
|
||||
$coursesInSessions[0][] = $row['c_id'];
|
||||
}
|
||||
|
||||
foreach ($sessionRelCourseRelUser as $row) {
|
||||
$coursesInSessions[$row['session_id']][] = $row['c_id'];
|
||||
}
|
||||
|
||||
return $coursesInSessions;
|
||||
}
|
||||
|
||||
function generateForm(int $studentId, array $coursesInSessions): FormValidator
|
||||
{
|
||||
$form = new FormValidator(
|
||||
'frm_export',
|
||||
'post',
|
||||
api_get_self()."?student=$studentId",
|
||||
'',
|
||||
[],
|
||||
FormValidator::LAYOUT_BOX
|
||||
);
|
||||
// Options to hide columns or blocks in export pdf
|
||||
$hideOptionsExport['connection_time'] = get_lang('HideConnectionTime');
|
||||
$hideOptionsExport['skills'] = get_lang('HideSkills');
|
||||
$hideOptionsExport['assignment'] = get_lang('HideAssignment');
|
||||
$form->addCheckBoxGroup("hide_options", get_lang('OptionsToHideInExport'), $hideOptionsExport);
|
||||
|
||||
foreach ($coursesInSessions as $sId => $courses) {
|
||||
if (empty($courses)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($sId) {
|
||||
$sessionInfo = api_get_session_info($sId);
|
||||
|
||||
$dateSession = empty($sessionInfo['duration'])
|
||||
? '('.SessionManager::parseSessionDates($sessionInfo, true)['display'].')'
|
||||
: '';
|
||||
|
||||
$fieldTitle = $sessionInfo['name'].PHP_EOL.Display::tag('small', $dateSession);
|
||||
} else {
|
||||
$fieldTitle = get_lang('Courses');
|
||||
}
|
||||
|
||||
$options = [];
|
||||
|
||||
foreach ($courses as $courseId) {
|
||||
$courseInfoItem = api_get_course_info_by_id($courseId);
|
||||
|
||||
if (empty($sessionInfo)) {
|
||||
$isSubscribed = CourseManager::is_user_subscribed_in_course(
|
||||
$studentId,
|
||||
$courseInfoItem['code']
|
||||
);
|
||||
} else {
|
||||
$isSubscribed = CourseManager::is_user_subscribed_in_course(
|
||||
$studentId,
|
||||
$courseInfoItem['code'],
|
||||
true,
|
||||
$sId
|
||||
);
|
||||
}
|
||||
|
||||
if (!$isSubscribed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[$sId.'_'.$courseId] = $courseInfoItem['title'];
|
||||
}
|
||||
|
||||
$form->addCheckBoxGroup("sc", $fieldTitle, $options, ['checked' => 'checked']);
|
||||
}
|
||||
|
||||
$form->addButtonExport(get_lang('ExportToPDF'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function generateHtmlForLearningPaths(int $studentId, array $courseInfo, int $sessionId, bool $hideConnectionTime = false): string
|
||||
{
|
||||
$student = api_get_user_entity($studentId);
|
||||
$showTime = ($hideConnectionTime === false);
|
||||
$html = '';
|
||||
|
||||
$columnHeaders = [];
|
||||
$columnHeaders['lp'] = get_lang('LearningPath');
|
||||
if ($showTime) {
|
||||
$columnHeaders['time'] = get_lang('Time');
|
||||
}
|
||||
$columnHeaders['best_score'] = get_lang('BestScore');
|
||||
$columnHeaders['latest_attempt_avg_score'] = get_lang('LatestAttemptAverageScore');
|
||||
$columnHeaders['progress'] = get_lang('Progress');
|
||||
$columnHeaders['last_connection'] = get_lang('LastConnexion');
|
||||
|
||||
$trackingColumns = api_get_configuration_value('tracking_columns');
|
||||
|
||||
if (isset($trackingColumns['my_students_lp'])) {
|
||||
foreach ($columnHeaders as $key => $value) {
|
||||
if (!isset($trackingColumns['my_progress_lp'][$key]) || $trackingColumns['my_students_lp'][$key] == false) {
|
||||
unset($columnHeaders[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (true === api_get_configuration_value('student_follow_page_add_LP_subscription_info')) {
|
||||
$columnHeaders['student_follow_page_add_LP_subscription_info'] = get_lang('Unlock');
|
||||
}
|
||||
|
||||
if (true === api_get_configuration_value('student_follow_page_add_LP_acquisition_info')) {
|
||||
$columnHeaders['student_follow_page_add_LP_acquisition_info'] = get_lang('Acquisition');
|
||||
}
|
||||
|
||||
$columnHeadersKeys = array_keys($columnHeaders);
|
||||
|
||||
$hideInvisibleViews = api_get_configuration_value('student_follow_page_add_LP_invisible_checkbox');
|
||||
$includeNotsubscribedLp = api_get_configuration_value('student_follow_page_include_not_subscribed_lp_students');
|
||||
|
||||
$timeCourse = Tracking::minimumTimeAvailable($sessionId, $courseInfo['real_id'])
|
||||
? Tracking::getCalculateTime($student->getId(), $courseInfo['real_id'], $sessionId)
|
||||
: null;
|
||||
|
||||
$lpCategories = learnpath::getCategories($courseInfo['real_id'], true);
|
||||
|
||||
/** @var CLpCategory $item */
|
||||
foreach ($lpCategories as $item) {
|
||||
$categoryId = $item->getId();
|
||||
|
||||
if (!learnpath::categoryIsVisibleForStudent($item, $student, $courseInfo['real_id'], $sessionId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$lpList = new LearnpathList(
|
||||
$student->getId(),
|
||||
$courseInfo,
|
||||
$sessionId,
|
||||
null,
|
||||
false,
|
||||
$categoryId,
|
||||
false,
|
||||
false,
|
||||
$includeNotsubscribedLp === true
|
||||
);
|
||||
|
||||
$flatList = $lpList->get_flat_list();
|
||||
|
||||
$lpTable = [];
|
||||
|
||||
foreach ($flatList as $learnpath) {
|
||||
$lpId = $learnpath['lp_old_id'];
|
||||
|
||||
if ($hideInvisibleViews
|
||||
&& !StudentFollowPage::isViewVisible($lpId, $student->getId(), $courseInfo['real_id'], $sessionId)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$contentToExport = [];
|
||||
|
||||
if (in_array('lp', $columnHeadersKeys)) {
|
||||
$contentToExport[] = api_html_entity_decode(stripslashes($learnpath['lp_name']), ENT_QUOTES);
|
||||
}
|
||||
|
||||
if (in_array('time', $columnHeadersKeys) && $showTime) {
|
||||
// Get time in lp
|
||||
if (!empty($timeCourse)) {
|
||||
$lpTime = $timeCourse[TOOL_LEARNPATH] ?? 0;
|
||||
$totalTime = isset($lpTime[$lpId]) ? (int) $lpTime[$lpId] : 0;
|
||||
} else {
|
||||
$totalTime = Tracking::get_time_spent_in_lp(
|
||||
$student->getId(),
|
||||
$courseInfo['code'],
|
||||
[$lpId],
|
||||
$sessionId
|
||||
);
|
||||
}
|
||||
|
||||
$contentToExport[] = api_time_to_hms($totalTime);
|
||||
}
|
||||
|
||||
if (in_array('best_score', $columnHeadersKeys)) {
|
||||
$bestScore = Tracking::get_avg_student_score(
|
||||
$student->getId(),
|
||||
$courseInfo['code'],
|
||||
[$lpId],
|
||||
$sessionId,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$contentToExport[] = empty($bestScore) ? '' : "$bestScore %";
|
||||
}
|
||||
|
||||
if (in_array('latest_attempt_avg_score', $columnHeadersKeys)) {
|
||||
$scoreLatest = Tracking::get_avg_student_score(
|
||||
$student->getId(),
|
||||
$courseInfo['code'],
|
||||
[$lpId],
|
||||
$sessionId,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
if (isset($scoreLatest) && is_numeric($scoreLatest)) {
|
||||
$scoreLatest = "$scoreLatest %";
|
||||
}
|
||||
|
||||
$contentToExport[] = $scoreLatest;
|
||||
}
|
||||
|
||||
if (in_array('progress', $columnHeadersKeys)) {
|
||||
$progress = Tracking::get_avg_student_progress(
|
||||
$student->getId(),
|
||||
$courseInfo['code'],
|
||||
[$lpId],
|
||||
$sessionId
|
||||
);
|
||||
|
||||
$contentToExport[] = is_numeric($progress) ? "$progress %" : '0 %';
|
||||
}
|
||||
|
||||
if (in_array('last_connection', $columnHeadersKeys)) {
|
||||
// Get last connection time in lp
|
||||
$startTime = Tracking::get_last_connection_time_in_lp(
|
||||
$student->getId(),
|
||||
$courseInfo['code'],
|
||||
$lpId,
|
||||
$sessionId
|
||||
);
|
||||
|
||||
$contentToExport[] = empty($startTime)
|
||||
? '-'
|
||||
: api_convert_and_format_date($startTime, DATE_TIME_FORMAT_LONG);
|
||||
}
|
||||
|
||||
if (in_array('student_follow_page_add_LP_subscription_info', $columnHeadersKeys)) {
|
||||
$lpSubscription = StudentFollowPage::getLpSubscription(
|
||||
$learnpath,
|
||||
$student->getId(),
|
||||
$courseInfo['real_id'],
|
||||
$sessionId
|
||||
);
|
||||
$contentToExport[] = strip_tags(str_replace('<br>', "\n", $lpSubscription));
|
||||
}
|
||||
|
||||
if (in_array('student_follow_page_add_LP_acquisition_info', $columnHeadersKeys)) {
|
||||
$lpAcquisition = StudentFollowPage::getLpAcquisition(
|
||||
$learnpath,
|
||||
$student->getId(),
|
||||
$courseInfo['real_id'],
|
||||
$sessionId
|
||||
);
|
||||
$contentToExport[] = strip_tags(str_replace('<br>', "\n", $lpAcquisition));
|
||||
}
|
||||
|
||||
$lpTable[] = $contentToExport;
|
||||
}
|
||||
|
||||
if (empty($lpTable)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($lpCategories) > 1) {
|
||||
$html .= Display::page_subheader3($item->getName());
|
||||
}
|
||||
|
||||
array_unshift($lpTable, [$columnHeaders]);
|
||||
|
||||
$html .= Export::convert_array_to_html($lpTable);
|
||||
}
|
||||
|
||||
if (!empty($html)) {
|
||||
$html = Display::page_subheader2(get_lang('ToolLearnpath')).PHP_EOL.$html;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function generateHtmlForQuizzes(int $studentId, array $courseInfo, int $sessionId): string
|
||||
{
|
||||
$html = Display::page_subheader2(get_lang('ToolQuiz'));
|
||||
|
||||
$columnHeaders = [];
|
||||
$columnHeaders[] = get_lang('Exercises');
|
||||
$columnHeaders[] = get_lang('LearningPath');
|
||||
$columnHeaders[] = get_lang('AvgCourseScore');
|
||||
$columnHeaders[] = get_lang('Attempts');
|
||||
|
||||
$taskTable = [$columnHeaders];
|
||||
|
||||
$tblQuiz = Database::get_course_table(TABLE_QUIZ_TEST);
|
||||
$sessionCondition = api_get_session_condition($sessionId, true, true, 'quiz.session_id');
|
||||
|
||||
$sql = "SELECT quiz.title, iid
|
||||
FROM $tblQuiz AS quiz
|
||||
WHERE
|
||||
quiz.c_id = ".$courseInfo['real_id']."
|
||||
AND active IN (0, 1)
|
||||
$sessionCondition
|
||||
ORDER BY quiz.title ASC";
|
||||
$resultExercices = Database::query($sql);
|
||||
|
||||
if (Database::num_rows($resultExercices) > 0) {
|
||||
while ($exercices = Database::fetch_array($resultExercices)) {
|
||||
$exerciseId = (int) $exercices['iid'];
|
||||
$countAttempts = Tracking::count_student_exercise_attempts(
|
||||
$studentId,
|
||||
$courseInfo['real_id'],
|
||||
$exerciseId,
|
||||
0,
|
||||
0,
|
||||
$sessionId,
|
||||
2
|
||||
);
|
||||
$scorePercentage = Tracking::get_avg_student_exercise_score(
|
||||
$studentId,
|
||||
$courseInfo['code'],
|
||||
$exerciseId,
|
||||
$sessionId
|
||||
);
|
||||
|
||||
$lpName = '-';
|
||||
|
||||
if (!isset($scorePercentage) && $countAttempts > 0) {
|
||||
$lpScores = Tracking::get_avg_student_exercise_score(
|
||||
$studentId,
|
||||
$courseInfo['code'],
|
||||
$exerciseId,
|
||||
$sessionId,
|
||||
2,
|
||||
1
|
||||
);
|
||||
$scorePercentage = $lpScores[0];
|
||||
$lpName = $lpScores[1];
|
||||
}
|
||||
|
||||
$lpName = !empty($lpName) ? $lpName : get_lang('NoLearnpath');
|
||||
|
||||
$contentToExport = [];
|
||||
$contentToExport[] = Exercise::get_formated_title_variable($exercices['title']);
|
||||
$contentToExport[] = empty($lpName) ? '-' : $lpName;
|
||||
$contentToExport[] = $countAttempts > 0 ? sprintf(get_lang('XPercent'), $scorePercentage) : '-';
|
||||
$contentToExport[] = $countAttempts;
|
||||
|
||||
$taskTable[] = $contentToExport;
|
||||
}
|
||||
|
||||
$html .= Export::convert_array_to_html($taskTable);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function generateHtmlForTasks(int $studentId, array $courseInfo, int $sessionId): string
|
||||
{
|
||||
$columnHeaders = [];
|
||||
$columnHeaders[] = get_lang('Tasks');
|
||||
$columnHeaders[] = get_lang('DocumentNumber');
|
||||
$columnHeaders[] = get_lang('Note');
|
||||
$columnHeaders[] = get_lang('HandedOut');
|
||||
$columnHeaders[] = get_lang('HandOutDateLimit');
|
||||
$columnHeaders[] = get_lang('ConsideredWorkingTime');
|
||||
|
||||
$workingTime = api_get_configuration_value('considered_working_time');
|
||||
|
||||
$userWorks = getWorkPerUser($studentId, $courseInfo['real_id'], $sessionId);
|
||||
|
||||
$taskTable = [$columnHeaders];
|
||||
|
||||
foreach ($userWorks as $work) {
|
||||
$work = $work['work'];
|
||||
|
||||
foreach ($work->user_results as $key => $results) {
|
||||
$documentNumber = $key + 1;
|
||||
|
||||
$contentToExport = [];
|
||||
|
||||
$contentToExport[] = $work->title;
|
||||
$contentToExport[] = $documentNumber;
|
||||
$contentToExport[] = !empty($results['qualification']) ? $results['qualification'] : '-';
|
||||
$contentToExport[] = api_convert_and_format_date($results['sent_date_from_db']).PHP_EOL
|
||||
.$results['expiry_note'];
|
||||
|
||||
$assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']);
|
||||
|
||||
if (!empty($assignment['expires_on'])) {
|
||||
$contentToExport[] = api_convert_and_format_date($assignment['expires_on']);
|
||||
}
|
||||
|
||||
$fieldValue = new ExtraFieldValue('work');
|
||||
$resultExtra = $fieldValue->getAllValuesForAnItem($work->iid, true);
|
||||
|
||||
foreach ($resultExtra as $field) {
|
||||
$field = $field['value'];
|
||||
|
||||
if ($workingTime == $field->getField()->getVariable()) {
|
||||
$time = $field->getValue();
|
||||
|
||||
$contentToExport[] = $time;
|
||||
}
|
||||
}
|
||||
|
||||
$taskTable[] = $contentToExport;
|
||||
}
|
||||
}
|
||||
|
||||
return Display::page_subheader2(get_lang('ToolStudentPublication')).PHP_EOL
|
||||
.Export::convert_array_to_html($taskTable);
|
||||
}
|
||||
|
||||
function generateHtmlForCourse(int $studentId, array $coursesInSessions, int $courseId, int $sessionId, bool $hideConnectionTime = false, bool $hideAssignment = false): ?string
|
||||
{
|
||||
if (empty($coursesInSessions[$sessionId]) || !in_array($courseId, $coursesInSessions[$sessionId])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$courseInfo = api_get_course_info_by_id($courseId);
|
||||
|
||||
$courseHtml = [];
|
||||
|
||||
if ($sessionId) {
|
||||
$sessionInfo = api_get_session_info($sessionId);
|
||||
|
||||
$dateSession = empty($sessionInfo['duration'])
|
||||
? '('.SessionManager::parseSessionDates($sessionInfo, true)['display'].')'
|
||||
: '';
|
||||
|
||||
$courseHtml[] = Display::page_header($sessionInfo['name'].PHP_EOL.Display::tag('small', $dateSession))
|
||||
.Display::page_subheader($courseInfo['title']);
|
||||
} else {
|
||||
$courseHtml[] = Display::page_header($courseInfo['title']);
|
||||
}
|
||||
|
||||
$courseHtml[] = generateHtmlForLearningPaths($studentId, $courseInfo, $sessionId, $hideConnectionTime);
|
||||
$courseHtml[] = generateHtmlForQuizzes($studentId, $courseInfo, $sessionId);
|
||||
if (!$hideAssignment) {
|
||||
$courseHtml[] = generateHtmlForTasks($studentId, $courseInfo, $sessionId);
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $courseHtml);
|
||||
}
|
||||
|
||||
$coursesInSessions = getCoursesInSession($studentInfo['id']);
|
||||
|
||||
$form = generateForm($studentInfo['id'], $coursesInSessions);
|
||||
|
||||
if ($form->validate()) {
|
||||
$values = $form->exportValues();
|
||||
|
||||
$studentInfo['status'] = api_get_status_langvars()[$studentInfo['status']];
|
||||
$studentInfo['official_code'] = empty($studentInfo['official_code']) ? get_lang('NoOfficialCode')
|
||||
: $studentInfo['code'];
|
||||
$studentInfo['phone'] = empty($studentInfo['phone']) ? get_lang('NoTel') : $studentInfo['phone'];
|
||||
$studentInfo['first_login'] = Tracking::get_first_connection_date($studentInfo['id']) ?? get_lang('NoConnexion');
|
||||
$studentInfo['last_login'] = Tracking::get_last_connection_date($studentInfo['id'], true)
|
||||
?? get_lang('NoConnexion');
|
||||
$studentInfo['last_course_connection'] = api_format_date(
|
||||
Tracking::getLastConnectionInAnyCourse($studentInfo['id']),
|
||||
DATE_FORMAT_SHORT
|
||||
);
|
||||
|
||||
$coursesInfo = [];
|
||||
$hideConnectionTime = isset($values['hide_options']['connection_time']);
|
||||
$hideSkills = isset($values['hide_options']['skills']);
|
||||
$hideAssignment = isset($values['hide_options']['assignment']);
|
||||
if (!empty($values['sc'])) {
|
||||
foreach ($values['sc'] as $courseKey) {
|
||||
[$sessionId, $courseId] = explode('_', $courseKey);
|
||||
|
||||
$coursesInfo[] = generateHtmlForCourse($studentInfo['id'], $coursesInSessions, $courseId, $sessionId, $hideConnectionTime, $hideAssignment);
|
||||
}
|
||||
}
|
||||
|
||||
$skills = Tracking::displayUserSkills($studentInfo['id']);
|
||||
if ($hideSkills) {
|
||||
$skills = '';
|
||||
}
|
||||
$view = new Template('', false, false, false, true, false, false);
|
||||
$view->assign('user_info', $studentInfo);
|
||||
$view->assign('careers', MyStudents::userCareersTable($studentInfo['id']));
|
||||
$view->assign('skills', $skills);
|
||||
$view->assign('classes', MyStudents::getBlockForClasses($studentInfo['id']));
|
||||
$view->assign('courses_info', $coursesInfo);
|
||||
|
||||
$template = $view->get_template('my_space/student_follow_pdf.tpl');
|
||||
$filename = $studentInfo['firstname'].' '.$studentInfo['lastname'];
|
||||
$params = [
|
||||
'filename' => $filename,
|
||||
'format' => 'A4',
|
||||
'orientation' => 'P',
|
||||
];
|
||||
|
||||
$css = '
|
||||
.user-info { clear: both; }
|
||||
.user-info__col { float: left; width: 33.33%; }
|
||||
';
|
||||
|
||||
$pdf = new PDF($params['format'], $params['orientation'], $params);
|
||||
|
||||
try {
|
||||
$pdf->content_to_pdf(
|
||||
$view->fetch($template),
|
||||
$css,
|
||||
$filename,
|
||||
null,
|
||||
'D',
|
||||
false,
|
||||
null,
|
||||
false,
|
||||
true
|
||||
);
|
||||
} catch (MpdfException $e) {
|
||||
echo Display::return_message(get_lang('ErrorWhileBuildingReport'), 'error');
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
echo Display::page_subheader($studentInfo['complete_name_with_username']);
|
||||
$form->display();
|
||||
49
main/mySpace/survey_report.php
Normal file
49
main/mySpace/survey_report.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$csv_content = [];
|
||||
$nameTools = get_lang('MySpace');
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true);
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$form = new FormValidator('survey');
|
||||
$form->addSelectAjax(
|
||||
'user_id',
|
||||
get_lang('User'),
|
||||
[],
|
||||
[
|
||||
'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_like',
|
||||
]
|
||||
);
|
||||
$form->addButtonSearch();
|
||||
|
||||
$userInfo = [];
|
||||
if ($form->validate()) {
|
||||
$userId = $form->exportValue('user_id');
|
||||
$userInfo = api_get_user_info($userId);
|
||||
}
|
||||
|
||||
Display::display_header($nameTools);
|
||||
echo '<div class="actions">';
|
||||
echo MySpace::getTopMenu();
|
||||
echo '</div>';
|
||||
echo MySpace::getAdminActions();
|
||||
|
||||
$form->display();
|
||||
|
||||
if (!empty($userInfo)) {
|
||||
echo Display::page_subheader($userInfo['complete_name']);
|
||||
echo SurveyManager::surveyReport($userInfo);
|
||||
echo SurveyManager::surveyReport($userInfo, 1);
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
183
main/mySpace/tc_report.php
Normal file
183
main/mySpace/tc_report.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$csv_content = [];
|
||||
$nameTools = get_lang('MySpace');
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true);
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$userInfo = [];
|
||||
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
|
||||
$languageFilter = isset($_REQUEST['language']) ? $_REQUEST['language'] : '';
|
||||
$content = '';
|
||||
|
||||
switch ($action) {
|
||||
case 'add_user':
|
||||
$bossId = isset($_REQUEST['boss_id']) ? (int) $_REQUEST['boss_id'] : 0;
|
||||
$bossInfo = api_get_user_info($bossId);
|
||||
|
||||
$form = new FormValidator('add_user');
|
||||
$form->addHeader(get_lang('AddUser').' '.$bossInfo['complete_name']);
|
||||
$form->addHidden('a', 'add_user');
|
||||
$form->addHidden('boss_id', $bossId);
|
||||
$form->addSelectAjax(
|
||||
'user_id',
|
||||
get_lang('User'),
|
||||
[],
|
||||
[
|
||||
'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=user_by_role&active=1&status='.STUDENT,
|
||||
]
|
||||
);
|
||||
$form->addButtonSave(get_lang('Add'));
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
$studentInfo = api_get_user_info($values['user_id']);
|
||||
UserManager::subscribeUserToBossList($values['user_id'], [$values['boss_id']], true);
|
||||
Display::addFlash(Display::return_message(get_lang('Saved').' '.$studentInfo['complete_name']));
|
||||
header('Location: '.api_get_self());
|
||||
exit;
|
||||
}
|
||||
$content = $form->returnForm();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$url = api_get_path(WEB_AJAX_PATH).'statistics.ajax.php?a=add_student_to_boss';
|
||||
|
||||
$htmlHeadXtra[] = '<script>
|
||||
$(function() {
|
||||
$(".add_user form").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
var id = $(this).attr("id");
|
||||
var data = $("#" + id ).serializeArray();
|
||||
var bossId = id.replace("add_user_to_", "") ;
|
||||
|
||||
for (i=0; i<data.length; i += 1) {
|
||||
if (data[i].name === "user_id") {
|
||||
var userId = data[i].value;
|
||||
var params = "boss_id="+ bossId + "&student_id="+ userId + "&";
|
||||
$.get(
|
||||
"'.$url.'",
|
||||
params,
|
||||
function(response) {
|
||||
$("#table_" + bossId ).html(response);
|
||||
$("#table_" + bossId ).append("'.addslashes(Display::label(get_lang('Added'), 'success')).'");
|
||||
$("#add_user_to_" + bossId + "_user_id").val(null).trigger("change");
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>';
|
||||
|
||||
Display::display_header($nameTools);
|
||||
echo '<div class="actions">';
|
||||
echo MySpace::getTopMenu();
|
||||
echo '</div>';
|
||||
echo MySpace::getAdminActions();
|
||||
|
||||
if ('add_user' !== $action) {
|
||||
$form = new FormValidator('language_filter');
|
||||
$form->addHidden('a', 'language_filter');
|
||||
$form->addSelectLanguage(
|
||||
'language',
|
||||
get_lang('Language'),
|
||||
['placeholder' => get_lang('SelectAnOption')]
|
||||
);
|
||||
$form->addButtonSearch(get_lang('Search'));
|
||||
|
||||
echo $form->returnForm();
|
||||
}
|
||||
|
||||
echo $content;
|
||||
$style = '<style>
|
||||
.boss_column {
|
||||
display: block;
|
||||
}
|
||||
.row .col-md-1 {
|
||||
display:flex;
|
||||
flex: 0 0 20%;
|
||||
}
|
||||
|
||||
.flex-nowrap {
|
||||
-webkit-flex-wrap: nowrap!important;
|
||||
-ms-flex-wrap: nowrap!important;
|
||||
flex-wrap: nowrap!important;
|
||||
}
|
||||
.flex-row {
|
||||
display:flex;
|
||||
-webkit-box-orient: horizontal!important;
|
||||
-webkit-box-direction: normal!important;
|
||||
-webkit-flex-direction: row!important;
|
||||
-ms-flex-direction: row!important;
|
||||
flex-direction: row!important;
|
||||
}
|
||||
|
||||
.add_user {
|
||||
//display:none;
|
||||
}
|
||||
</style>';
|
||||
echo $style;
|
||||
|
||||
$tableContent = '';
|
||||
|
||||
if ('add_user' !== $action) {
|
||||
$conditions = ['status' => STUDENT_BOSS, 'active' => 1];
|
||||
if (!empty($languageFilter) && 'placeholder' !== $languageFilter) {
|
||||
$conditions['language'] = $languageFilter;
|
||||
}
|
||||
$bossList = UserManager::get_user_list($conditions, ['firstname']);
|
||||
$tableContent .= '<div class="container-fluid"><div class="row flex-row flex-nowrap">';
|
||||
foreach ($bossList as $boss) {
|
||||
$bossId = $boss['id'];
|
||||
$tableContent .= '<div class="col-md-1">';
|
||||
$tableContent .= '<div class="boss_column">';
|
||||
$tableContent .= '<h5><strong>'.api_get_person_name($boss['firstname'], $boss['lastname']).'</strong></h5>';
|
||||
$tableContent .= Statistics::getBossTable($bossId);
|
||||
|
||||
$url = api_get_self().'?a=add_user&boss_id='.$bossId;
|
||||
|
||||
$tableContent .= '<div class="add_user">';
|
||||
$tableContent .= '<strong>'.get_lang('AddStudent').'</strong>';
|
||||
$addUserForm = new FormValidator(
|
||||
'add_user_to_'.$bossId,
|
||||
'post',
|
||||
'',
|
||||
'',
|
||||
[],
|
||||
FormValidator::LAYOUT_BOX_NO_LABEL
|
||||
);
|
||||
$addUserForm->addSelectAjax(
|
||||
'user_id',
|
||||
'',
|
||||
[],
|
||||
[
|
||||
'width' => '200px',
|
||||
'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=user_by_role&active=1&status='.STUDENT,
|
||||
]
|
||||
);
|
||||
$addUserForm->addButtonSave(get_lang('Add'));
|
||||
$tableContent .= $addUserForm->returnForm();
|
||||
$tableContent .= '</div>';
|
||||
|
||||
$tableContent .= '</div>';
|
||||
$tableContent .= '</div>';
|
||||
}
|
||||
$tableContent .= '</div></div>';
|
||||
}
|
||||
|
||||
echo $tableContent;
|
||||
|
||||
Display::display_footer();
|
||||
308
main/mySpace/teachers.php
Normal file
308
main/mySpace/teachers.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* Teacher report.
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$export_csv = isset($_GET['export']) && 'csv' == $_GET['export'] ? true : false;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
|
||||
$nameTools = get_lang('Teachers');
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
|
||||
$interbreadcrumb[] = ["url" => "teachers.php", "name" => get_lang('Teachers')];
|
||||
}
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && isset($_GET["type"]) && $_GET["type"] == "coach") {
|
||||
$interbreadcrumb[] = ["url" => "coaches.php", "name" => get_lang('Tutors')];
|
||||
}
|
||||
|
||||
function get_count_users()
|
||||
{
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
|
||||
|
||||
$lastConnectionDate = null;
|
||||
if (!empty($sleepingDays)) {
|
||||
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
|
||||
}
|
||||
|
||||
$count = SessionManager::getCountUserTracking(
|
||||
$keyword,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
null,
|
||||
null,
|
||||
COURSEMANAGER
|
||||
);
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
function get_users($from, $limit, $column, $direction)
|
||||
{
|
||||
$active = isset($_GET['active']) ? $_GET['active'] : 1;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
|
||||
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
|
||||
|
||||
$lastConnectionDate = null;
|
||||
if (!empty($sleepingDays)) {
|
||||
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
|
||||
}
|
||||
|
||||
$is_western_name_order = api_is_western_name_order();
|
||||
$coach_id = api_get_user_id();
|
||||
|
||||
$drhLoaded = false;
|
||||
if (api_is_drh() && api_drh_can_access_all_session_content()) {
|
||||
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
|
||||
'drh_all',
|
||||
api_get_user_id(),
|
||||
false,
|
||||
$from,
|
||||
$limit,
|
||||
$column,
|
||||
$direction,
|
||||
$keyword,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
null,
|
||||
null,
|
||||
COURSEMANAGER
|
||||
);
|
||||
$drhLoaded = true;
|
||||
}
|
||||
|
||||
$checkSessionVisibility = api_get_configuration_value('show_users_in_active_sessions_in_tracking');
|
||||
if (false == $drhLoaded) {
|
||||
$students = UserManager::getUsersFollowedByUser(
|
||||
api_get_user_id(),
|
||||
COURSEMANAGER,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
$from,
|
||||
$limit,
|
||||
$column,
|
||||
$direction,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
COURSEMANAGER,
|
||||
$keyword,
|
||||
$checkSessionVisibility
|
||||
);
|
||||
}
|
||||
|
||||
$all_datas = [];
|
||||
$url = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php';
|
||||
foreach ($students as $student_data) {
|
||||
$student_id = $student_data['user_id'];
|
||||
$student_data = api_get_user_info($student_id);
|
||||
if (isset($_GET['id_session'])) {
|
||||
$courses = Tracking::get_course_list_in_session_from_student($student_id, $_GET['id_session']);
|
||||
}
|
||||
|
||||
$avg_time_spent = $avg_student_score = $avg_student_progress = 0;
|
||||
$nb_courses_student = 0;
|
||||
if (!empty($courses)) {
|
||||
foreach ($courses as $course_code) {
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
|
||||
$avg_time_spent += Tracking::get_time_spent_on_the_course(
|
||||
$student_id,
|
||||
$courseId,
|
||||
$_GET['id_session']
|
||||
);
|
||||
$my_average = Tracking::get_avg_student_score($student_id, $course_code);
|
||||
if (is_numeric($my_average)) {
|
||||
$avg_student_score += $my_average;
|
||||
}
|
||||
$avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
|
||||
$nb_courses_student++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nb_courses_student > 0) {
|
||||
$avg_time_spent = $avg_time_spent / $nb_courses_student;
|
||||
$avg_student_score = $avg_student_score / $nb_courses_student;
|
||||
$avg_student_progress = $avg_student_progress / $nb_courses_student;
|
||||
} else {
|
||||
$avg_time_spent = null;
|
||||
$avg_student_score = null;
|
||||
$avg_student_progress = null;
|
||||
}
|
||||
|
||||
$urlDetails = $url."?student=$student_id&origin=teacher_details";
|
||||
if (isset($_GET['id_coach']) && 0 != intval($_GET['id_coach'])) {
|
||||
$urlDetails = $url."?student=$student_id&id_coach=$coach_id&id_session=$sessionId";
|
||||
}
|
||||
|
||||
$row = [];
|
||||
if ($is_western_name_order) {
|
||||
$row[] = Display::url($student_data['firstname'], $urlDetails);
|
||||
$row[] = Display::url($student_data['lastname'], $urlDetails);
|
||||
} else {
|
||||
$row[] = $student_data['lastname'];
|
||||
$row[] = $student_data['firstname'];
|
||||
}
|
||||
$string_date = Tracking::get_last_connection_date($student_id, true);
|
||||
$first_date = Tracking::get_first_connection_date($student_id);
|
||||
$row[] = $first_date;
|
||||
$row[] = $string_date;
|
||||
|
||||
$detailsLink = Display::url(
|
||||
Display::return_icon('2rightarrow.png', get_lang('Details').' '.$student_data['username']),
|
||||
$urlDetails,
|
||||
['id' => 'details_'.$student_data['username']]
|
||||
);
|
||||
$row[] = $detailsLink;
|
||||
$all_datas[] = $row;
|
||||
}
|
||||
|
||||
return $all_datas;
|
||||
}
|
||||
|
||||
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();
|
||||
$actionsLeft = '';
|
||||
if (api_is_drh()) {
|
||||
$menu_items = [
|
||||
Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
|
||||
),
|
||||
Display::url(Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM), 'student.php'),
|
||||
Display::url(
|
||||
Display::return_icon('teacher_na.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
),
|
||||
Display::url(Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM), 'course.php'),
|
||||
Display::url(
|
||||
Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
'session.php'
|
||||
),
|
||||
];
|
||||
|
||||
$nb_menu_items = count($menu_items);
|
||||
if ($nb_menu_items > 1) {
|
||||
foreach ($menu_items as $key => $item) {
|
||||
$actionsLeft .= $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$actionsRight = '';
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), [], ICON_SIZE_MEDIUM),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print();']
|
||||
);
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?export=csv&keyword='.$keyword
|
||||
);
|
||||
|
||||
$toolbar = Display::toolbarAction('toolbar-teachers', [$actionsLeft, $actionsRight]);
|
||||
|
||||
$table = new SortableTable(
|
||||
'tracking_teachers',
|
||||
'get_count_users',
|
||||
'get_users',
|
||||
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
|
||||
10
|
||||
);
|
||||
|
||||
$params = [
|
||||
'keyword' => $keyword,
|
||||
'active' => $active,
|
||||
'sleeping_days' => $sleepingDays,
|
||||
];
|
||||
$table->set_additional_parameters($params);
|
||||
|
||||
if ($is_western_name_order) {
|
||||
$table->set_header(0, get_lang('FirstName'), false);
|
||||
$table->set_header(1, get_lang('LastName'), false);
|
||||
} else {
|
||||
$table->set_header(0, get_lang('LastName'), false);
|
||||
$table->set_header(1, get_lang('FirstName'), false);
|
||||
}
|
||||
|
||||
$table->set_header(2, get_lang('FirstLogin'), false);
|
||||
$table->set_header(3, get_lang('LastConnexion'), false);
|
||||
$table->set_header(4, get_lang('Details'), false);
|
||||
|
||||
if ($export_csv) {
|
||||
if ($is_western_name_order) {
|
||||
$csv_header[] = [
|
||||
get_lang('FirstName'),
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
} else {
|
||||
$csv_header[] = [
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH).'mySpace/teachers.php');
|
||||
$form = Tracking::setUserSearchForm($form);
|
||||
$form->setDefaults($params);
|
||||
|
||||
if ($export_csv) {
|
||||
// send the csv file if asked
|
||||
$content = $table->get_table_data();
|
||||
foreach ($content as &$row) {
|
||||
$row[3] = strip_tags($row[3]);
|
||||
unset($row[4]);
|
||||
}
|
||||
$csv_content = array_merge($csv_header, $content);
|
||||
ob_end_clean();
|
||||
Export::arrayToCsv($csv_content, 'reporting_teacher_list');
|
||||
exit;
|
||||
} else {
|
||||
Display::display_header($nameTools);
|
||||
echo $toolbar;
|
||||
$page_title = get_lang('Teachers');
|
||||
echo Display::page_subheader($page_title);
|
||||
if (isset($active)) {
|
||||
if ($active) {
|
||||
$activeLabel = get_lang('ActiveUsers');
|
||||
} else {
|
||||
$activeLabel = get_lang('InactiveUsers');
|
||||
}
|
||||
echo Display::page_subheader2($activeLabel);
|
||||
}
|
||||
$form->display();
|
||||
$table->display();
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
211
main/mySpace/ti_report.php
Normal file
211
main/mySpace/ti_report.php
Normal file
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$csv_content = [];
|
||||
$nameTools = get_lang('MySpace');
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true);
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$userInfo = [];
|
||||
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
|
||||
$content = '';
|
||||
switch ($action) {
|
||||
case 'add_user':
|
||||
break;
|
||||
}
|
||||
|
||||
Display::display_header($nameTools);
|
||||
echo '<div class="actions">';
|
||||
echo MySpace::getTopMenu();
|
||||
echo '</div>';
|
||||
echo MySpace::getAdminActions();
|
||||
|
||||
echo '<style>
|
||||
.session_block {
|
||||
width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
.session_block .label {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
table th{
|
||||
text-align: center;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
</style>';
|
||||
|
||||
$form = new FormValidator('users', 'get', api_get_self().'?a=users_active');
|
||||
$form->addDateRangePicker(
|
||||
'daterange',
|
||||
get_lang('DateRange'),
|
||||
true,
|
||||
['format' => 'YYYY-MM-DD', 'timePicker' => 'false', 'validate_format' => 'Y-m-d']
|
||||
);
|
||||
$form->addHidden('a', 'users_active');
|
||||
$form->addButtonFilter(get_lang('Search'));
|
||||
|
||||
$weekFormat = 'oW';
|
||||
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
$startDate = Database::escape_string($values['daterange_start']);
|
||||
$endDate = Database::escape_string($values['daterange_end']);
|
||||
//$startDate = Database::escape_string($_REQUEST['daterange_start']);
|
||||
//$endDate = Database::escape_string($_REQUEST['daterange_end']);
|
||||
|
||||
$date = new DateTime($startDate);
|
||||
$weekStart = $date->format($weekFormat);
|
||||
|
||||
$date = new DateTime($endDate);
|
||||
$weekEnd = $date->format($weekFormat);
|
||||
$first = DateTime::createFromFormat('Y-m-d', $startDate);
|
||||
$second = DateTime::createFromFormat('Y-m-d', $endDate);
|
||||
$numberOfWeeks = floor($first->diff($second)->days / 7);
|
||||
|
||||
$sql = " SELECT id_coach, name, id as session_id, display_start_date, display_end_date
|
||||
FROM session
|
||||
WHERE display_start_date BETWEEN '$startDate' AND '$endDate'
|
||||
ORDER BY id_coach";
|
||||
$result = Database::query($sql);
|
||||
|
||||
$coachList = [];
|
||||
while ($row = Database::fetch_array($result, 'ASSOC')) {
|
||||
$coachId = $row['id_coach'];
|
||||
if (!isset($coachList[$coachId])) {
|
||||
$userInfo = api_get_user_info($coachId);
|
||||
$coachList[$coachId]['complete_name'] = $userInfo['complete_name'];
|
||||
$coachList[$coachId]['session_count'] = 0;
|
||||
}
|
||||
|
||||
// Start
|
||||
$date = new DateTime($row['display_start_date']);
|
||||
$week = $date->format($weekFormat);
|
||||
$coachList[$coachId]['week'][$week]['sessions'][] = $row;
|
||||
|
||||
// End
|
||||
$endDate = new DateTime($row['display_end_date']);
|
||||
$endWeek = $endDate->format($weekFormat);
|
||||
|
||||
$numberOfWeeksBetween = floor($date->diff($endDate)->days / 7);
|
||||
|
||||
for ($i = 0; $i < $numberOfWeeksBetween; $i++) {
|
||||
$date->add(new DateInterval('P1W'));
|
||||
$week = $date->format($weekFormat);
|
||||
$coachList[$coachId]['week'][$week]['sessions'][] = $row;
|
||||
}
|
||||
|
||||
$coachList[$coachId]['session_count']++;
|
||||
$coachList[$coachId]['data'] = $row;
|
||||
}
|
||||
|
||||
$table = new HTML_Table(['class' => 'table table-responsive']);
|
||||
$headers = [
|
||||
get_lang('Coach'),
|
||||
get_lang('Sessions'),
|
||||
];
|
||||
|
||||
$date = new DateTime($startDate);
|
||||
for ($i = 0; $i <= $numberOfWeeks; $i++) {
|
||||
$headers[] = $date->format('o-W');
|
||||
$date->add(new DateInterval('P1W'));
|
||||
}
|
||||
|
||||
$width = ' width:300px;';
|
||||
$row = 0;
|
||||
$column = 0;
|
||||
foreach ($headers as $header) {
|
||||
$table->setHeaderContents($row, $column, $header);
|
||||
$table->updateCellAttributes(
|
||||
$row,
|
||||
$column,
|
||||
'style="'.$width.'"'
|
||||
);
|
||||
$column++;
|
||||
}
|
||||
$row++;
|
||||
$url = api_get_path(WEB_CODE_PATH).'session/resume_session.php?';
|
||||
foreach ($coachList as $coachData) {
|
||||
$column = 0;
|
||||
$table->updateCellAttributes(
|
||||
$row,
|
||||
$column,
|
||||
'style="'.$width.'"'
|
||||
);
|
||||
$table->setCellContents($row, $column++, $coachData['complete_name']);
|
||||
|
||||
$table->updateCellAttributes(
|
||||
$row,
|
||||
$column,
|
||||
'style="'.$width.'"'
|
||||
);
|
||||
$table->setCellContents($row, $column++, $coachData['session_count']);
|
||||
|
||||
$date = new DateTime($startDate);
|
||||
$sessionAdded = [];
|
||||
for ($i = 2; $i <= $numberOfWeeks; $i++) {
|
||||
$dateWeekToCheck = $date->format($weekFormat);
|
||||
if (isset($coachData['week'][$dateWeekToCheck])) {
|
||||
$sessionArray = [];
|
||||
foreach ($coachData['week'][$dateWeekToCheck]['sessions'] as $session) {
|
||||
$date2 = new DateTime($session['display_start_date']);
|
||||
$name = $session['name'];
|
||||
|
||||
$showName = true;
|
||||
if (in_array($session['session_id'], $sessionAdded)) {
|
||||
$showName = false;
|
||||
} else {
|
||||
$sessionAdded[] = $session['session_id'];
|
||||
}
|
||||
|
||||
if (false === $showName) {
|
||||
$name = '';
|
||||
}
|
||||
$sessionArray[] = Display::url(
|
||||
$name,
|
||||
$url.'id_session='.$session['session_id'],
|
||||
['class' => 'label label-success', 'target' => '_blank', 'title' => addslashes($session['name'])]
|
||||
);
|
||||
}
|
||||
$value = implode('<br /><br />', $sessionArray);
|
||||
$value = "<div class='session_block'> $value </div>";
|
||||
$table->setCellContents($row, $i, $value);
|
||||
$table->updateCellAttributes(
|
||||
$row,
|
||||
$i,
|
||||
'style="background:green; '.$width.'"'
|
||||
);
|
||||
} else {
|
||||
$table->setCellContents($row, $i, '<div class="session_block"></div>');
|
||||
$table->updateCellAttributes(
|
||||
$row,
|
||||
$i,
|
||||
'style="'.$width.'"'
|
||||
);
|
||||
}
|
||||
$date->add(new DateInterval('P1W'));
|
||||
}
|
||||
$row++;
|
||||
}
|
||||
|
||||
$content = $table->toHtml();
|
||||
}
|
||||
|
||||
echo $form->returnForm();
|
||||
echo $content;
|
||||
|
||||
Display::display_footer();
|
||||
124
main/mySpace/time_report.php
Normal file
124
main/mySpace/time_report.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users(true);
|
||||
|
||||
if (api_is_student()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$formValidator = new FormValidator('time_report_form', 'post', api_get_self());
|
||||
|
||||
// Get the list of users based on the role
|
||||
$userId = api_get_user_id();
|
||||
$userOptions = [];
|
||||
|
||||
if (api_is_platform_admin() || (api_is_session_admin() && api_get_setting('prevent_session_admins_to_manage_all_users') !== 'true')) {
|
||||
$userList = UserManager::get_user_list();
|
||||
} else {
|
||||
$userList = $studentList = UserManager::getUsersFollowedByUser(
|
||||
$userId,
|
||||
STUDENT,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
COURSEMANAGER
|
||||
);
|
||||
}
|
||||
|
||||
$formValidator->addElement('checkbox', 'select_all_users', get_lang('SelectAllUsers'), null, ['id' => 'select_all_users']);
|
||||
$userOptions = [];
|
||||
foreach ($userList as $user) {
|
||||
$userOptions[$user['user_id']] = $user['lastname'].' '.$user['firstname'];
|
||||
}
|
||||
$formValidator->addElement('select', 'users', get_lang('SelectUsers'), $userOptions, [
|
||||
'multiple' => 'multiple',
|
||||
'id' => 'user_selector',
|
||||
]);
|
||||
|
||||
$htmlHeadXtra[] = '
|
||||
<script>
|
||||
$(function() {
|
||||
var selectAllCheckbox = $("#select_all_users");
|
||||
var userSelector = $("#user_selector");
|
||||
|
||||
userSelector.select2({
|
||||
placeholder: "'.get_lang('SelectAnOption').'",
|
||||
allowClear: true,
|
||||
width: "100%"
|
||||
});
|
||||
|
||||
selectAllCheckbox.on("change", function() {
|
||||
if (this.checked) {
|
||||
var allOptions = userSelector.find("option");
|
||||
var allValues = [];
|
||||
allOptions.each(function() {
|
||||
allValues.push($(this).val());
|
||||
});
|
||||
userSelector.val(allValues).trigger("change");
|
||||
} else {
|
||||
userSelector.val(null).trigger("change");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
// Date selectors
|
||||
$formValidator->addDatePicker('start_date', get_lang('StartDate'));
|
||||
$formValidator->addDatePicker('end_date', get_lang('EndDate'));
|
||||
|
||||
// Report type selector
|
||||
$reportTypeValues = [
|
||||
'time_report' => get_lang('TimeReport'),
|
||||
'billing_report' => get_lang('BillingReport'),
|
||||
];
|
||||
$formValidator->addElement('select', 'report_type', get_lang('ReportType'), $reportTypeValues);
|
||||
|
||||
// Button to generate the report
|
||||
$formValidator->addButtonSend(get_lang('GenerateReport'));
|
||||
|
||||
// Form validation rules
|
||||
$formValidator->addRule('start_date', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$formValidator->addRule('end_date', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$formValidator->addRule('users', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$formValidator->addRule('report_type', get_lang('ThisFieldIsRequired'), 'required');
|
||||
|
||||
if ($formValidator->validate()) {
|
||||
$values = $formValidator->exportValues();
|
||||
$users = $values['users'];
|
||||
$startDate = $values['start_date'];
|
||||
$endDate = $values['end_date'];
|
||||
$reportType = $values['report_type'];
|
||||
$exportXls = isset($_POST['export']);
|
||||
|
||||
if (empty($users)) {
|
||||
Display::addFlash(Display::return_message(get_lang('NoUsersSelected'), 'warning'));
|
||||
} else {
|
||||
$data = Tracking::generateReport($reportType, $users, $startDate, $endDate);
|
||||
if (empty($data)) {
|
||||
Display::addFlash(Display::return_message(get_lang('NoDataToExport'), 'warning'));
|
||||
} else {
|
||||
$headers = $data['headers'];
|
||||
$rows = $data['rows'];
|
||||
array_unshift($rows, $headers);
|
||||
$fileName = get_lang('Export').'-'.$reportTypeValues[$reportType].'_'.api_get_local_time();
|
||||
Export::arrayToCsv($rows, $fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nameTools = get_lang('TimeReport');
|
||||
Display::display_header($nameTools);
|
||||
|
||||
$formValidator->display();
|
||||
|
||||
Display::display_footer();
|
||||
187
main/mySpace/user_edit.php
Normal file
187
main/mySpace/user_edit.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
// including necessary libraries
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
// user permissions
|
||||
api_block_anonymous_users();
|
||||
|
||||
if (!api_is_platform_admin()) {
|
||||
if (!api_is_drh()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
} else {
|
||||
api_protect_admin_script();
|
||||
}
|
||||
|
||||
$userId = isset($_REQUEST['user_id']) ? intval($_REQUEST['user_id']) : '';
|
||||
|
||||
$userInfo = api_get_user_info($userId);
|
||||
if (empty($userInfo)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$userIsFollowed = UserManager::is_user_followed_by_drh($userId, api_get_user_id());
|
||||
|
||||
if (api_drh_can_access_all_session_content()) {
|
||||
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
|
||||
'drh_all',
|
||||
api_get_user_id(),
|
||||
false,
|
||||
0, //$from,
|
||||
null, //$limit,
|
||||
null, //$column,
|
||||
'desc', //$direction,
|
||||
null, //$keyword,
|
||||
null, //$active,
|
||||
null, //$lastConnectionDate,
|
||||
null,
|
||||
null,
|
||||
STUDENT
|
||||
);
|
||||
|
||||
if (empty($students)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$userIdList = [];
|
||||
foreach ($students as $student) {
|
||||
$userIdList[] = $student['user_id'];
|
||||
}
|
||||
|
||||
if (!in_array($userId, $userIdList)) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
} else {
|
||||
if (!api_is_platform_admin() && !$userIsFollowed) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
}
|
||||
|
||||
$url = api_get_self().'?user_id='.$userId;
|
||||
$tool_name = get_lang('ModifyUserInfo');
|
||||
// Create the form
|
||||
$form = new FormValidator('user_edit', 'post', $url);
|
||||
// Username
|
||||
$usernameInput = $form->addElement('text', 'username', get_lang('LoginName'));
|
||||
$usernameInput->freeze();
|
||||
|
||||
// Password
|
||||
$group = [];
|
||||
$auth_sources = 0; //make available wider as we need it in case of form reset (see below)
|
||||
$group[] = &$form->createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword').'<br />', 1);
|
||||
$group[] = &$form->createElement('radio', 'password_auto', 'id="radio_user_password"', null, 0);
|
||||
$group[] = &$form->createElement('password', 'password', null, ['onkeydown' => 'javascript: password_switch_radio_button(document.user_add,"password[password_auto]");']);
|
||||
$form->addGroup($group, 'password', get_lang('Password'));
|
||||
|
||||
// Send email
|
||||
$group = [];
|
||||
$group[] = &$form->createElement('radio', 'send_mail', null, get_lang('Yes'), 1);
|
||||
$group[] = &$form->createElement('radio', 'send_mail', null, get_lang('No'), 0);
|
||||
$form->addGroup($group, 'mail', get_lang('SendMailToNewUser'));
|
||||
|
||||
// Set default values
|
||||
$defaults = [];
|
||||
$defaults['username'] = $userInfo['username'];
|
||||
$defaults['mail']['send_mail'] = 0;
|
||||
$defaults['password']['password_auto'] = 1;
|
||||
|
||||
$form->setDefaults($defaults);
|
||||
// Submit button
|
||||
$select_level = [];
|
||||
$html_results_enabled[] = $form->addButtonUpdate(get_lang('Update'), 'submit', true);
|
||||
$form->addGroup($html_results_enabled);
|
||||
// Validate form
|
||||
if ($form->validate()) {
|
||||
$check = Security::check_token('post');
|
||||
if ($check) {
|
||||
$user = $form->exportValues();
|
||||
$email = $userInfo['email'];
|
||||
$username = $userInfo['username'];
|
||||
$send_mail = intval($user['mail']['send_mail']);
|
||||
$auth_source = PLATFORM_AUTH_SOURCE;
|
||||
$resetPassword = $user['password']['password_auto'] == '1' ? 0 : 2;
|
||||
$auth_source = $userInfo['auth_source'];
|
||||
$password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password'];
|
||||
|
||||
UserManager::update_user(
|
||||
$userId,
|
||||
$userInfo['firstname'],
|
||||
$userInfo['lastname'],
|
||||
$userInfo['username'],
|
||||
$password,
|
||||
$auth_source,
|
||||
$userInfo['email'],
|
||||
$userInfo['status'],
|
||||
$userInfo['official_code'],
|
||||
$userInfo['phone'],
|
||||
$userInfo['picture_uri'],
|
||||
$userInfo['expiration_date'],
|
||||
$userInfo['active'],
|
||||
$userInfo['creator_id'],
|
||||
$userInfo['hr_dept_id'],
|
||||
null, //$extra =
|
||||
$userInfo['language'],
|
||||
null, //$encrypt_method
|
||||
false,
|
||||
$resetPassword
|
||||
);
|
||||
|
||||
if (!empty($email) && $send_mail) {
|
||||
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
|
||||
$portal_url = api_get_path(WEB_PATH);
|
||||
if (api_is_multiple_url_enabled()) {
|
||||
$access_url_id = api_get_current_access_url_id();
|
||||
if ($access_url_id != -1) {
|
||||
$url = api_get_access_url($access_url_id);
|
||||
$portal_url = $url['url'];
|
||||
}
|
||||
}
|
||||
|
||||
$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($userInfo['firstname'], $userInfo['lastname'])).",\n\n".
|
||||
get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".
|
||||
get_lang('Username')." : ".$username."\n".get_lang('Pass')." : ".stripslashes($password)."\n\n".
|
||||
get_lang('Address')." ".api_get_setting('siteName')." ".
|
||||
get_lang('Is')." : ".$portal_url."\n\n".
|
||||
get_lang('Problem')."\n\n".
|
||||
get_lang('SignatureFormula').",\n\n".
|
||||
api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".
|
||||
get_lang('Manager')." ".
|
||||
api_get_setting('siteName')."\nT. ".
|
||||
api_get_setting('administratorTelephone')."\n".
|
||||
get_lang('Email')." : ".api_get_setting('emailAdministrator');
|
||||
$emailbody = nl2br($emailbody);
|
||||
|
||||
MessageManager::send_message_simple($userInfo['user_id'], $emailsubject, $emailbody);
|
||||
}
|
||||
|
||||
Security::clear_token();
|
||||
$tok = Security::get_token();
|
||||
header('Location: '.$url.'&message=1');
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
if (isset($_POST['submit'])) {
|
||||
Security::clear_token();
|
||||
}
|
||||
$token = Security::get_token();
|
||||
$form->addElement('hidden', 'sec_token');
|
||||
$form->setConstants(['sec_token' => $token]);
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_CODE_PATH)."mySpace/student.php",
|
||||
"name" => get_lang('UserList'),
|
||||
];
|
||||
|
||||
if (isset($_REQUEST['message'])) {
|
||||
Display::addFlash(Display::return_message(get_lang('Updated'), 'normal'));
|
||||
}
|
||||
|
||||
Display::display_header($tool_name);
|
||||
// Display form
|
||||
$form->display();
|
||||
|
||||
Display::display_footer();
|
||||
165
main/mySpace/user_import.php
Normal file
165
main/mySpace/user_import.php
Normal file
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
/**
|
||||
* This tool allows platform admins to add users by uploading a CSV or XML file
|
||||
* This code is inherited from admin/user_import.php.
|
||||
*
|
||||
* Created on 26 julio 2008 by Julio Montoya gugli100@gmail.com
|
||||
*/
|
||||
$cidReset = true;
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
$this_section = SECTION_PLATFORM_ADMIN; // TODO: Platform admin section?
|
||||
|
||||
$tool_name = get_lang('ImportUserListXMLCSV');
|
||||
api_block_anonymous_users();
|
||||
|
||||
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
|
||||
$id_session = '';
|
||||
if (isset($_GET['id_session']) && $_GET['id_session'] != '') {
|
||||
$id_session = intval($_GET['id_session']);
|
||||
$interbreadcrumb[] = ['url' => 'session.php', 'name' => get_lang('Sessions')];
|
||||
$interbreadcrumb[] = ['url' => 'course.php?id_session='.$id_session.'', 'name' => get_lang('Course')];
|
||||
}
|
||||
|
||||
// Set this option to true to enforce strict purification for usenames.
|
||||
$purification_option_for_usernames = false;
|
||||
|
||||
// Checking whether the current coach is the admin coach.
|
||||
if (api_get_setting('add_users_by_coach') === 'true') {
|
||||
if (!api_is_platform_admin()) {
|
||||
if (isset($_REQUEST['id_session'])) {
|
||||
$id_session = intval($_REQUEST['id_session']);
|
||||
$sql = 'SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).'
|
||||
WHERE id='.$id_session;
|
||||
$rs = Database::query($sql);
|
||||
if (Database::result($rs, 0, 0) != $_user['user_id']) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
} else {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
set_time_limit(0);
|
||||
$errors = [];
|
||||
if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {
|
||||
$file_type = $_POST['file_type'];
|
||||
$id_session = intval($_POST['id_session']);
|
||||
if ($file_type == 'csv') {
|
||||
$users = MySpace::parse_csv_data($_FILES['import_file']['tmp_name']);
|
||||
} else {
|
||||
$users = MySpace::parse_xml_data($_FILES['import_file']['tmp_name']);
|
||||
}
|
||||
if (count($users) > 0) {
|
||||
$results = MySpace::validate_data($users);
|
||||
$errors = $results['errors'];
|
||||
$users = $results['users'];
|
||||
|
||||
if (count($errors) == 0) {
|
||||
if (!empty($id_session)) {
|
||||
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
|
||||
// Selecting all the courses from the session id requested.
|
||||
$sql = "SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'";
|
||||
$result = Database::query($sql);
|
||||
$course_list = [];
|
||||
while ($row = Database::fetch_array($result)) {
|
||||
$course_list[] = $row['c_id'];
|
||||
}
|
||||
$errors = MySpace::get_user_creator($users);
|
||||
$users = MySpace::check_all_usernames($users, $course_list, $id_session);
|
||||
if (count($errors) == 0) {
|
||||
MySpace::save_data($users, $course_list, $id_session);
|
||||
}
|
||||
} else {
|
||||
Display::addFlash(Display::return_message(get_lang('NoSessionId'), 'warning'));
|
||||
header('Location: course.php?id_session='.$id_session);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Display::addFlash(Display::return_message(get_lang('NoUsersRead'), 'warning'));
|
||||
header('Location: course.php?id_session='.$id_session);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
Display::display_header($tool_name);
|
||||
|
||||
if (isset($_FILES['import_file']) && $_FILES['import_file']['size'] == 0 && $_POST) {
|
||||
echo Display::return_message(get_lang('ThisFieldIsRequired'), 'error');
|
||||
}
|
||||
|
||||
if (count($errors) != 0) {
|
||||
$error_message = '<ul>';
|
||||
foreach ($errors as $index => $error_user) {
|
||||
$error_message .= '<li><strong>'.$error_user['error'].'</strong>: ';
|
||||
$error_message .= api_get_person_name($error_user['FirstName'], $error_user['LastName']);
|
||||
$error_message .= '</li>';
|
||||
}
|
||||
$error_message .= '</ul>';
|
||||
echo Display::return_message($error_message, 'error', false);
|
||||
}
|
||||
|
||||
$form = new FormValidator('user_import');
|
||||
$form->addElement('hidden', 'formSent');
|
||||
$form->addElement('hidden', 'id_session', $id_session);
|
||||
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
|
||||
$form->addRule('import_file', get_lang('ThisFieldIsRequired'), 'required');
|
||||
$allowed_file_types = ['xml', 'csv'];
|
||||
$form->addRule('import_file', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'file_type',
|
||||
get_lang('FileType'),
|
||||
'XML (<a href="../admin/example.xml" target="_blank" download>'.get_lang('ExampleXMLFile').'</a>)',
|
||||
'xml'
|
||||
);
|
||||
$form->addElement(
|
||||
'radio',
|
||||
'file_type',
|
||||
null,
|
||||
'CSV (<a href="../admin/example.csv" target="_blank" download>'.get_lang('ExampleCSVFile').'</a>)',
|
||||
'csv'
|
||||
);
|
||||
$form->addElement('radio', 'sendMail', get_lang('SendMailToUsers'), get_lang('Yes'), 1);
|
||||
$form->addElement('radio', 'sendMail', null, get_lang('No'), 0);
|
||||
$form->addElement('submit', 'submit', get_lang('Ok'));
|
||||
$defaults['formSent'] = 1;
|
||||
$defaults['sendMail'] = 0;
|
||||
$defaults['file_type'] = 'xml';
|
||||
$form->setDefaults($defaults);
|
||||
$form->display();
|
||||
?>
|
||||
<p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
<b>LastName</b>;<b>FirstName</b>;<b>Email</b>;UserName;Password;OfficialCode;PhoneNumber;
|
||||
<b>Montoya</b>;<b>Julio</b>;<b>info@localhost</b>;jmontoya;123456789;code1;3141516
|
||||
<b>Doewing</b>;<b>Johny</b>;<b>info@localhost</b>;jdoewing;123456789;code2;3141516
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
<p><?php echo get_lang('XMLMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
|
||||
<blockquote>
|
||||
<pre>
|
||||
<?xml version="1.0" encoding="<?php echo api_refine_encoding_id(api_get_system_encoding()); ?>"?>
|
||||
<Contacts>
|
||||
<Contact>
|
||||
<b><LastName>Montoya</LastName></b>
|
||||
<b><FirstName>Julio</FirstName></b>
|
||||
<b><Email>info@localhost</Email></b>
|
||||
<UserName>jmontoya</UserName>
|
||||
<Password>123456</Password>
|
||||
<OfficialCode>code1</OfficialCode>
|
||||
<PhoneNumber>3141516</PhoneNumber>
|
||||
</Contact>
|
||||
</Contacts>
|
||||
</pre>
|
||||
</blockquote>
|
||||
<?php
|
||||
Display::display_footer();
|
||||
422
main/mySpace/users.php
Normal file
422
main/mySpace/users.php
Normal file
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Report on users followed (filtered by status given in URL).
|
||||
*/
|
||||
$cidReset = true;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users();
|
||||
|
||||
$allowToTrack = api_is_platform_admin(true, true) ||
|
||||
api_is_teacher() ||
|
||||
api_is_student_boss();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$nameTools = get_lang('Users');
|
||||
$export_csv = isset($_GET['export']) && 'csv' === $_GET['export'] ? true : false;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? intval($_GET['sleeping_days']) : null;
|
||||
$status = isset($_GET['status']) ? Security::remove_XSS($_GET['status']) : null;
|
||||
|
||||
$webCodePath = api_get_path(WEB_CODE_PATH);
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "index.php",
|
||||
"name" => get_lang('MySpace'),
|
||||
];
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
|
||||
$interbreadcrumb[] = [
|
||||
"url" => "teachers.php",
|
||||
"name" => get_lang('Teachers'),
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && isset($_GET["type"]) && $_GET["type"] === "coach") {
|
||||
$interbreadcrumb[] = ["url" => "coaches.php", "name" => get_lang('Tutors')];
|
||||
}
|
||||
|
||||
function get_count_users()
|
||||
{
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? (int) $_GET['sleeping_days'] : null;
|
||||
$active = isset($_GET['active']) ? (int) $_GET['active'] : 1;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$status = !empty($_GET['status']) ? Security::remove_XSS($_GET['status']) : null;
|
||||
|
||||
$lastConnectionDate = null;
|
||||
if (!empty($sleepingDays)) {
|
||||
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
|
||||
}
|
||||
|
||||
$usersCount = 0;
|
||||
$allowDhrAccessToAllStudents = api_get_configuration_value('drh_allow_access_to_all_students');
|
||||
if ($allowDhrAccessToAllStudents) {
|
||||
$conditions = [];
|
||||
if (isset($status)) {
|
||||
$conditions['status'] = $status;
|
||||
}
|
||||
if (isset($active)) {
|
||||
$conditions['active'] = (int) $active;
|
||||
}
|
||||
$usersCount = UserManager::get_user_list(
|
||||
$conditions,
|
||||
[],
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
$keyword,
|
||||
$lastConnectionDate,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$usersCount = SessionManager::getCountUserTracking(
|
||||
$keyword,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
null,
|
||||
null,
|
||||
$status
|
||||
);
|
||||
}
|
||||
|
||||
return $usersCount;
|
||||
}
|
||||
|
||||
function get_users($from, $limit, $column, $direction)
|
||||
{
|
||||
$active = isset($_GET['active']) ? $_GET['active'] : 1;
|
||||
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
|
||||
$sleepingDays = isset($_GET['sleeping_days']) ? (int) $_GET['sleeping_days'] : null;
|
||||
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
|
||||
$status = !empty($_GET['status']) ? Security::remove_XSS($_GET['status']) : null;
|
||||
|
||||
$lastConnectionDate = null;
|
||||
if (!empty($sleepingDays)) {
|
||||
$lastConnectionDate = api_get_utc_datetime(strtotime($sleepingDays.' days ago'));
|
||||
}
|
||||
$is_western_name_order = api_is_western_name_order();
|
||||
$coach_id = api_get_user_id();
|
||||
$drhLoaded = false;
|
||||
|
||||
if (api_is_drh()) {
|
||||
if (api_drh_can_access_all_session_content()) {
|
||||
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
|
||||
'drh_all',
|
||||
api_get_user_id(),
|
||||
false,
|
||||
$from,
|
||||
$limit,
|
||||
'',
|
||||
$direction,
|
||||
$keyword,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
null,
|
||||
null,
|
||||
$status
|
||||
);
|
||||
$drhLoaded = true;
|
||||
}
|
||||
$allowDhrAccessToAllStudents = api_get_configuration_value('drh_allow_access_to_all_students');
|
||||
if ($allowDhrAccessToAllStudents) {
|
||||
$conditions = [];
|
||||
if (isset($status)) {
|
||||
$conditions['status'] = $status;
|
||||
}
|
||||
if (isset($active)) {
|
||||
$conditions['active'] = (int) $active;
|
||||
}
|
||||
$students = UserManager::get_user_list(
|
||||
$conditions,
|
||||
[],
|
||||
$from,
|
||||
$limit,
|
||||
null,
|
||||
$keyword,
|
||||
$lastConnectionDate
|
||||
);
|
||||
$drhLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $drhLoaded) {
|
||||
$checkSessionVisibility = api_get_configuration_value('show_users_in_active_sessions_in_tracking');
|
||||
$students = UserManager::getUsersFollowedByUser(
|
||||
api_get_user_id(),
|
||||
$status,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
$from,
|
||||
$limit,
|
||||
'',
|
||||
$direction,
|
||||
$active,
|
||||
$lastConnectionDate,
|
||||
COURSEMANAGER,
|
||||
$keyword,
|
||||
$checkSessionVisibility
|
||||
);
|
||||
}
|
||||
|
||||
$all_datas = [];
|
||||
foreach ($students as $student_data) {
|
||||
$student_id = $student_data['user_id'];
|
||||
$student_data = api_get_user_info($student_id);
|
||||
if (isset($_GET['id_session'])) {
|
||||
$courses = Tracking::get_course_list_in_session_from_student($student_id, $sessionId);
|
||||
}
|
||||
|
||||
$avg_time_spent = $avg_student_score = $avg_student_progress = 0;
|
||||
$nb_courses_student = 0;
|
||||
if (!empty($courses)) {
|
||||
foreach ($courses as $course_code) {
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
|
||||
if (CourseManager::is_user_subscribed_in_course($student_id, $course_code, true)) {
|
||||
$avg_time_spent += Tracking::get_time_spent_on_the_course(
|
||||
$student_id,
|
||||
$courseId,
|
||||
$_GET['id_session']
|
||||
);
|
||||
$my_average = Tracking::get_avg_student_score($student_id, $course_code);
|
||||
if (is_numeric($my_average)) {
|
||||
$avg_student_score += $my_average;
|
||||
}
|
||||
$avg_student_progress += Tracking::get_avg_student_progress($student_id, $course_code);
|
||||
$nb_courses_student++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nb_courses_student > 0) {
|
||||
$avg_time_spent = $avg_time_spent / $nb_courses_student;
|
||||
$avg_student_score = $avg_student_score / $nb_courses_student;
|
||||
$avg_student_progress = $avg_student_progress / $nb_courses_student;
|
||||
} else {
|
||||
$avg_time_spent = null;
|
||||
$avg_student_score = null;
|
||||
$avg_student_progress = null;
|
||||
}
|
||||
|
||||
$row = [];
|
||||
if ($is_western_name_order) {
|
||||
$row[] = $student_data['firstname'];
|
||||
$row[] = $student_data['lastname'];
|
||||
} else {
|
||||
$row[] = $student_data['lastname'];
|
||||
$row[] = $student_data['firstname'];
|
||||
}
|
||||
|
||||
$string_date = Tracking::get_last_connection_date($student_id, true);
|
||||
$first_date = Tracking::get_first_connection_date($student_id);
|
||||
$row[] = $first_date;
|
||||
$row[] = $string_date;
|
||||
|
||||
if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
|
||||
$detailsLink = '<a href="myStudents.php?student='.$student_id.'&id_coach='.$coach_id.'&id_session='.$sessionId.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a>';
|
||||
} else {
|
||||
$detailsLink = '<a href="myStudents.php?student='.$student_id.'">
|
||||
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a>';
|
||||
}
|
||||
|
||||
$row[] = $detailsLink;
|
||||
$all_datas[] = $row;
|
||||
}
|
||||
|
||||
return $all_datas;
|
||||
}
|
||||
|
||||
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();
|
||||
$actionsLeft = '';
|
||||
|
||||
if (api_is_drh()) {
|
||||
$menu_items = [
|
||||
Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'auth/my_progress.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('user_na.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
|
||||
'teachers.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM),
|
||||
'course.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('session.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
|
||||
'session.php'
|
||||
),
|
||||
Display::url(
|
||||
Display::return_icon('skills.png', get_lang('Skills'), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'social/my_skills_report.php'
|
||||
),
|
||||
];
|
||||
|
||||
$nb_menu_items = count($menu_items);
|
||||
if ($nb_menu_items > 1) {
|
||||
foreach ($menu_items as $key => $item) {
|
||||
$actionsLeft .= $item;
|
||||
}
|
||||
}
|
||||
} elseif (api_is_student_boss()) {
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'auth/my_progress.php'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('user_na.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
|
||||
'#'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('skills.png', get_lang('Skills'), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'social/my_skills_report.php'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon('statistics.png', get_lang("CompanyReport"), [], ICON_SIZE_MEDIUM),
|
||||
$webCodePath.'mySpace/company_reports.php'
|
||||
);
|
||||
$actionsLeft .= Display::url(
|
||||
Display::return_icon(
|
||||
'certificate_list.png',
|
||||
get_lang('GradebookSeeListOfStudentsCertificates'),
|
||||
[],
|
||||
ICON_SIZE_MEDIUM
|
||||
),
|
||||
$webCodePath.'gradebook/certificate_report.php'
|
||||
);
|
||||
}
|
||||
|
||||
$actionsRight = Display::url(
|
||||
Display::return_icon('printer.png', get_lang('Print'), [], ICON_SIZE_MEDIUM),
|
||||
'javascript: void(0);',
|
||||
['onclick' => 'javascript: window.print();']
|
||||
);
|
||||
$actionsRight .= Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?export=csv&keyword='.$keyword
|
||||
);
|
||||
|
||||
$toolbar = Display::toolbarAction('toolbar-user', [$actionsLeft, $actionsRight]);
|
||||
|
||||
$itemPerPage = 10;
|
||||
$perPage = api_get_configuration_value('my_space_users_items_per_page');
|
||||
if ($perPage) {
|
||||
$itemPerPage = (int) $perPage;
|
||||
}
|
||||
|
||||
$table = new SortableTable(
|
||||
'tracking_student',
|
||||
'get_count_users',
|
||||
'get_users',
|
||||
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
|
||||
$itemPerPage
|
||||
);
|
||||
|
||||
$params = [
|
||||
'keyword' => $keyword,
|
||||
'active' => $active,
|
||||
'sleeping_days' => $sleepingDays,
|
||||
'status' => $status,
|
||||
];
|
||||
$table->set_additional_parameters($params);
|
||||
|
||||
if ($is_western_name_order) {
|
||||
$table->set_header(0, get_lang('FirstName'), false);
|
||||
$table->set_header(1, get_lang('LastName'), false);
|
||||
} else {
|
||||
$table->set_header(0, get_lang('LastName'), false);
|
||||
$table->set_header(1, get_lang('FirstName'), false);
|
||||
}
|
||||
|
||||
$table->set_header(2, get_lang('FirstLogin'), false);
|
||||
$table->set_header(3, get_lang('LastConnexion'), false);
|
||||
$table->set_header(4, get_lang('Details'), false);
|
||||
|
||||
if ($export_csv) {
|
||||
if ($is_western_name_order) {
|
||||
$csv_header[] = [
|
||||
get_lang('FirstName'),
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
} else {
|
||||
$csv_header[] = [
|
||||
get_lang('LastName'),
|
||||
get_lang('FirstName'),
|
||||
get_lang('FirstLogin'),
|
||||
get_lang('LastConnexion'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$form = new FormValidator(
|
||||
'search_user',
|
||||
'get',
|
||||
$webCodePath.'mySpace/users.php'
|
||||
);
|
||||
$form->addElement(
|
||||
'select',
|
||||
'status',
|
||||
get_lang('Status'),
|
||||
[
|
||||
'' => '',
|
||||
STUDENT => get_lang('Student'),
|
||||
COURSEMANAGER => get_lang('Teacher'),
|
||||
DRH => get_lang('DRH'),
|
||||
]
|
||||
);
|
||||
$form = Tracking::setUserSearchForm($form);
|
||||
$form->setDefaults($params);
|
||||
|
||||
if ($export_csv) {
|
||||
// send the csv file if asked
|
||||
$content = $table->get_table_data();
|
||||
foreach ($content as &$row) {
|
||||
unset($row[4]);
|
||||
}
|
||||
$csv_content = array_merge($csv_header, $content);
|
||||
ob_end_clean();
|
||||
Export::arrayToCsv($csv_content, 'reporting_student_list');
|
||||
exit;
|
||||
} else {
|
||||
Display::display_header($nameTools);
|
||||
echo $toolbar;
|
||||
echo Display::page_subheader($nameTools);
|
||||
if (isset($active)) {
|
||||
if ($active) {
|
||||
$activeLabel = get_lang('ActiveUsers');
|
||||
} else {
|
||||
$activeLabel = get_lang('InactiveUsers');
|
||||
}
|
||||
echo Display::page_subheader2($activeLabel);
|
||||
}
|
||||
$form->display();
|
||||
$table->display();
|
||||
}
|
||||
|
||||
Display::display_footer();
|
||||
205
main/mySpace/work_stats.php
Normal file
205
main/mySpace/work_stats.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
|
||||
|
||||
api_protect_course_script();
|
||||
|
||||
$allowToTrack = api_is_platform_admin() || api_is_allowed_to_edit();
|
||||
|
||||
if (!$allowToTrack) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
$consideredWorkingTime = api_get_configuration_value('considered_working_time');
|
||||
|
||||
if (false === $consideredWorkingTime) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$courseCode = api_get_course_id();
|
||||
$sessionId = api_get_session_id();
|
||||
|
||||
$nameTools = get_lang('Students');
|
||||
|
||||
$this_section = SECTION_TRACKING;
|
||||
$webCodePath = api_get_path(WEB_CODE_PATH);
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_is_student_boss() ? '#' : 'index.php',
|
||||
'name' => get_lang('MySpace'),
|
||||
];
|
||||
|
||||
function get_count_users()
|
||||
{
|
||||
$courseCode = api_get_course_id();
|
||||
$sessionId = api_get_session_id();
|
||||
|
||||
return CourseManager::get_user_list_from_course_code(
|
||||
$courseCode,
|
||||
$sessionId,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
function get_users($from, $number_of_items, $column, $direction)
|
||||
{
|
||||
$consideredWorkingTime = api_get_configuration_value('considered_working_time');
|
||||
|
||||
$courseId = api_get_course_int_id();
|
||||
$courseCode = api_get_course_id();
|
||||
$sessionId = api_get_session_id();
|
||||
$webCodePath = api_get_path(WEB_CODE_PATH);
|
||||
|
||||
$lastConnectionDate = null;
|
||||
$is_western_name_order = api_is_western_name_order();
|
||||
$limit = null;
|
||||
$from = (int) $from;
|
||||
$number_of_items = (int) $number_of_items;
|
||||
$limit = 'LIMIT '.$from.','.$number_of_items;
|
||||
|
||||
$students = CourseManager::get_user_list_from_course_code(
|
||||
$courseCode,
|
||||
$sessionId,
|
||||
$limit,
|
||||
null,
|
||||
null,
|
||||
false
|
||||
);
|
||||
$url = $webCodePath.'mySpace/myStudents.php';
|
||||
|
||||
$workList = getWorkListTeacher(0, 100, null, null, null);
|
||||
|
||||
$workTimeList = [];
|
||||
foreach ($workList as $work) {
|
||||
$fieldValue = new ExtraFieldValue('work');
|
||||
$resultExtra = $fieldValue->getAllValuesForAnItem(
|
||||
$work['id'],
|
||||
true
|
||||
);
|
||||
|
||||
foreach ($resultExtra as $field) {
|
||||
$field = $field['value'];
|
||||
if ($consideredWorkingTime == $field->getField()->getVariable()) {
|
||||
$time = $field->getValue();
|
||||
$parsed = date_parse($time);
|
||||
$workTimeList[$work['id']] = $parsed['hour'] * 3600 + $parsed['minute'] * 60 + $parsed['second'];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$all_datas = [];
|
||||
foreach ($students as $studentData) {
|
||||
$studentId = $studentData['user_id'];
|
||||
$studentData = api_get_user_info($studentId);
|
||||
$urlDetails = $url."?student=$studentId&details=true&course=$courseCode&id_session=$sessionId";
|
||||
$row = [];
|
||||
if ($is_western_name_order) {
|
||||
$first = Display::url($studentData['firstname'], $urlDetails);
|
||||
$last = Display::url($studentData['lastname'], $urlDetails);
|
||||
} else {
|
||||
$first = Display::url($studentData['lastname'], $urlDetails);
|
||||
$last = Display::url($studentData['firstname'], $urlDetails);
|
||||
}
|
||||
|
||||
$row[] = $first;
|
||||
$row[] = $last;
|
||||
|
||||
$timeInSeconds = Tracking::get_time_spent_on_the_course(
|
||||
$studentId,
|
||||
$courseId,
|
||||
$sessionId
|
||||
);
|
||||
|
||||
$row[] = api_time_to_hms($timeInSeconds);
|
||||
|
||||
$userWorkTime = 0;
|
||||
foreach ($workList as $work) {
|
||||
$userWorks = get_work_user_list(
|
||||
0,
|
||||
100,
|
||||
null,
|
||||
null,
|
||||
$work['id'],
|
||||
null,
|
||||
$studentId,
|
||||
false,
|
||||
$courseId,
|
||||
$sessionId
|
||||
);
|
||||
|
||||
if ($userWorks) {
|
||||
foreach ($userWorks as $work) {
|
||||
$userWorkTime += $workTimeList[$work['parent_id']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$row[] = api_time_to_hms($userWorkTime);
|
||||
$status = '';
|
||||
if ($userWorkTime && $timeInSeconds) {
|
||||
if ($userWorkTime > $timeInSeconds) {
|
||||
$status = Display::label('TimeToFix', 'warning');
|
||||
} else {
|
||||
$status = Display::label('Ok', 'success');
|
||||
}
|
||||
}
|
||||
|
||||
$row[] = $status;
|
||||
/*$detailsLink = Display::url(
|
||||
Display::return_icon('2rightarrow.png', get_lang('Details').' '.$studentData['username']),
|
||||
$urlDetails,
|
||||
['id' => 'details_'.$studentData['username']]
|
||||
);
|
||||
$row[] = $detailsLink;*/
|
||||
$all_datas[] = $row;
|
||||
}
|
||||
|
||||
return $all_datas;
|
||||
}
|
||||
|
||||
$is_western_name_order = api_is_western_name_order();
|
||||
$sort_by_first_name = api_sort_by_first_name();
|
||||
$actionsLeft = '';
|
||||
$toolbar = Display::toolbarAction('toolbar-student', [$actionsLeft]);
|
||||
|
||||
$itemPerPage = 10;
|
||||
$perPage = api_get_configuration_value('my_space_users_items_per_page');
|
||||
if ($perPage) {
|
||||
$itemPerPage = (int) $perPage;
|
||||
}
|
||||
|
||||
$table = new SortableTable(
|
||||
'tracking_work_student',
|
||||
'get_count_users',
|
||||
'get_users',
|
||||
($is_western_name_order xor $sort_by_first_name) ? 1 : 0,
|
||||
$itemPerPage
|
||||
);
|
||||
|
||||
$parameters = ['cidReq' => $courseCode, 'id_session' => $sessionId];
|
||||
$table->set_additional_parameters($parameters);
|
||||
|
||||
if ($is_western_name_order) {
|
||||
$table->set_header(0, get_lang('FirstName'), false);
|
||||
$table->set_header(1, get_lang('LastName'), false);
|
||||
} else {
|
||||
$table->set_header(0, get_lang('LastName'), false);
|
||||
$table->set_header(1, get_lang('FirstName'), false);
|
||||
}
|
||||
|
||||
$table->set_header(2, get_lang('TimeSpentInTheCourse'), false);
|
||||
$table->set_header(3, get_lang('TimeSpentOnAssignment'), false);
|
||||
$table->set_header(4, get_lang('Status'), false);
|
||||
|
||||
Display::display_header($nameTools);
|
||||
echo $toolbar;
|
||||
echo Display::page_subheader($nameTools);
|
||||
$table->display();
|
||||
|
||||
Display::display_footer();
|
||||
185
main/mySpace/works_in_session_report.php
Normal file
185
main/mySpace/works_in_session_report.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use Chamilo\CoreBundle\Entity\Session;
|
||||
use Chamilo\CoreBundle\Entity\SessionRelCourse;
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php';
|
||||
|
||||
api_block_anonymous_users(true);
|
||||
|
||||
if (api_is_student()) {
|
||||
api_not_allowed(true);
|
||||
exit;
|
||||
}
|
||||
|
||||
$toolName = get_lang('WorksInSessionReport');
|
||||
|
||||
$em = Database::getManager();
|
||||
$session = null;
|
||||
if (api_is_platform_admin()) {
|
||||
$sessionList = SessionManager::get_sessions_list();
|
||||
} elseif (api_is_drh()) {
|
||||
$sessionList = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
|
||||
} elseif (api_is_session_admin()) {
|
||||
$sessionList = SessionManager::getSessionsFollowedByUser(api_get_user_id(), SESSIONADMIN);
|
||||
} else {
|
||||
$sessionList = Tracking::get_sessions_coached_by_user(api_get_user_id());
|
||||
}
|
||||
$form = new FormValidator('work_report', 'GET');
|
||||
$selectSession = $form->addSelect('session', get_lang('Session'), [0 => get_lang('None')]);
|
||||
$form->addButtonFilter(get_lang('Filter'));
|
||||
|
||||
foreach ($sessionList as $sessionInfo) {
|
||||
$selectSession->addOption($sessionInfo['name'], $sessionInfo['id']);
|
||||
}
|
||||
|
||||
$sessionId = isset($_GET['session']) ? (int) $_GET['session'] : 0;
|
||||
$session = null;
|
||||
if (!empty($sessionId)) {
|
||||
$form->setDefaults(['session' => $sessionId]);
|
||||
$session = api_get_session_entity($sessionId);
|
||||
}
|
||||
|
||||
$courses = [];
|
||||
$users = [];
|
||||
if ($session) {
|
||||
$sessionCourses = $session->getCourses();
|
||||
/** @var SessionRelCourse $sessionCourse */
|
||||
foreach ($sessionCourses as $sessionCourse) {
|
||||
$course = $sessionCourse->getCourse();
|
||||
$courses[$course->getId()] = $course->getCode();
|
||||
$userCourseSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Session::STUDENT);
|
||||
$usersInSession = $session->getUsers();
|
||||
|
||||
// Set defaults.
|
||||
foreach ($usersInSession as $userInSession) {
|
||||
$user = $userInSession->getUser();
|
||||
if (!array_key_exists($user->getId(), $users)) {
|
||||
$users[$user->getId()] = [
|
||||
'code' => $user->getOfficialCode(),
|
||||
'complete_name' => UserManager::formatUserFullName($user),
|
||||
'time_in_platform' => api_time_to_hms(
|
||||
Tracking::get_time_spent_on_the_platform($user->getId(), 'ever')
|
||||
),
|
||||
'first_connection' => Tracking::get_first_connection_date($user->getId()),
|
||||
'last_connection' => Tracking::get_last_connection_date($user->getId()),
|
||||
];
|
||||
}
|
||||
$users[$user->getId()][$course->getId().'_score'] = null;
|
||||
$users[$user->getId()][$course->getId().'_progress'] = null;
|
||||
$users[$user->getId()][$course->getId().'_last_sent_date'] = null;
|
||||
}
|
||||
|
||||
foreach ($userCourseSubscriptions as $userCourseSubscription) {
|
||||
/** @var User $user */
|
||||
$user = $userCourseSubscription->getUser();
|
||||
if (!$session->hasStudentInCourse($user, $course)) {
|
||||
continue;
|
||||
}
|
||||
$users[$user->getId()][$course->getId().'_score'] = Tracking::get_avg_student_score(
|
||||
$user->getId(),
|
||||
$course->getCode(),
|
||||
[],
|
||||
$session->getId(),
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
$users[$user->getId()][$course->getId().'_progress'] = Tracking::get_avg_student_progress(
|
||||
$user->getId(),
|
||||
$course->getCode(),
|
||||
[],
|
||||
$session->getId()
|
||||
);
|
||||
|
||||
$lastPublication = Tracking::getLastStudentPublication(
|
||||
$user,
|
||||
'work',
|
||||
$course,
|
||||
$session
|
||||
);
|
||||
|
||||
if (!$lastPublication) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$users[$user->getId()][$course->getId().'_last_sent_date'] = api_get_local_time(
|
||||
$lastPublication->getSentDate()->getTimestamp()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['export']) && $session && $courses && $users) {
|
||||
$fileName = 'works_in_session_'.api_get_local_time();
|
||||
|
||||
$dataToExport = [];
|
||||
$dataToExport[] = [$toolName, $session->getName()];
|
||||
$dataToExport['headers'][] = get_lang('OfficialCode');
|
||||
$dataToExport['headers'][] = get_lang('StudentName');
|
||||
$dataToExport['headers'][] = get_lang('TimeSpentOnThePlatform');
|
||||
$dataToExport['headers'][] = get_lang('FirstLoginInPlatform');
|
||||
$dataToExport['headers'][] = get_lang('LatestLoginInPlatform');
|
||||
|
||||
foreach ($courses as $courseCode) {
|
||||
$dataToExport['headers'][] = $courseCode.' ('.get_lang('BestScore').')';
|
||||
$dataToExport['headers'][] = get_lang('Progress');
|
||||
$dataToExport['headers'][] = get_lang('LastSentWorkDate');
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
$dataToExport[] = $user;
|
||||
}
|
||||
|
||||
switch ($_GET['export']) {
|
||||
case 'xls':
|
||||
Export::export_table_xls_html($dataToExport, $fileName);
|
||||
break;
|
||||
case 'csv':
|
||||
Export::arrayToCsv($dataToExport, $fileName);
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$interbreadcrumb[] = [
|
||||
'url' => api_get_path(WEB_CODE_PATH).'mySpace/index.php',
|
||||
'name' => get_lang('MySpace'),
|
||||
];
|
||||
|
||||
$actions = null;
|
||||
|
||||
if ($session) {
|
||||
$actions = Display::url(
|
||||
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?'.http_build_query(['export' => 'csv', 'session' => $session->getId()])
|
||||
);
|
||||
$actions .= Display::url(
|
||||
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
|
||||
api_get_self().'?'.http_build_query(['export' => 'xls', 'session' => $session->getId()])
|
||||
);
|
||||
}
|
||||
|
||||
$view = new Template($toolName);
|
||||
$view->assign('form', $form->returnForm());
|
||||
|
||||
if ($session) {
|
||||
$view->assign('session', ['name' => $session->getName()]);
|
||||
$view->assign('courses', $courses);
|
||||
$view->assign('users', $users);
|
||||
}
|
||||
|
||||
$template = $view->get_template('my_space/works_in_session_report.tpl');
|
||||
$content = $view->fetch($template);
|
||||
|
||||
$view->assign('header', $toolName);
|
||||
|
||||
if ($actions) {
|
||||
$view->assign('actions', Display::toolbarAction('toolbar', [$actions]));
|
||||
}
|
||||
|
||||
$view->assign('content', $content);
|
||||
$view->display_one_col_template();
|
||||
Reference in New Issue
Block a user