diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php
index ce2e07320b..022de40091 100755
--- a/main/mySpace/myStudents.php
+++ b/main/mySpace/myStudents.php
@@ -38,7 +38,6 @@ if (empty($student_id)) {
api_not_allowed(true);
}
-// user info
$user_info = api_get_user_info($student_id);
if (empty($user_info)) {
@@ -241,6 +240,8 @@ switch ($action) {
break;
case 'export_to_pdf':
$sessionToExport = $sId = 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);
@@ -276,39 +277,43 @@ switch ($action) {
$first = Tracking::get_first_connection_date($student_id);
$last = Tracking::get_last_connection_date($student_id);
-
- $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++;
+ $timeSpentContent = '';
+ 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();
}
- $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);
$courseTable = '';
-
if (!empty($courses)) {
$courseTable .= '
';
$courseTable .= '';
$courseTable .= '
| '.get_lang('FormationUnit').' |
'.get_lang('ConnectionTime').' |
- '.get_lang('Progress').' |
- '.get_lang('Score').' |
-
';
+ '.get_lang('Progress').' | ';
+
+ if ('attendance' === $type) {
+ $courseTable .= ''.get_lang('Score').' | ';
+ }
+ $courseTable .= '';
$courseTable .= '';
$courseTable .= '';
@@ -364,8 +369,10 @@ switch ($action) {
$courseInfoItem['title'].'
'.$time_spent_on_course.' |
- '.$progress.' |
- '.$score.' | ';
+ '.$progress.' | ';
+ if ('attendance' === $type) {
+ $courseTable .= ''.$score.' | ';
+ }
$courseTable .= '';
}
}
@@ -383,16 +390,33 @@ switch ($action) {
'.get_lang('Total').' |
'.$totalTimeFormatted.' |
'.$totalProgressFormatted.' |
- '.$totalScoreFormatted.' |
- ';
+ ';
+ if ('attendance' === $type) {
+ $courseTable .= ''.$totalScoreFormatted.' | ';
+ }
+ $courseTable .= '';
$courseTable .= '
';
}
$tpl = new Template('', false, false, false, true, false, false);
$tpl->assign('title', get_lang('AttestationOfAttendance'));
$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', $user_info['complete_name']);
- $tpl->assign('table_progress', $table->toHtml());
+ $tpl->assign('student_info', $user_info);
+ $tpl->assign('student_info_extra_fields', UserManager::get_extra_user_data($user_info['user_id']));
+ $tpl->assign('table_progress', $timeSpentContent);
$tpl->assign(
'subtitle',
sprintf(
@@ -401,7 +425,11 @@ switch ($action) {
)
);
$tpl->assign('table_course', $courseTable);
- $content = $tpl->fetch($tpl->get_template('my_space/pdf_export_student.tpl'));
+ $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'),
@@ -414,7 +442,7 @@ switch ($action) {
'show_teacher_as_myself' => false,
'orientation' => 'P',
];
- $pdf = new PDF('A4', $params['orientation'], $params);
+ @$pdf = new PDF('A4', $params['orientation'], $params);
try {
$pdf->setBackground($tpl->theme);
@@ -1453,7 +1481,12 @@ if (empty($details)) {
$sessionAction .= Display::url(
Display::return_icon('pdf.png', get_lang('ExportToPDF'), [], ICON_SIZE_MEDIUM),
$currentUrl.'&'
- .http_build_query(['action' => 'export_to_pdf', 'session_to_export' => $sId])
+ .http_build_query(['action' => 'export_to_pdf', 'type' => 'attendance', 'session_to_export' => $sId])
+ );
+ $sessionAction .= Display::url(
+ Display::return_icon('pdf.png', get_lang('CertificateOfAchievement'), [], ICON_SIZE_MEDIUM),
+ $currentUrl.'&'
+ .http_build_query(['action' => 'export_to_pdf', 'type' => 'achievement', 'session_to_export' => $sId])
);
}
echo $sessionAction;
diff --git a/main/template/default/my_space/certificate_achievement.tpl b/main/template/default/my_space/certificate_achievement.tpl
new file mode 100644
index 0000000000..79e71430a3
--- /dev/null
+++ b/main/template/default/my_space/certificate_achievement.tpl
@@ -0,0 +1,39 @@
+
+ {{ logo }}
+
+
+{% if title %}
+
+ {{ title }}
+
+{% endif %}
+
+{% if session_title %}
+
+ {{ session_title }}
+
+{% endif %}
+
+{% if student_info %}
+
+ {{ 'NamesAndLastNames'|get_lang }} : {{ student_info.complete_name }}
+
+{% endif %}
+
+{% if table_progress %}
+
+ {{ table_progress }}
+
+{% endif %}
+
+{% if subtitle %}
+
+ {{ subtitle }}
+
+{% endif %}
+
+{% if table_course %}
+
+ {{ table_course }}
+
+{% endif %}