diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php
index 2fa1f151fb..3a650b6a6d 100644
--- a/main/inc/lib/course.lib.php
+++ b/main/inc/lib/course.lib.php
@@ -1283,9 +1283,7 @@ class CourseManager {
}
// We get the session coach.
- $rs = Database::query('SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).
- ' WHERE id="'.$session_id.'"');
- $user_info = array();
+ $rs = Database::query('SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id="'.$session_id.'"');
$session_id_coach = Database::result($rs, 0, 'id_coach');
$user_info = Database::get_user_info_from_id($session_id_coach);
$user_info['status'] = $user['status'];
@@ -1293,7 +1291,6 @@ class CourseManager {
$user_info['tutor_id'] = $user['tutor_id'];
$user_info['email'] = $user['email'];
$users[$session_id_coach] = $user_info;
-
return $users;
}
diff --git a/main/user/user.php b/main/user/user.php
index e5a1f68bf2..98c1d46318 100644
--- a/main/user/user.php
+++ b/main/user/user.php
@@ -130,7 +130,7 @@ if (api_is_allowed_to_edit(null, true)) {
// users subscribed to the course through a session
- if (api_get_session_id()) {
+ if (api_get_session_id()) {
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", $select_email_condition phone, user.official_code, active $legal
FROM $table_session_course_user as session_course_user, $table_users as user ";
@@ -242,27 +242,50 @@ if (api_is_allowed_to_edit(null, true)) {
Export::export_table_xls($a_users);
exit;
case 'pdf' :
- $header = get_lang('StudentList');
- $description = '
';
- if (api_get_session_id()) {
- $description .= '| '.get_lang('Session').': | '.api_get_session_name(api_get_session_id()).' | ';
- }
- $description .= '
| '.get_lang('Course').': | '.$course_info['name'].' | ';
-
- $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
- $coaches = CourseManager::get_coach_list_from_course_code_to_string($course_info['code'], $session_id);
+ $header = get_lang('StudentList');
+ $description = '';
+ if (api_get_session_id()) {
+ $description .= '| '.get_lang('Session').': | '.api_get_session_name(api_get_session_id()).' | ';
+ }
+ $description .= '
| '.get_lang('Course').': | '.$course_info['name'].' | ';
- if (!empty($teachers)) {
- $description .= '
| '.get_lang('Teachers').': | '.$teachers.' | ';
- }
- if (!empty($coaches)) {
- $description .= '
| '.get_lang('Coachs').': | '.$coaches.' | ';
- }
- $description .= '
| '.get_lang('Date').': | '.api_convert_and_format_date(time(), DATE_TIME_FORMAT_LONG).' | ';
- $description .= '
';
- $params = array();
- Export::export_table_pdf($a_users, get_lang('UserList'), $header, $description, $params);
- exit;
+ $teachers = CourseManager::get_teacher_list_from_course_code($course_info['code']);
+
+ //If I'm a teacher in this course show just my name
+ if (isset($teachers[$user_id])) {
+ if (!empty($teachers)) {
+ $teacher_info = $teachers[$user_id];
+ $description .= '
| '.get_lang('Teacher').': | '.api_get_person_name($teacher_info['firstname'], $teacher_info['lastname']).' | ';
+ }
+ } else {
+ //If not show all teachers
+ $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
+ if (!empty($teachers)) {
+ $description .= '
| '.get_lang('Teachers').': | '.$teachers.' | ';
+ }
+ }
+
+ if (!empty($session_id)) {
+ //If I'm a coach
+ $coaches = CourseManager::get_coach_list_from_course_code($course_info['code'], $session_id);
+
+ if (isset($coaches) && isset($coaches[$user_id])) {
+ $user_info = api_get_user_info($user_id);
+ $description .= '
| '.get_lang('Coach').': | '.$user_info['complete_name'].' | ';
+ } else {
+ //If not show everything
+ $teachers = CourseManager::get_coach_list_from_course_code_to_string($course_info['code'], $session_id);
+ if (!empty($teachers)) {
+ $description .= '
| '.get_lang('Coachs').': | '.$coaches.' | ';
+ }
+ }
+ }
+
+ $description .= '
| '.get_lang('Date').': | '.api_convert_and_format_date(time(), DATE_TIME_FORMAT_LONG).' | ';
+ $description .= '
';
+ $params = array();
+ Export::export_table_pdf($a_users, get_lang('UserList'), $header, $description, $params);
+ exit;
}
}
}