Internal: Update code from 1.11.x

pull/3466/head
Julio Montoya 5 years ago
parent 20bfa1b5cb
commit cfb518a053
  1. 1
      public/main/messages/new_message.php
  2. 23
      public/main/mySpace/access_details_session.php
  3. 5
      public/main/mySpace/coaches.php
  4. 160
      public/main/mySpace/company_reports.php
  5. 368
      public/main/mySpace/myStudents.php
  6. 12
      public/main/mySpace/session.php
  7. 183
      public/main/mySpace/session_filter.php
  8. 15
      public/main/mySpace/student.php
  9. 36
      public/main/mySpace/teachers.php
  10. 7
      public/main/mySpace/user_edit.php
  11. 8
      public/main/mySpace/users.php
  12. 9
      public/main/mySpace/works_in_session_report.php
  13. 2
      public/main/notification_event/edit.php

@ -146,6 +146,7 @@ function manageForm($default, $select_from_user_list = null, $sent_to = '', $tpl
[],
[
'multiple' => 'multiple',
'delay' => 1000,
'url' => api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=find_users',
]
);

@ -78,7 +78,7 @@ $form = new FormValidator(
);
$form->addElement('text', 'from', get_lang('From'));
$form->addElement('text', 'to', get_lang('Until'));
$form->addElement('hidden', 'user_id', $userId);
$form->addHidden('user_id', $userId);
$form->addRule('from', get_lang('Required field'), 'required');
$form->addRule('from', get_lang('Required field').' dd/mm/yyyy', 'callback', 'validateDate');
$form->addRule('to', get_lang('Required field'), 'required');
@ -101,17 +101,8 @@ function validateDate($value)
return true;
}
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'));
function getReport($userId, $from, $to, $addTime = false)
{
$sessionCategories = UserManager::get_sessions_by_category($userId, false);
$report = [];
$minLogin = 0;
@ -597,12 +588,14 @@ if ($formByDay->validate()) {
$formByDay->setDefaults(['from' => $startDate, 'to' => $endDate]);
Display::display_header('');
$userInfo = api_get_user_info($userId);
echo Display::page_header(get_lang('Learner details in course'));
echo Display::page_subheader(
get_lang('User').': '.$userInfo['complete_name']
);
$form->setDefaults(['from' => $startDate, 'to' => $endDate]);
$form->display();
echo Display::tabs(
[get_lang('CertificateOfAchievement'), get_lang('CertificateOfAchievementByDay')],
[$form->returnForm(), $formByDay->returnForm()]
);
Display::display_footer();

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Coaches reporting.
*/
ob_start();
$cidReset = true;
@ -24,7 +22,6 @@ Display :: display_header($nameTools);
api_display_tool_title($nameTools);
// Database Table Definitions
$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);

@ -40,32 +40,88 @@ $columns = [
//Column config
$column_model = [
['name' => 'course', 'index' => 'title', 'width' => '180', 'align' => 'left', 'wrap_cell' => 'true'],
['name' => 'user', 'index' => 'user', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'],
['name' => 'email', 'index' => 'email', 'width' => '100', 'align' => 'left', 'sortable' => 'false', 'wrap_cell' => 'true'],
['name' => 'time', 'index' => 'time', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
['name' => 'certificate', 'index' => 'certificate', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
['name' => 'progress_100', 'index' => 'progress_100', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
['name' => 'progress', 'index' => 'progress', 'width' => '50', 'align' => 'left', 'sortable' => 'false'],
[
'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['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'];
$column_model[] = [
'name' => 'group',
'index' => 'group',
'width' => '50',
'align' => 'left',
'sortable' => 'false',
];
$columns[] = get_lang('Group');
}
@ -76,20 +132,91 @@ $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",{
'.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:false,
search:true,
excel:true
});
},
{height:280,reloadAfterSubmit:false}, // edit options
{height:280,reloadAfterSubmit:false}, // add options
{reloadAfterSubmit:false},
prmSearch
);
jQuery("#user_course_report").jqGrid("navButtonAdd","#user_course_report_pager", {
grid.searchGrid(prmSearch);
grid.jqGrid("navButtonAdd","#user_course_report_pager", {
caption:"",
onClickButton : function () {
jQuery("#user_course_report").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
grid.jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
}
});
});
@ -136,7 +263,6 @@ $content .= Display::url(
$content .= '</div>';
$content .= '<h1 class="page-header">'.get_lang('Corporate report').'</h1>';
$content .= Display::grid_html('user_course_report');
$tpl = new Template($tool_name);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -10,6 +10,7 @@ if (!isset($_GET['course'])) {
}
require_once __DIR__.'/../inc/global.inc.php';
require_once '../work/work.lib.php';
api_block_anonymous_users();
@ -30,6 +31,8 @@ $details = isset($_GET['details']) ? Security::remove_XSS($_GET['details']) : ''
$currentUrl = api_get_self().'?student='.$student_id.'&course='.$courseCode.'&id_session='.$sessionId
.'&origin='.$origin.'&details='.$details;
$allowMessages = api_get_configuration_value('private_messages_about_user');
$workingTime = api_get_configuration_value('considered_working_time');
$workingTimeEdit = api_get_configuration_value('allow_working_time_edition');
if (empty($student_id)) {
api_not_allowed(true);
@ -212,6 +215,30 @@ $tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISE
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'add_work_time':
if (false === $workingTimeEdit) {
api_not_allowed(true);
}
$workingTime = isset($_GET['time']) ? $_GET['time'] : '';
$workId = isset($_GET['work_id']) ? $_GET['work_id'] : '';
Event::eventAddVirtualCourseTime($courseInfo['real_id'], $student_id, $sessionId, $workingTime, $workId);
Display::addFlash(Display::return_message(get_lang('Updated')));
header('Location: '.$currentUrl);
exit;
case 'remove_work_time':
if (false === $workingTimeEdit) {
api_not_allowed(true);
}
$workingTime = isset($_GET['time']) ? $_GET['time'] : '';
$workId = isset($_GET['work_id']) ? $_GET['work_id'] : '';
Event::eventRemoveVirtualCourseTime($courseInfo['real_id'], $student_id, $sessionId, $workingTime, $workId);
Display::addFlash(Display::return_message(get_lang('Updated')));
header('Location: '.$currentUrl);
exit;
break;
case 'export_to_pdf':
$sessionToExport = $sId = isset($_GET['session_to_export']) ? (int) $_GET['session_to_export'] : 0;
$sessionInfo = api_get_session_info($sessionToExport);
@ -223,21 +250,25 @@ switch ($action) {
$numberVisits = 0;
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$progress = 0;
$timeSpentPerCourse = [];
$progressPerCourse = [];
foreach ($courses as $course) {
$courseId = $course['c_id'];
$timeSpent += Tracking::get_time_spent_on_the_course($student_id, $courseId, $sessionToExport);
$sql = 'SELECT DISTINCT count(course_access_id) as count
FROM '.$table.'
$courseTimeSpent = Tracking::get_time_spent_on_the_course($student_id, $courseId, $sessionToExport);
$timeSpentPerCourse[$courseId] = $courseTimeSpent;
$timeSpent += $courseTimeSpent;
$sql = "SELECT DISTINCT count(course_access_id) as count
FROM $table
WHERE
user_id = '.$student_id.' AND
c_id = '.$courseId.' AND
session_id = '.$sessionToExport.'
ORDER BY login_course_date ASC';
c_id = $courseId AND
session_id = $sessionToExport AND
user_id = $student_id";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$numberVisits += $row['count'];
$progress += Tracking::get_avg_student_progress($student_id, $course['code'], [], $sessionToExport);
$courseProgress = Tracking::get_avg_student_progress($student_id, $course['code'], [], $sessionToExport);
$progressPerCourse[$courseId] = $courseProgress;
$progress += $courseProgress;
}
$average = round($progress / count($courses), 1);
@ -304,25 +335,14 @@ switch ($action) {
);
if ($isSubscribed) {
$timeInSeconds = Tracking::get_time_spent_on_the_course(
$user_info['user_id'],
$courseId,
$sessionToExport
);
$timeInSeconds = $timeSpentPerCourse[$courseId];
$totalCourseTime += $timeInSeconds;
$time_spent_on_course = api_time_to_hms($timeInSeconds);
$progress = Tracking::get_avg_student_progress(
$user_info['user_id'],
$courseCodeItem,
[],
$sId
);
$progress = $progressPerCourse[$courseId];
$totalProgress += $progress;
$bestScore = Tracking::get_avg_student_score(
$user_info['user_id'],
$student_id,
$courseCodeItem,
[],
$sId,
@ -339,8 +359,10 @@ switch ($action) {
$score = empty($bestScore) ? '0%' : $bestScore.'%';
$courseTable .= '<tr>
<td ><a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
$courseInfoItem['title'].'</a></td>
<td>
<a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
$courseInfoItem['title'].'</a>
</td>
<td >'.$time_spent_on_course.'</td>
<td >'.$progress.'</td>
<td >'.$score.'</td>';
@ -366,12 +388,10 @@ switch ($action) {
$courseTable .= '</tbody></table>';
}
$studentInfo = api_get_user_info($student_id);
$tpl = new Template('', false, false, false, true, false, false);
$tpl->assign('title', get_lang('Attestation of attendance'));
$tpl->assign('session_title', $sessionInfo['name']);
$tpl->assign('student', $studentInfo['complete_name']);
$tpl->assign('student', $user_info['complete_name']);
$tpl->assign('table_progress', $table->toHtml());
$tpl->assign('subtitle', sprintf(
get_lang('In session %s, you had the following results'),
@ -385,7 +405,7 @@ switch ($action) {
'session_info' => $sessionInfo,
'course_info' => '',
'pdf_date' => '',
'student_info' => $studentInfo,
'student_info' => $user_info,
'show_grade_generated_date' => true,
'show_real_course_teachers' => false,
'show_teacher_as_myself' => false,
@ -441,36 +461,42 @@ switch ($action) {
if (true === $allowMessages) {
$subject = isset($_POST['subject']) ? $_POST['subject'] : '';
$message = isset($_POST['message']) ? $_POST['message'] : '';
$currentUserInfo = api_get_user_info();
MessageManager::sendMessageAboutUser(
$user_info,
$currentUserInfo,
$subject,
$message
);
// Send also message to all student bosses
$bossList = UserManager::getStudentBossList($student_id);
if (!empty($bossList)) {
$url = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id;
$link = Display::url($url, $url);
foreach ($bossList as $boss) {
MessageManager::send_message_simple(
$boss['boss_id'],
sprintf(get_lang('Follow up message about student %s'), $user_info['complete_name']),
sprintf(
get_lang('Hi,<br/><br/>'),
$currentUserInfo['complete_name'],
$user_info['complete_name'],
$link
)
);
if (!empty($subject) && !empty($message)) {
$currentUserInfo = api_get_user_info();
MessageManager::sendMessageAboutUser(
$user_info,
$currentUserInfo,
$subject,
$message
);
// Send also message to all student bosses
$bossList = UserManager::getStudentBossList($student_id);
if (!empty($bossList)) {
$url = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id;
$link = Display::url($url, $url);
foreach ($bossList as $boss) {
MessageManager::send_message_simple(
$boss['boss_id'],
sprintf(get_lang('Follow up message about student %s'), $user_info['complete_name']),
sprintf(
get_lang('Hi,<br/><br/>'),
$currentUserInfo['complete_name'],
$user_info['complete_name'],
$link
)
);
}
}
Display::addFlash(Display::return_message(get_lang('Message Sent')));
} else {
Display::addFlash(Display::return_message(get_lang('AllFieldsRequired'), 'warning'));
}
Display::addFlash(Display::return_message(get_lang('Message Sent')));
header('Location: '.$currentUrl);
exit;
}
@ -710,6 +736,18 @@ if (Skill::isAllowed($student_id, false)) {
);
}
if (Skill::isAllowed($student_id, false)) {
echo Display::url(
Display::return_icon(
'attendance.png',
get_lang('CountDoneAttendance'),
null,
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?action=all_attendance&student='.$student_id
);
}
$permissions = StudentFollowUpPlugin::getPermissions(
$student_id,
api_get_user_id()
@ -941,6 +979,115 @@ if ('true' === api_get_setting('allow_terms_conditions')) {
];
}
if (isset($_GET['action']) and $_GET['action'] == 'all_attendance') {
/*Display all attendances */
// Varible for all attendance list
$startDate = new DateTime();
$startDate = $startDate->modify('-1 week');
if (isset($_GET['startDate'])) {
$startDate = new DateTime($_GET['startDate']);
}
$startDate = $startDate->setTime(0, 0, 0);
$endDate = new DateTime();
if (isset($_GET['endDate'])) {
$endDate = new DateTime($_GET['endDate']);
}
$endDate = $endDate->setTime(23, 59, 0);
// $startDate = new DateTime(api_get_local_time($startDate));
// $endDate = new DateTime(api_get_local_time($endDate));
if ($startDate > $endDate) {
$dataTemp = $startDate;
$startDate = $endDate;
$endDate = $dataTemp;
}
$startDateText = api_get_local_time($startDate);
$endDateText = api_get_local_time($endDate);
// Varible for all attendance list
/** Start date and end date*/
$defaults['startDate'] = $startDateText;
$defaults['endDate'] = $endDateText;
$form = new FormValidator('all_attendance_list', 'GET',
'myStudents.php?action=all_attendance&student='.$student_id.'&startDate='.$defaults['startDate'].'&endDate='.$defaults['endDate'].'&&'.api_get_cidreq(),
'');
$form->addElement('html', '<input type="hidden" name="student" value="'.$student_id.'" >');
$form->addElement('html', '<input type="hidden" name="action" value="all_attendance" >');
$form->addDateTimePicker('startDate', [
get_lang('ExeStartTime'),
], [
'form_name' => 'attendance_calendar_edit',
], 5);
$form->addDateTimePicker('endDate', [
get_lang('ExeEndTime'),
], [
'form_name' => 'attendance_calendar_edit',
], 5);
$form->addButtonSave(get_lang('Submit'));
$form->setDefaults($defaults);
$form->display();
/** Display dates */
$attendance = new Attendance();
$data = $attendance->getCoursesWithAttendance($student_id, $startDate, $endDate);
// 'attendance from %s to %s'
$title = sprintf(get_lang('AttendanceFromXToY'), $startDateText, $endDateText);
echo '
<h3>'.$title.'</h3>
<div class="">
<table class="table table-striped table-hover table-responsive">
<thead>
<tr>
<th>'.get_lang('DateExo').'</th>
<th>'.get_lang('Training').'</th>
<th>'.get_lang('Present').'</th>
</tr>
</thead>
<tbody>';
// <th>'.get_lang('Professor').'</th>
foreach ($data as $attendanceData => $attendanceSheet) {
/*
* $attendanceData can be in_category or not_category for courses
* */
$totalAttendance = count($attendanceSheet);
for ($i = 0; $i < $totalAttendance; $i++) {
$attendanceWork = $attendanceSheet[$i];
$courseInfoItem = api_get_course_info_by_id($attendanceWork['courseId']);
$date = api_get_local_time($attendanceWork[1]);
$sId = $attendanceWork['session'];
$printSession = '';
if ($sId != 0) {
// get session name
$printSession = "(".$attendanceWork['sessionName'].")";
}
// $teacher = isset($attendanceWork['teacher'])?$attendanceWork['teacher']:'';
echo '
<tr>
<td>'.$date.'</td>
<td>'
.'<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH)
.'attendance/index.php?cidReq='.$attendanceWork['courseCode'].'&id_session='.$sId.'&student_id='
.$student_id.'">'
.$attendanceWork['courseTitle']." $printSession ".'</a>
</td>
<td>'.$attendanceWork['presence'].'</td>
</tr>';
//<td>'.$teacher.'</td>
}
}
echo '</tbody>
</table></div>';
/** Display dates */
/*Display all attendances */
Display::display_footer();
exit();
}
$details = true;
$tpl = new Template(
'',
@ -1325,15 +1472,11 @@ if (empty($details)) {
['align' => 'absmiddle', 'hspace' => '3px']
),
'progress' => get_lang('Progress').
Display::return_icon('info3.gif', get_lang('LPProgressScore'), ['align' => 'absmiddle', 'hspace' => '3px']),
'last_connection' => get_lang('LastConnexion').
Display::return_icon(
'info3.gif',
get_lang('% of learning objects visited'),
['align' => 'absmiddle', 'hspace' => '3px']
),
'last_connection' => get_lang('Latest login').
Display::return_icon(
'info3.gif',
get_lang('Last time learner entered the course'),
get_lang('LastTimeTheCourseWasUsed'),
['align' => 'absmiddle', 'hspace' => '3px']
),
];
@ -1367,6 +1510,19 @@ if (empty($details)) {
$columnName
);
}
$hookLpTracking = HookMyStudentsLpTracking::create();
if ($hookLpTracking) {
$hookHeaders = $hookLpTracking->notifyTrackingHeader();
foreach ($hookHeaders as $hookHeader) {
$columnHeadersToExport[] = $hookHeader['value'];
$headers .= Display::tag('th', $hookHeader['value'], $hookHeader['attrs']);
}
}
$csv_content[] = $columnHeadersToExport;
$columnHeadersKeys = array_keys($columnHeaders);
$categoriesTempList = learnpath::getCategories($courseInfo['real_id']);
@ -1562,6 +1718,16 @@ if (empty($details)) {
echo Display::tag('td', $start_time);
}
if ($hookLpTracking) {
$hookContents = $hookLpTracking->notifyTrackingContent($lp_id, $student_id);
foreach ($hookContents as $hookContent) {
$contentToExport[] = strip_tags($hookContent['value']);
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']);
}
}
$csv_content[] = $contentToExport;
if (true === $any_result) {
@ -1596,9 +1762,10 @@ if (empty($details)) {
);
}
echo '</td>';
}
echo '</tr>';
}
}
echo '</tbody></table></div>';
}
}
@ -1617,8 +1784,22 @@ if (empty($details)) {
['align' => 'absmiddle', 'hspace' => '3px']
).'</th>';
echo '<th>'.get_lang('Attempts').'</th>';
echo '<th>'.get_lang('Latest attempt').'</th>';
echo '<th>'.get_lang('All attempts').'</th>';
echo '<th>'.get_lang('LatestAttempt').'</th>';
echo '<th>'.get_lang('AllAttempts').'</th>';
$hookQuizTracking = HookMyStudentsQuizTracking::create();
if ($hookQuizTracking) {
$hookHeaders = array_map(
function ($hookHeader) {
return Display::tag('th', $hookHeader['value'], $hookHeader['attrs']);
},
$hookQuizTracking->notifyTrackingHeader()
);
echo implode(PHP_EOL, $hookHeaders);
}
echo '</tr></thead><tbody>';
$csv_content[] = [];
@ -1629,6 +1810,18 @@ if (empty($details)) {
get_lang('Attempts'),
];
if ($hookQuizTracking) {
$hookHeaders = array_map(
function ($hookHeader) {
return strip_tags($hookHeader['value']);
},
$hookQuizTracking->notifyTrackingHeader()
);
$csvContentIndex = count($csv_content) - 1;
$csv_content[$csvContentIndex] = array_merge($csv_content[$csvContentIndex], $hookHeaders);
}
$t_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
$sessionCondition = api_get_session_condition(
$sessionId,
@ -1669,6 +1862,10 @@ if (empty($details)) {
);
$lp_name = '-';
$hookContents = $hookQuizTracking
? $hookQuizTracking->notifyTrackingContent($exercise_id, $student_id)
: [];
if (!isset($score_percentage) && $count_attempts > 0) {
$scores_lp = Tracking::get_avg_student_exercise_score(
$student_id,
@ -1754,6 +1951,13 @@ if (empty($details)) {
);
}
echo '</td>';
if (!empty($hookContents)) {
foreach ($hookContents as $hookContent) {
echo Display::tag('td', $hookContent['value'], $hookContent['attrs']);
}
}
echo '</tr>';
$data_exercices[$i][] = $exercices['title'];
$data_exercices[$i][] = $score_percentage.'%';
@ -1766,6 +1970,14 @@ if (empty($details)) {
$count_attempts,
];
if (!empty($hookContents)) {
$csvContentIndex = count($csv_content) - 1;
foreach ($hookContents as $hookContent) {
$csv_content[$csvContentIndex][] = strip_tags($hookContent['value']);
}
}
$i++;
}
} else {
@ -1776,7 +1988,6 @@ if (empty($details)) {
// @when using sessions we do not show the survey list
if (empty($sessionId)) {
$survey_list = SurveyManager::get_surveys($courseCode, $sessionId);
if (!empty($survey_list)) {
$survey_data = [];
foreach ($survey_list as $survey) {
@ -1829,7 +2040,6 @@ if (empty($details)) {
}
}
require_once '../work/work.lib.php';
$userWorks = getWorkPerUser($student_id, $courseInfo['real_id'], $sessionId);
echo '
<div class="table-responsive">
@ -1849,16 +2059,19 @@ if (empty($details)) {
$workingTime = api_get_configuration_value('considered_working_time');
foreach ($userWorks as $work) {
$work = $work['work'];
$showOnce = true;
foreach ($work->user_results as $key => $results) {
$resultId = $results['id'];
echo '<tr>';
echo '<td>'.$work->title.'</td>';
$documentNumber = $key + 1;
$url = api_get_path(WEB_CODE_PATH).'work/view.php?cidReq='.$courseCode.'&id_session='.$sessionId.'&id='
.$results['id'];
.$resultId;
echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>';
$qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
echo '<td class="text-center">'.$qualification.'</td>';
echo '<td class="text-center">'.$results['formatted_date'].'</td>';
echo '<td class="text-center">'.api_convert_and_format_date($results['sent_date_from_db']).' '.$results['expiry_note'].'</td>';
$assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']);
echo '<td class="text-center">';
@ -1876,7 +2089,22 @@ if (empty($details)) {
foreach ($resultExtra as $field) {
$field = $field['value'];
if ($workingTime == $field->getField()->getVariable()) {
echo '<td class="text-center">'.$field->getValue().'</td>';
$time = $field->getValue();
echo '<td class="text-center">';
echo $time;
if ($workingTimeEdit && $showOnce) {
$showOnce = false;
echo '&nbsp;'.Display::url(
get_lang('AddTime'),
$currentUrl.'&action=add_work_time&time='.$time.'&work_id='.$work->id
);
echo '&nbsp;'.Display::url(
get_lang('RemoveTime'),
$currentUrl.'&action=remove_work_time&time='.$time.'&work_id='.$work->id
);
}
echo '</td>';
}
}
echo '</tr>';

@ -53,6 +53,11 @@ if (api_is_platform_admin(true, true)) {
Display::return_icon('session_na.png', get_lang('Course 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(
@ -71,6 +76,13 @@ if (api_is_platform_admin(true, true)) {
);
}
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) {

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Report for current courses followed by the user.
*/
@ -7,59 +9,17 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_TRACKING;
if (!api_is_allowed_to_create_course()) {
if (!api_is_allowed_to_create_course() && !api_is_drh()) {
api_not_allowed(true);
}
$allowCustomCertificate = api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true';
$plugin = CustomCertificatePlugin::create();
$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?' +
'session_id=' + session_id + '&'+
'date_begin=' + date_begin + '&' +
'date_end=' + date_end + '&' +
'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?' +
'session_id=' + session_id + '&'+
'date_begin=' + date_begin + '&' +
'date_end=' + date_end + '&' +
'export_zip=1';
$(location).attr('href',url);
}
});
});
</script>";
$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);
@ -68,6 +28,7 @@ define('ALL_DATE_FILTER', 3);
$certificateList = [];
$formSent = 0;
$urlParam = '';
if (isset($_POST['formSent'])) {
$formSent = $_POST['formSent'];
@ -83,6 +44,15 @@ if (isset($_POST['formSent'])) {
$filterDate += DATE_END_FILTER;
}
$filterCheckList = [];
$extraField = new ExtraField('user');
$extraFieldsAll = $extraField->get_all(['filter = ?' => 1], 'option_order');
foreach ($extraFieldsAll as $field) {
if (!empty($_POST['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",
@ -149,11 +119,111 @@ if (isset($_POST['formSent'])) {
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'], $_POST['extra_'.$field['variable']]);
if ($pos === false) {
unset($certificateList[$key]);
}
break;
case ExtraField::FIELD_TYPE_RADIO:
$valueRadio = $_POST['extra_'.$field['variable']]['extra_'.$field['variable']];
if ($extraFieldValueData['value'] != $valueRadio) {
unset($certificateList[$key]);
}
break;
case ExtraField::FIELD_TYPE_SELECT:
if ($extraFieldValueData['value'] != $_POST['extra_'.$field['variable']]) {
unset($certificateList[$key]);
}
break;
}
}
}
}
$params = [
'session_id' => (int) $_POST['session_id'],
'date_begin' => Security::remove_XSS($_POST['date_begin']),
'date_end' => Security::remove_XSS($_POST['date_end']),
];
//select of sessions
foreach ($filterCheckList as $field) {
$params['extra_'.$field['variable']] = Security::remove_XSS($_POST['extra_'.$field['variable']]);
}
$urlParam = http_build_query($params);
}
$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>";
$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 id, name FROM $tblSession ORDER BY name";
$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);
@ -162,7 +232,9 @@ if (api_is_multiple_url_enabled()) {
$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";
}
}
@ -178,6 +250,22 @@ $form = new FormValidator('search_user', 'post', api_get_self());
$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'));
@ -228,10 +316,7 @@ if (count($certificateList) == 0) {
<table class="table data_table">
<tbody>';
$list = GradebookUtils::get_list_gradebook_certificates_by_user_id(
$value['user_id'],
$categoryId
);
$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>';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -270,6 +271,12 @@ if (api_is_drh()) {
Display::return_icon('statistics.png', get_lang('Corporate report'), [], 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',
@ -293,12 +300,18 @@ $actionsRight .= Display::url(
$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,
10
$itemPerPage
);
$params = [

@ -71,25 +71,23 @@ function get_users($from, $limit, $column, $direction)
$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,
$column,
$direction,
$keyword,
$active,
$lastConnectionDate,
null,
null,
COURSEMANAGER
);
$drhLoaded = true;
}
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;
}
if (false == $drhLoaded) {

@ -154,12 +154,7 @@ if ($form->validate()) {
get_lang('e-mail')." : ".api_get_setting('emailAdministrator');
$emailbody = nl2br($emailbody);
api_mail_html(
api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS),
$email,
$emailsubject,
$emailbody
);
MessageManager::send_message_simple($userInfo['user_id'], $emailsubject, $emailbody);
}
Security::clear_token();

@ -275,12 +275,18 @@ $actionsRight .= Display::url(
$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,
10
$itemPerPage
);
$params = [

@ -1,13 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
/**
* Courses reporting.
*/
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(true);
@ -25,6 +23,8 @@ 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());
}
@ -40,8 +40,7 @@ $sessionId = isset($_GET['session']) ? (int) $_GET['session'] : 0;
$session = null;
if (!empty($sessionId)) {
$form->setDefaults(['session' => $sessionId]);
/** @var Session $session */
$session = $em->find('ChamiloCoreBundle:Session', $sessionId);
$session = api_get_session_entity($sessionId);
}
$coursesInfo = [];

@ -10,7 +10,7 @@ $tool = 'notification_event';
$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
if (empty($id)) {
api_not_allowed();
api_not_allowed(true);
}
$manager = new NotificationEvent();

Loading…
Cancel
Save