diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php
index 2036e3cc916..377b9cff590 100644
--- a/main/install/configuration.dist.php
+++ b/main/install/configuration.dist.php
@@ -1953,6 +1953,9 @@
//Create an extra field for courses with identifier "theoretical_time"
//$_configuration['display_theoretical_time'] = false;
+// Show subscription column in session course list on main/mySpace/myStudents.php
+//$_configuration['display_session_subscription_column'] = false;
+
// Enable improved tracking section in main/mySpace/myStudents.php
//$_configuration['improve_tracking_in_mystudent_php'] = false;
diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php
index 40718cc1217..40b729a3030 100755
--- a/main/mySpace/myStudents.php
+++ b/main/mySpace/myStudents.php
@@ -16,6 +16,11 @@
api_block_anonymous_users();
$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
$export = isset($_GET['export']) ? $_GET['export'] : false;
$sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
@@ -35,6 +40,7 @@
$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');
+$subscriptionColumnEnabled = api_get_configuration_value('display_session_subscription_column');
$allowToQualify = api_is_allowed_to_edit(null, true) ||
api_is_course_tutor() ||
@@ -142,6 +148,51 @@
header('Location: '.$currentUrl);
exit;
break;
+ case 'subscribe_course':
+ if (false === $subscriptionColumnEnabled) {
+ break;
+ }
+ $courseCodeParam = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : '';
+ $sessionParam = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
+ if ('' !== $courseCodeParam && $sessionParam > 0) {
+ SessionManager::subscribe_users_to_session_course(
+ [$student_id],
+ $sessionParam,
+ $courseCodeParam
+ );
+ Display::addFlash(Display::return_message(get_lang('Updated')));
+ }
+ $redirectUrl = api_get_self().'?' . http_build_query([
+ 'student' => $student_id,
+ 'origin' => $origin,
+ 'details' => $details,
+ 'id_session' => $sessionParam,
+ ]);
+ header('Location: '.$redirectUrl);
+ exit;
+ case 'unsubscribe_course':
+ if (false === $subscriptionColumnEnabled) {
+ break;
+ }
+ $courseCodeParam = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : '';
+ $sessionParam = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
+ if ('' !== $courseCodeParam && $sessionParam > 0) {
+ $courseInfoParam = api_get_course_info($courseCodeParam);
+ SessionManager::removeUsersFromCourseSession(
+ [$student_id],
+ $sessionParam,
+ $courseInfoParam
+ );
+ Display::addFlash(Display::return_message(get_lang('Updated')));
+ }
+ $redirectUrl = api_get_self().'?' . http_build_query([
+ 'student' => $student_id,
+ 'origin' => $origin,
+ 'details' => $details,
+ 'id_session' => $sessionParam,
+ ]);
+ header('Location: '.$redirectUrl);
+ exit;
case 'export_one_session_row':
$sessionToExport = isset($_GET['session_to_export']) ? (int) $_GET['session_to_export'] : 0;
$exportList = Session::read('export_course_list');
@@ -1406,27 +1457,35 @@
$lpIdList = [];
if (empty($details)) {
$csv_content[] = [];
- if($theoreticalTimeEnabled) {
- $csv_content[] = [
+ if ($theoreticalTimeEnabled) {
+ $header = [
get_lang('Session'),
get_lang('Course'),
get_lang('Time'),
get_lang('Progress'),
get_lang('Score'),
get_lang('TheoreticalTime'),
- get_lang('AttendancesFaults'),
- get_lang('Evaluations'),
];
+ if ($subscriptionColumnEnabled) {
+ $header[] = get_lang('Subscription');
+ }
+ $header[] = get_lang('AttendancesFaults');
+ $header[] = get_lang('Evaluations');
+ $csv_content[] = $header;
} else {
- $csv_content[] = [
+ $header = [
get_lang('Session'),
get_lang('Course'),
get_lang('Time'),
get_lang('Progress'),
get_lang('Score'),
- get_lang('AttendancesFaults'),
- get_lang('Evaluations'),
];
+ if ($subscriptionColumnEnabled) {
+ $header[] = get_lang('Subscription');
+ }
+ $header[] = get_lang('AttendancesFaults');
+ $header[] = get_lang('Evaluations');
+ $csv_content[] = $header;
}
$attendance = new Attendance();
@@ -1471,6 +1530,9 @@
if($theoreticalTimeEnabled) {
echo '
'.get_lang('TheoreticalTime').' | ';
}
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ echo ''.get_lang('Subscription').' | ';
+ }
echo ''.get_lang('AttendancesFaults').' |
'.get_lang('Evaluations').' |
'.get_lang('Details').' |
@@ -1486,10 +1548,13 @@
get_lang('Progress'),
get_lang('Score'),
get_lang('TheoreticalTime'),
- get_lang('AttendancesFaults'),
- get_lang('Evaluations'),
- get_lang('Details'),
];
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ $csvRow[] = get_lang('Subscription');
+ }
+ $csvRow[] = get_lang('AttendancesFaults');
+ $csvRow[] = get_lang('Evaluations');
+ $csvRow[] = get_lang('Details');
} else {
$csvRow = [
'',
@@ -1497,10 +1562,13 @@
get_lang('Time'),
get_lang('Progress'),
get_lang('Score'),
- get_lang('AttendancesFaults'),
- get_lang('Evaluations'),
- get_lang('Details'),
];
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ $csvRow[] = get_lang('Subscription');
+ }
+ $csvRow[] = get_lang('AttendancesFaults');
+ $csvRow[] = get_lang('Evaluations');
+ $csvRow[] = get_lang('Details');
}
$exportCourseList[$sId][] = $csvRow;
@@ -1534,8 +1602,58 @@
$sId
);
}
+ $time_spent_on_course = api_time_to_hms(0);
+ $attendances_faults_avg = '0/0 (0%)';
+ $scoretotal_display = '0/0 (0%)';
+ $progress = '0%';
+ $score = '0%';
+ $subscriptionIcon = '';
+ $subscriptionCsv = '';
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ $subscribeUrl = api_get_self().'?' . http_build_query([
+ 'action' => 'subscribe_course',
+ 'id_session' => $sId,
+ 'student' => $student_id,
+ 'course_code' => $courseCodeItem,
+ 'origin' => $origin,
+ 'details' => $details,
+ ]);
+ $unsubscribeUrl = api_get_self().'?' . http_build_query([
+ 'action' => 'unsubscribe_course',
+ 'id_session' => $sId,
+ 'student' => $student_id,
+ 'course_code' => $courseCodeItem,
+ 'origin' => $origin,
+ 'details' => $details,
+ ]);
+ $subscriptionIcon = Display::url(
+ Display::return_icon('add.png', get_lang('NotRegistered')),
+ $subscribeUrl
+ );
+ $subscriptionCsv = '+';
+ }
+ if($theoreticalTimeEnabled) {
+ $theoreticalTime = CourseManager::get_course_extra_field_value('theoretical_time', $courseCodeItem);
+ if (is_numeric($theoreticalTime) && (float)$theoreticalTime != 0) {
+ if ($isSubscribed) {
+ $totalTheoreticalTime += (float)$theoreticalTime;
+ }
+ $hours = floor($theoreticalTime / 60);
+ $minutes = $theoreticalTime % 60;
+ $theoreticalTimeDisplay = sprintf('%02d:%02d', $hours, $minutes);
+ } else {
+ $theoreticalTimeDisplay = '00:00';
+ }
+ }
if ($isSubscribed) {
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ $subscriptionIcon = Display::url(
+ Display::return_icon('delete.png', get_lang('Registered')),
+ $unsubscribeUrl
+ );
+ $subscriptionCsv = 'x';
+ }
$totalCourses++;
$timeInSeconds = Tracking::get_time_spent_on_the_course(
$student_id,
@@ -1552,7 +1670,6 @@
$sId
);
- $attendances_faults_avg = '0/0 (0%)';
if (!empty($results_faults_avg['total'])) {
if (api_is_drh()) {
$attendances_faults_avg = Display::url(
@@ -1591,105 +1708,103 @@
}
}
- $scoretotal_display = '0/0 (0%)';
if (!empty($scoretotal) && !empty($scoretotal[1])) {
$scoretotal_display =
- round($scoretotal[0], 1).'/'.
- round($scoretotal[1], 1).
+ round($scoretotal[0], 1).'/' .
+ round($scoretotal[1], 1) .
' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
$gradeBookTotal[0] += $scoretotal[0];
$gradeBookTotal[1] += $scoretotal[1];
}
- $progress = Tracking::get_avg_student_progress(
+ $progressVal = Tracking::get_avg_student_progress(
$student_id,
$courseCodeItem,
[],
$sId
);
- $totalProgress += $progress;
+ $totalProgress += $progressVal;
- $score = Tracking::get_avg_student_score(
+ $scoreVal = Tracking::get_avg_student_score(
$student_id,
$courseCodeItem,
[],
$sId
);
- if (is_numeric($score)) {
- $totalScore += $score;
- }
-
- if($theoreticalTimeEnabled) {
- $theoreticalTime = CourseManager::get_course_extra_field_value('theoretical_time', $courseCodeItem);
- if (is_numeric($theoreticalTime) && (float)$theoreticalTime != 0) {
- $totalTheoreticalTime += (float)$theoreticalTime;
- $hours = floor($theoreticalTime / 60);
- $minutes = $theoreticalTime % 60;
- $theoreticalTimeDisplay = sprintf('%02d:%02d', $hours, $minutes);
- } else {
- $theoreticalTimeDisplay = '00:00';
- }
+ if (is_numeric($scoreVal)) {
+ $totalScore += $scoreVal;
}
- $progress = empty($progress) ? '0%' : $progress.'%';
- $score = empty($score) ? '0%' : $score.'%';
-
- if($theoreticalTimeEnabled) {
- $csvRow = [
- $session_name,
- $courseInfoItem['title'],
- $time_spent_on_course,
- $progress,
- $score,
- $theoreticalTimeDisplay,
- $attendances_faults_avg,
- $scoretotal_display,
- ];
- } else {
- $csvRow = [
- $session_name,
- $courseInfoItem['title'],
- $time_spent_on_course,
- $progress,
- $score,
- $attendances_faults_avg,
- $scoretotal_display,
- ];
- }
+ $progress = empty($progressVal) ? '0%' : $progressVal.'%';
+ $score = empty($scoreVal) ? '0%' : $scoreVal.'%';
+ }
- $csv_content[] = $csvRow;
- $exportCourseList[$sId][] = $csvRow;
-
- echo '
-
- '.
- $courseInfoItem['title'].'
-
- |
- '.$time_spent_on_course.' |
- '.$progress.' |
- '.$score.' | ';
if($theoreticalTimeEnabled) {
- echo ''.$theoreticalTimeDisplay.' | ';
+ $csvRow = [
+ $session_name,
+ $courseInfoItem['title'],
+ $time_spent_on_course,
+ $progress,
+ $score,
+ $theoreticalTimeDisplay,
+ ];
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ $csvRow[] = $subscriptionCsv;
}
- echo ''.$attendances_faults_avg.' |
- '.$scoretotal_display.' | ';
- if (!empty($coachId)) {
- echo ''
- .Display::return_icon('2rightarrow.png', get_lang('Details')).' | ';
- } else {
- echo ''
- .Display::return_icon('2rightarrow.png', get_lang('Details')).' | ';
+ $csvRow[] = $attendances_faults_avg;
+ $csvRow[] = $scoretotal_display;
+ } else {
+ $csvRow = [
+ $session_name,
+ $courseInfoItem['title'],
+ $time_spent_on_course,
+ $progress,
+ $score,
+ ];
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ $csvRow[] = $subscriptionCsv;
}
- echo '
';
+ $csvRow[] = $attendances_faults_avg;
+ $csvRow[] = $scoretotal_display;
}
+
+ $csv_content[] = $csvRow;
+ $exportCourseList[$sId][] = $csvRow;
+ $rowClass = $isSubscribed ? '' : ' class="course-unsubscribed"';
+ echo '',
+ '',
+ ''.
+ $courseInfoItem['title'].
+ '',
+ ' | ',
+ ''.$time_spent_on_course.' | ',
+ ''.$progress.' | ',
+ ''.$score.' | ';
+ if($theoreticalTimeEnabled) {
+ echo ''.$theoreticalTimeDisplay.' | ';
+ }
+ if ($subscriptionColumnEnabled && !empty($sId)) {
+ echo ''.$subscriptionIcon.' | ';
+ }
+ echo ''.$attendances_faults_avg.' | ',
+ ''.$scoretotal_display.' | ';
+ if (!empty($coachId)) {
+ echo ''
+ .Display::return_icon('2rightarrow.png', get_lang('Details'), ['class' => 'details-icon'])
+ .' | ';
+ } else {
+ echo ''
+ .Display::return_icon('2rightarrow.png', get_lang('Details'), ['class' => 'details-icon'])
+ .' | ';
+ }
+ echo '
';
}
$totalAttendanceFormatted = $scoreDisplay->display_score($totalAttendance);
@@ -1711,10 +1826,13 @@
$totalTheoreticalTimeDisplay = sprintf('%02d:%02d', $totalHours, $totalMinutes);
echo ''.$totalTheoreticalTimeDisplay.' | ';
}
- echo ''.$totalAttendanceFormatted.' |
- '.$totalEvaluations.' |
- |
- ';
+ if (!empty($sId)) {
+ echo ' | ';
+ }
+ echo ''.$totalAttendanceFormatted.' | ',
+ ''.$totalEvaluations.' | ',
+ ' | ',
+ '';
if($theoreticalTimeEnabled) {
$csvRow = [
@@ -1724,10 +1842,13 @@
$totalProgressFormatted,
$totalScoreFormatted,
$totalTheoreticalTimeDisplay,
- $totalAttendanceFormatted,
- $totalEvaluations,
- '',
];
+ if (!empty($sId)) {
+ $csvRow[] = '';
+ }
+ $csvRow[] = $totalAttendanceFormatted;
+ $csvRow[] = $totalEvaluations;
+ $csvRow[] = '';
} else {
$csvRow = [
get_lang('Total'),
@@ -1735,10 +1856,13 @@
$totalTimeFormatted,
$totalProgressFormatted,
$totalScoreFormatted,
- $totalAttendanceFormatted,
- $totalEvaluations,
- '',
];
+ if (!empty($sId)) {
+ $csvRow[] = '';
+ }
+ $csvRow[] = $totalAttendanceFormatted;
+ $csvRow[] = $totalEvaluations;
+ $csvRow[] = '';
}
$csv_content[] = $csvRow;