|
130 | 130 |
|
131 | 131 | // users subscribed to the course through a session |
132 | 132 |
|
133 | | - if (api_get_session_id()) { |
| 133 | + if (api_get_session_id()) { |
134 | 134 | $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
135 | 135 | $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 |
136 | 136 | FROM $table_session_course_user as session_course_user, $table_users as user "; |
|
242 | 242 | Export::export_table_xls($a_users); |
243 | 243 | exit; |
244 | 244 | case 'pdf' : |
245 | | - $header = get_lang('StudentList'); |
246 | | - $description = '<table class="data_table_no_border">'; |
247 | | - if (api_get_session_id()) { |
248 | | - $description .= '<tr><td>'.get_lang('Session').': </td><td class="highlight">'.api_get_session_name(api_get_session_id()).'</td>'; |
249 | | - } |
250 | | - $description .= '<tr><td>'.get_lang('Course').': </td><td class="highlight">'.$course_info['name'].'</td>'; |
251 | | - |
252 | | - $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']); |
253 | | - $coaches = CourseManager::get_coach_list_from_course_code_to_string($course_info['code'], $session_id); |
| 245 | + $header = get_lang('StudentList'); |
| 246 | + $description = '<table class="data_table_no_border">'; |
| 247 | + if (api_get_session_id()) { |
| 248 | + $description .= '<tr><td>'.get_lang('Session').': </td><td class="highlight">'.api_get_session_name(api_get_session_id()).'</td>'; |
| 249 | + } |
| 250 | + $description .= '<tr><td>'.get_lang('Course').': </td><td class="highlight">'.$course_info['name'].'</td>'; |
254 | 251 |
|
255 | | - if (!empty($teachers)) { |
256 | | - $description .= '<tr><td>'.get_lang('Teachers').': </td><td class="highlight">'.$teachers.' </td>'; |
257 | | - } |
258 | | - if (!empty($coaches)) { |
259 | | - $description .= '<tr><td>'.get_lang('Coachs').': </td><td class="highlight">'.$coaches.' </td>'; |
260 | | - } |
261 | | - $description .= '<tr><td>'.get_lang('Date').': </td><td class="highlight">'.api_convert_and_format_date(time(), DATE_TIME_FORMAT_LONG).'</td>'; |
262 | | - $description .= '</table>'; |
263 | | - $params = array(); |
264 | | - Export::export_table_pdf($a_users, get_lang('UserList'), $header, $description, $params); |
265 | | - exit; |
| 252 | + $teachers = CourseManager::get_teacher_list_from_course_code($course_info['code']); |
| 253 | + |
| 254 | + //If I'm a teacher in this course show just my name |
| 255 | + if (isset($teachers[$user_id])) { |
| 256 | + if (!empty($teachers)) { |
| 257 | + $teacher_info = $teachers[$user_id]; |
| 258 | + $description .= '<tr><td>'.get_lang('Teacher').': </td><td class="highlight">'.api_get_person_name($teacher_info['firstname'], $teacher_info['lastname']).'</td>'; |
| 259 | + } |
| 260 | + } else { |
| 261 | + //If not show all teachers |
| 262 | + $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']); |
| 263 | + if (!empty($teachers)) { |
| 264 | + $description .= '<tr><td>'.get_lang('Teachers').': </td><td class="highlight">'.$teachers.'</td>'; |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + if (!empty($session_id)) { |
| 269 | + //If I'm a coach |
| 270 | + $coaches = CourseManager::get_coach_list_from_course_code($course_info['code'], $session_id); |
| 271 | + |
| 272 | + if (isset($coaches) && isset($coaches[$user_id])) { |
| 273 | + $user_info = api_get_user_info($user_id); |
| 274 | + $description .= '<tr><td>'.get_lang('Coach').': </td><td class="highlight">'.$user_info['complete_name'].'</td>'; |
| 275 | + } else { |
| 276 | + //If not show everything |
| 277 | + $teachers = CourseManager::get_coach_list_from_course_code_to_string($course_info['code'], $session_id); |
| 278 | + if (!empty($teachers)) { |
| 279 | + $description .= '<tr><td>'.get_lang('Coachs').': </td><td class="highlight">'.$coaches.'</td>'; |
| 280 | + } |
| 281 | + } |
| 282 | + } |
| 283 | + |
| 284 | + $description .= '<tr><td>'.get_lang('Date').': </td><td class="highlight">'.api_convert_and_format_date(time(), DATE_TIME_FORMAT_LONG).'</td>'; |
| 285 | + $description .= '</table>'; |
| 286 | + $params = array(); |
| 287 | + Export::export_table_pdf($a_users, get_lang('UserList'), $header, $description, $params); |
| 288 | + exit; |
266 | 289 | } |
267 | 290 | } |
268 | 291 | } |
|
0 commit comments