myStudents.php 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Implements the tracking of students in the Reporting pages
  5. * @package chamilo.reporting
  6. */
  7. api_block_anonymous_users();
  8. if (!api_is_allowed_to_create_course() &&
  9. !api_is_session_admin() &&
  10. !api_is_drh() &&
  11. !api_is_student_boss()
  12. ) {
  13. // Check if the user is tutor of the course
  14. $user_course_status = CourseManager::get_tutor_in_course_status(
  15. api_get_user_id(),
  16. api_get_course_id()
  17. );
  18. if ($user_course_status != 1) {
  19. api_not_allowed(true);
  20. }
  21. }
  22. $alloAssignSkill = api_is_platform_admin(false, true);
  23. $htmlHeadXtra[] = '<script>
  24. function show_image(image,width,height) {
  25. width = parseInt(width) + 20;
  26. height = parseInt(height) + 20;
  27. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
  28. }
  29. </script>';
  30. $export = isset($_GET['export']) ? $_GET['export'] : false;
  31. $sessionId = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0;
  32. $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
  33. $course_code = isset($_GET['course']) ? Security :: remove_XSS($_GET['course']) : null;
  34. // time spent on the course
  35. $courseInfo = api_get_course_info($course_code);
  36. if (empty($sessionId)) {
  37. $sessionId = api_get_session_id();
  38. }
  39. if ($export) {
  40. ob_start();
  41. }
  42. $csv_content = array();
  43. $from_myspace = false;
  44. if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
  45. $from_myspace = true;
  46. $this_section = SECTION_TRACKING;
  47. } else {
  48. $this_section = SECTION_COURSES;
  49. }
  50. $nameTools = get_lang('StudentDetails');
  51. $em = Database::getManager();
  52. if (isset($_GET['details'])) {
  53. if ($origin == 'user_course') {
  54. if (empty ($cidReq)) {
  55. $interbreadcrumb[] = array (
  56. "url" => api_get_path(WEB_COURSE_PATH) . $courseInfo['directory'],
  57. 'name' => $courseInfo['title']
  58. );
  59. }
  60. $interbreadcrumb[] = array (
  61. "url" => "../user/user.php?cidReq=" . $course_code,
  62. "name" => get_lang("Users")
  63. );
  64. } else
  65. if ($origin == 'tracking_course') {
  66. $interbreadcrumb[] = array (
  67. "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session=' . api_get_session_id(),
  68. "name" => get_lang("Tracking")
  69. );
  70. } else
  71. if ($origin == 'resume_session') {
  72. $interbreadcrumb[] = array (
  73. 'url' => "../session/session_list.php",
  74. "name" => get_lang('SessionList')
  75. );
  76. $interbreadcrumb[] = array (
  77. 'url' => "../session/resume_session.php?id_session=" . $sessionId,
  78. "name" => get_lang('SessionOverview')
  79. );
  80. } else {
  81. $interbreadcrumb[] = array (
  82. "url" => api_is_student_boss()?"#":"index.php",
  83. "name" => get_lang('MySpace')
  84. );
  85. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  86. $interbreadcrumb[] = array (
  87. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  88. "name" => get_lang("CoachStudents")
  89. );
  90. $interbreadcrumb[] = array (
  91. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']) . '&id_coach=' . Security :: remove_XSS($_GET['id_coach']),
  92. "name" => get_lang("StudentDetails")
  93. );
  94. } else {
  95. $interbreadcrumb[] = array (
  96. "url" => "student.php",
  97. "name" => get_lang("MyStudents")
  98. );
  99. $interbreadcrumb[] = array (
  100. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
  101. "name" => get_lang("StudentDetails")
  102. );
  103. }
  104. }
  105. $nameTools = get_lang("DetailsStudentInCourse");
  106. } else {
  107. if ($origin == 'resume_session') {
  108. $interbreadcrumb[] = array (
  109. 'url' => "../session/session_list.php",
  110. "name" => get_lang('SessionList')
  111. );
  112. if (!empty($sessionId)) {
  113. $interbreadcrumb[] = array(
  114. 'url' => "../session/resume_session.php?id_session=".$sessionId,
  115. "name" => get_lang('SessionOverview')
  116. );
  117. }
  118. } else {
  119. $interbreadcrumb[] = array (
  120. "url" => api_is_student_boss()?"#":"index.php",
  121. "name" => get_lang('MySpace')
  122. );
  123. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  124. if ($sessionId) {
  125. $interbreadcrumb[] = array (
  126. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']) . "&id_session=" . $sessionId,
  127. "name" => get_lang("CoachStudents")
  128. );
  129. } else {
  130. $interbreadcrumb[] = array (
  131. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  132. "name" => get_lang("CoachStudents")
  133. );
  134. }
  135. } else {
  136. $interbreadcrumb[] = array (
  137. "url" => "student.php",
  138. "name" => get_lang("MyStudents")
  139. );
  140. }
  141. }
  142. }
  143. // Database Table Definitions
  144. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  145. $tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  146. if (isset($_GET['user_id']) && $_GET['user_id'] != "") {
  147. $user_id = intval($_GET['user_id']);
  148. } else {
  149. $user_id = api_get_user_id();
  150. }
  151. $student_id = intval($_GET['student']);
  152. // Action behaviour
  153. $check = Security::check_token('get');
  154. if ($check) {
  155. switch ($_GET['action']) {
  156. case 'reset_lp':
  157. $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : "";
  158. if (api_is_allowed_to_edit() &&
  159. !empty($lp_id) &&
  160. !empty($student_id)
  161. ) {
  162. Event::delete_student_lp_events(
  163. $student_id,
  164. $lp_id,
  165. $courseInfo,
  166. $sessionId
  167. );
  168. // @todo delete the stats.track_e_exercises records.
  169. // First implement this http://support.chamilo.org/issues/1334
  170. $message = Display::return_message(
  171. get_lang('LPWasReset'),
  172. 'success'
  173. );
  174. }
  175. break;
  176. default:
  177. break;
  178. }
  179. Security::clear_token();
  180. }
  181. // user info
  182. $user_info = api_get_user_info($student_id);
  183. $courses_in_session = array();
  184. //See #4676
  185. $drh_can_access_all_courses = false;
  186. if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) {
  187. $drh_can_access_all_courses = true;
  188. }
  189. $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
  190. $courses_in_session_by_coach = array();
  191. $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
  192. // RRHH or session admin
  193. if (api_is_session_admin() || api_is_drh()) {
  194. $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
  195. $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
  196. if (!empty($session_by_session_admin)) {
  197. foreach ($session_by_session_admin as $session_coached_by_user) {
  198. $courses_followed_by_coach = Tracking :: get_courses_list_from_session($session_coached_by_user['id']);
  199. $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
  200. }
  201. }
  202. }
  203. // Teacher or admin
  204. if (!empty($sessions_coached_by_user)) {
  205. foreach ($sessions_coached_by_user as $session_coached_by_user) {
  206. $sid = intval($session_coached_by_user['id']);
  207. $courses_followed_by_coach = Tracking :: get_courses_followed_by_coach(api_get_user_id(), $sid);
  208. $courses_in_session_by_coach[$sid] = $courses_followed_by_coach;
  209. }
  210. }
  211. $sql = "SELECT c_id
  212. FROM $tbl_course_user
  213. WHERE
  214. relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND
  215. user_id = ".intval($user_info['user_id']);
  216. $rs = Database::query($sql);
  217. while ($row = Database :: fetch_array($rs)) {
  218. if ($drh_can_access_all_courses) {
  219. $courses_in_session[0][] = $row['c_id'];
  220. } else {
  221. if (isset($courses[$row['c_id']])) {
  222. $courses_in_session[0][] = $row['c_id'];
  223. }
  224. }
  225. }
  226. // Get the list of sessions where the user is subscribed as student
  227. $sql = 'SELECT session_id, c_id
  228. FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
  229. WHERE user_id=' . intval($user_info['user_id']);
  230. $rs = Database::query($sql);
  231. $tmp_sessions = array();
  232. while ($row = Database :: fetch_array($rs, 'ASSOC')) {
  233. $tmp_sessions[] = $row['session_id'];
  234. if ($drh_can_access_all_courses) {
  235. if (in_array($row['session_id'], $tmp_sessions)) {
  236. $courses_in_session[$row['session_id']][] = $row['c_id'];
  237. }
  238. } else {
  239. if (isset($courses_in_session_by_coach[$row['session_id']])) {
  240. if (in_array($row['session_id'], $tmp_sessions)) {
  241. $courses_in_session[$row['session_id']][] = $row['c_id'];
  242. }
  243. }
  244. }
  245. }
  246. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  247. api_get_user_id(),
  248. api_get_course_info()
  249. );
  250. if (api_is_drh() && !api_is_platform_admin()) {
  251. if (!empty($student_id)) {
  252. if (api_drh_can_access_all_session_content()) {
  253. //@todo securize drh with student id
  254. /*$users = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id());
  255. $userList = array();
  256. foreach ($users as $user) {
  257. $userList[] = $user['user_id'];
  258. }
  259. if (!in_array($student_id, $userList)) {
  260. api_not_allowed(true);
  261. }*/
  262. } else {
  263. if (!($isDrhOfCourse)) {
  264. if (api_is_drh() &&
  265. !UserManager::is_user_followed_by_drh($student_id, api_get_user_id())
  266. ) {
  267. api_not_allowed(true);
  268. }
  269. }
  270. }
  271. }
  272. }
  273. Display :: display_header($nameTools);
  274. if (isset($message)) {
  275. echo $message;
  276. }
  277. $token = Security::get_token();
  278. if (!empty($student_id)) {
  279. // Actions bar
  280. echo '<div class="actions">';
  281. echo '<a href="javascript: window.history.go(-1);">'.
  282. Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  283. echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
  284. Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
  285. echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">'.
  286. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
  287. echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=xls">'.
  288. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
  289. if (!empty ($user_info['email'])) {
  290. $send_mail = '<a href="mailto:'.$user_info['email'].'">'.
  291. Display :: return_icon('mail_send.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM).'</a>';
  292. } else {
  293. $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM);
  294. }
  295. echo $send_mail;
  296. if (!empty($student_id) && !empty($_GET['course'])) {
  297. // Only show link to connection details if course and student were defined in the URL
  298. echo '<a href="access_details.php?student=' . $student_id . '&course=' . Security :: remove_XSS($_GET['course']) . '&origin=' . $origin. '&cidReq='.Security::remove_XSS($_GET['course']).'&id_session='.$sessionId.'">'.
  299. Display :: return_icon('statistics.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>';
  300. }
  301. if (api_can_login_as($student_id)) {
  302. echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$student_id.'&sec_token='.$token.'">'.
  303. Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a>';
  304. }
  305. if ($alloAssignSkill) {
  306. echo Display::url(
  307. Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_MEDIUM),
  308. api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $student_id])
  309. );
  310. }
  311. echo '</div>';
  312. // is the user online ?
  313. if (UserManager::user_is_online($_GET['student'])) {
  314. $online = get_lang('Yes');
  315. } else {
  316. $online = get_lang('No');
  317. }
  318. // get average of score and average of progress by student
  319. $avg_student_progress = $avg_student_score = 0;
  320. if (CourseManager :: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
  321. $avg_student_progress = Tracking::get_avg_student_progress(
  322. $user_info['user_id'],
  323. $course_code,
  324. array(),
  325. $sessionId
  326. );
  327. //the score inside the Reporting table
  328. $avg_student_score = Tracking::get_avg_student_score(
  329. $user_info['user_id'],
  330. $course_code,
  331. array(),
  332. $sessionId
  333. );
  334. }
  335. $avg_student_progress = round($avg_student_progress, 2);
  336. $time_spent_on_the_course = 0;
  337. if (!empty($courseInfo)) {
  338. $time_spent_on_the_course = api_time_to_hms(
  339. Tracking:: get_time_spent_on_the_course(
  340. $user_info['user_id'],
  341. $courseInfo['real_id'],
  342. $sessionId
  343. )
  344. );
  345. }
  346. // get information about connections on the platform by student
  347. $first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']);
  348. if ($first_connection_date == '') {
  349. $first_connection_date = get_lang('NoConnexion');
  350. }
  351. $last_connection_date = Tracking :: get_last_connection_date($user_info['user_id'], true);
  352. if ($last_connection_date == '') {
  353. $last_connection_date = get_lang('NoConnexion');
  354. }
  355. // cvs information
  356. $csv_content[] = array(
  357. get_lang('Information', '')
  358. );
  359. $csv_content[] = array (
  360. get_lang('Name', ''),
  361. get_lang('Email', ''),
  362. get_lang('Tel', '')
  363. );
  364. $csv_content[] = array(
  365. $user_info['complete_name'],
  366. $user_info['email'],
  367. $user_info['phone']
  368. );
  369. $csv_content[] = array();
  370. // csv tracking
  371. $csv_content[] = array(
  372. get_lang('Tracking', '')
  373. );
  374. $csv_content[] = array(
  375. get_lang('FirstLoginInPlatform', ''),
  376. get_lang('LatestLoginInPlatform', ''),
  377. get_lang('TimeSpentInTheCourse', ''),
  378. get_lang('Progress', ''),
  379. get_lang('Score', '')
  380. );
  381. $csv_content[] = array(
  382. strip_tags($first_connection_date),
  383. strip_tags($last_connection_date),
  384. $time_spent_on_the_course,
  385. $avg_student_progress . '%',
  386. $avg_student_score
  387. );
  388. $coachs_name = '';
  389. $session_name = '';
  390. // $nb_login = Tracking :: count_login_per_student($user_info['user_id'], $info_course['real_id']);
  391. //get coach and session_name if there is one and if session_mode is activated
  392. /*if ($sessionId > 0) {
  393. $session_info = api_get_session_info($sessionId);
  394. $session_coach_id = $session_info['session_admin_id'];
  395. $course_coachs = api_get_coachs_from_course($sessionId, $info_course['real_id']);
  396. $nb_login = '';
  397. if (!empty($course_coachs)) {
  398. $info_tutor_name = array();
  399. foreach ($course_coachs as $course_coach) {
  400. $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
  401. }
  402. $info_course['tutor_name'] = implode(",",$info_tutor_name);
  403. } elseif ($session_coach_id != 0) {
  404. $session_coach_id = intval($session_info['id_coach']);
  405. $coach_info = api_get_user_info($session_coach_id);
  406. $info_course['tutor_name'] = $coach_info['complete_name'];
  407. }
  408. $coachs_name = $info_course['tutor_name'];
  409. $session_name = $session_info['name'];
  410. } // end
  411. */
  412. $table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).$user_info['complete_name'];
  413. echo Display::page_subheader($table_title);
  414. $userPicture = UserManager::getUserPicture($user_info['user_id']);
  415. $userGroupManager = new UserGroup();
  416. $userGroups = $userGroupManager->getNameListByUser($user_info['user_id'], UserGroup::NORMAL_CLASS);
  417. ?>
  418. <img src="<?php echo $userPicture ?>">
  419. <div class="row">
  420. <div class="col-sm-6">
  421. <table class="table table-striped table-hover">
  422. <thead>
  423. <tr>
  424. <th><?php echo get_lang('Information'); ?></th>
  425. </tr>
  426. </thead>
  427. <tbody>
  428. <tr>
  429. <td><?php echo get_lang('Name') . ' : '.$user_info['complete_name']; ?></td>
  430. </tr>
  431. <tr>
  432. <td><?php echo get_lang('Email') . ' : ';
  433. if (!empty ($user_info['email'])) {
  434. echo '<a href="mailto:' . $user_info['email'] . '">' . $user_info['email'] . '</a>';
  435. } else {
  436. echo get_lang('NoEmail');
  437. } ?>
  438. </td>
  439. </tr>
  440. <tr>
  441. <td> <?php echo get_lang('Tel') . ' : ';
  442. if (!empty ($user_info['phone'])) {
  443. echo $user_info['phone'];
  444. } else {
  445. echo get_lang('NoTel');
  446. }
  447. ?>
  448. </td>
  449. </tr>
  450. <tr>
  451. <td> <?php echo get_lang('OfficialCode') . ' : ';
  452. if (!empty ($user_info['official_code'])) {
  453. echo $user_info['official_code'];
  454. } else {
  455. echo get_lang('NoOfficialCode');
  456. }
  457. ?>
  458. </td>
  459. </tr>
  460. <tr>
  461. <td><?php echo get_lang('OnLine') . ' : '.$online; ?> </td>
  462. </tr>
  463. <?php
  464. // Display timezone if the user selected one and if the admin allows the use of user's timezone
  465. $timezone = null;
  466. $timezone_user = UserManager::get_extra_user_data_by_field($user_info['user_id'],'timezone');
  467. $use_users_timezone = api_get_setting('profile.use_users_timezone');
  468. if (isset($timezone_user['timezone']) &&
  469. !empty($timezone_user['timezone']) &&
  470. $use_users_timezone == 'true'
  471. ) {
  472. $timezone = $timezone_user['timezone'];
  473. }
  474. if ($timezone !== null) {
  475. ?>
  476. <tr>
  477. <td> <?php echo get_lang('Timezone') . ' : '.$timezone; ?> </td>
  478. </tr>
  479. <?php
  480. }
  481. ?>
  482. </tbody>
  483. </table>
  484. </div>
  485. <div class="col-sm-6">
  486. <table class="table table-striped table-hover">
  487. <thead>
  488. <tr>
  489. <th colspan="2" class="text-center"><?php echo get_lang('Tracking'); ?></th>
  490. </tr>
  491. </thead>
  492. <tbody>
  493. <tr><td align="right"><?php echo get_lang('FirstLoginInPlatform') ?></td>
  494. <td align="left"><?php echo $first_connection_date ?></td>
  495. </tr>
  496. <tr>
  497. <td align="right"><?php echo get_lang('LatestLoginInPlatform') ?></td>
  498. <td align="left"><?php echo $last_connection_date ?></td>
  499. </tr>
  500. <?php if (isset($_GET['details']) && $_GET['details'] == 'true') {?>
  501. <tr>
  502. <td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
  503. <td align="left"><?php echo $time_spent_on_the_course ?></td>
  504. </tr>
  505. <tr>
  506. <td align="right">
  507. <?php
  508. echo get_lang('Progress').' ';
  509. Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));?>
  510. </td>
  511. <td align="left"><?php echo $avg_student_progress.'%' ?></td>
  512. </tr>
  513. <tr>
  514. <td align="right">
  515. <?php
  516. echo get_lang('Score').' ';
  517. Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?>
  518. </td>
  519. <td align="left"><?php
  520. if (is_numeric($avg_student_score)) {
  521. echo $avg_student_score.'%';
  522. } else {
  523. echo $avg_student_score;
  524. }
  525. ?>
  526. </td>
  527. </tr>
  528. <?php
  529. /*if (!empty($nb_login)) {
  530. echo '<tr><td align="right">'.get_lang('CountToolAccess').'</td>';
  531. echo '<td align="left"> '.$nb_login.'</td>';
  532. echo '</tr>';
  533. }*/
  534. } ?>
  535. </tbody>
  536. </table>
  537. <?php if (!empty($userGroups)) { ?>
  538. <table class="table table-striped table-hover">
  539. <thead>
  540. <tr>
  541. <th><?php echo get_lang('Classes') ?></th>
  542. </tr>
  543. </thead>
  544. <tbody>
  545. <?php foreach ($userGroups as $class) { ?>
  546. <tr>
  547. <td><?php echo $class ?></td>
  548. </tr>
  549. <?php } ?>
  550. </tbody>
  551. </table>
  552. <?php } ?>
  553. </div>
  554. </div>
  555. <?php
  556. /*$table_title = '';
  557. if (!empty($sessionId)) {
  558. $session_name = api_get_session_name($sessionId);
  559. $table_title = $session_name ? Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.' ':'';
  560. }
  561. if (!empty($courseInfo['title'])) {
  562. $table_title .= $courseInfo ? Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$courseInfo['title'].' ':'';
  563. }
  564. echo Display::page_subheader($table_title);*/
  565. if (empty($_GET['details'])) {
  566. $csv_content[] = array();
  567. $csv_content[] = array(
  568. get_lang('Session'),
  569. get_lang('Course'),
  570. get_lang('Time'),
  571. get_lang('Progress'),
  572. get_lang('Score'),
  573. get_lang('AttendancesFaults'),
  574. get_lang('Evaluations')
  575. );
  576. $attendance = new Attendance();
  577. foreach ($courses_in_session as $sessionId => $courses) {
  578. $session_name = '';
  579. $access_start_date = '';
  580. $access_end_date = '';
  581. $date_session = '';
  582. $title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
  583. $session_info = api_get_session_info($sessionId);
  584. if ($session_info) {
  585. $session_name = $session_info['name'];
  586. if (!empty($session_info['access_start_date']) && $session_info['access_start_date'] != '0000-00-00') {
  587. $access_start_date = api_format_date($session_info['access_start_date'], DATE_FORMAT_SHORT);
  588. }
  589. if (!empty($session_info['access_end_date']) && $session_info['access_end_date'] != '0000-00-00') {
  590. $access_end_date = api_format_date($session_info['access_end_date'], DATE_FORMAT_SHORT);
  591. }
  592. if (!empty($access_start_date) && !empty($access_end_date)) {
  593. $date_session = get_lang('From') . ' ' . $access_start_date . ' ' . get_lang('Until') . ' ' . $access_end_date;
  594. }
  595. $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':'');
  596. }
  597. // Courses
  598. echo '<h3>'.$title.'</h3>';
  599. echo '<div class="table-respondive">';
  600. echo '<table class="table table-striped table-hover courses-tracking">';
  601. echo '<thead>';
  602. echo '<tr>
  603. <th>'.get_lang('Course').'</th>
  604. <th>'.get_lang('Time').'</th>
  605. <th>'.get_lang('Progress').'</th>
  606. <th>'.get_lang('Score').'</th>
  607. <th>'.get_lang('AttendancesFaults').'</th>
  608. <th>'.get_lang('Evaluations').'</th>
  609. <th>'.get_lang('Details').'</th>
  610. </tr>';
  611. echo '</thead>';
  612. echo '<tbody>';
  613. if (!empty($courses)) {
  614. foreach ($courses as $courseId) {
  615. $courseInfoItem = api_get_course_info_by_id($courseId);
  616. $courseId = $courseInfoItem['real_id'];
  617. $courseCodeItem = $courseInfoItem['code'];
  618. if (CourseManager :: is_user_subscribed_in_course($student_id, $courseCodeItem, true)) {
  619. $time_spent_on_course = api_time_to_hms(
  620. Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sessionId)
  621. );
  622. // get average of faults in attendances by student
  623. $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $courseCodeItem, $sessionId);
  624. if (!empty($results_faults_avg['total'])) {
  625. if (api_is_drh()) {
  626. $attendances_faults_avg =
  627. '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sessionId.'&student_id='.$student_id.'">'.
  628. $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  629. } else {
  630. $attendances_faults_avg =
  631. $results_faults_avg['faults'].'/'.
  632. $results_faults_avg['total'].
  633. ' ('.$results_faults_avg['porcent'].'%)'
  634. ;
  635. }
  636. } else {
  637. $attendances_faults_avg = '0/0 (0%)';
  638. }
  639. // Get evaluations by student
  640. $cats = Category::load(null, null, $courseCodeItem, null, null, $sessionId);
  641. $scoretotal = array();
  642. if (isset($cats) && isset($cats[0])) {
  643. if (!empty($sessionId)) {
  644. $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem, $sessionId);
  645. } else {
  646. $scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem);
  647. }
  648. }
  649. $scoretotal_display = '0/0 (0%)';
  650. if (!empty($scoretotal)) {
  651. $scoretotal_display =
  652. round($scoretotal[0], 1 ).'/'.
  653. round($scoretotal[1],1).
  654. ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
  655. }
  656. $progress = Tracking::get_avg_student_progress($user_info['user_id'], $courseCodeItem, null, $sessionId);
  657. $score = Tracking :: get_avg_student_score($user_info['user_id'], $courseCodeItem, null, $sessionId);
  658. $progress = empty($progress) ? '0%' : $progress.'%';
  659. $score = empty($score) ? '0%' : $score.'%';
  660. $csv_content[] = array(
  661. $session_name,
  662. $courseInfoItem['title'],
  663. $time_spent_on_course,
  664. $progress,
  665. $score,
  666. $attendances_faults_avg,
  667. $scoretotal_display
  668. );
  669. echo '<tr>
  670. <td ><a href="' .$courseInfoItem['course_public_url'] .'?id_session=' . $sessionId . '">'.
  671. $courseInfoItem['title'].'</a></td>
  672. <td >'.$time_spent_on_course .'</td>
  673. <td >'.$progress.'</td>
  674. <td >'.$score.'</td>
  675. <td >'.$attendances_faults_avg.'</td>
  676. <td >'.$scoretotal_display.'</td>';
  677. if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  678. echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
  679. '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  680. } else {
  681. echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
  682. '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  683. }
  684. echo '</tr>';
  685. }
  686. }
  687. } else {
  688. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  689. }
  690. echo '</tbody>';
  691. echo '</table>';
  692. echo '</div>';
  693. }
  694. } else {
  695. if ($user_info['status'] != INVITEE) {
  696. $csv_content[] = array();
  697. $csv_content[] = array(str_replace('&nbsp;', '', $table_title));
  698. $t_lp = Database :: get_course_table(TABLE_LP_MAIN);
  699. // csv export headers
  700. $csv_content[] = array();
  701. $csv_content[] = array(
  702. get_lang('Learnpath'),
  703. get_lang('Time'),
  704. get_lang('AverageScore'),
  705. get_lang('LatestAttemptAverageScore'),
  706. get_lang('Progress'),
  707. get_lang('LastConnexion')
  708. );
  709. $query = $em
  710. ->createQuery('
  711. SELECT lp FROM ChamiloCourseBundle:CLp lp
  712. WHERE lp.sessionId = :session AND lp.cId = :course
  713. ORDER BY lp.displayOrder ASC
  714. ');
  715. if (empty($sessionId)) {
  716. $query->setParameters([
  717. 'session' => 0,
  718. 'course' => $courseInfo['real_id']
  719. ]);
  720. } else {
  721. $query->setParameters([
  722. 'session' => $sessionId,
  723. 'course' => $courseInfo['real_id']
  724. ]);
  725. }
  726. $rs_lp = $query->getResult();
  727. if (count($rs_lp) > 0) {
  728. ?>
  729. <!-- LPs-->
  730. <div class="table-responsive">
  731. <table class="table table-striped table-hover">
  732. <thead>
  733. <tr>
  734. <th><?php echo get_lang('LearningPath');?></th>
  735. <th><?php
  736. echo get_lang('Time').' ';
  737. Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  738. <th><?php
  739. echo get_lang('AverageScore').' ';
  740. Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInAllAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  741. <th><?php
  742. echo get_lang('LatestAttemptAverageScore').' ';
  743. Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  744. <th><?php
  745. echo get_lang('Progress').' ';
  746. Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
  747. <th><?php
  748. echo get_lang('LastConnexion').' ';
  749. Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
  750. <?php
  751. echo '<th>'.get_lang('Details').'</th>';
  752. if (api_is_allowed_to_edit()) {
  753. echo '<th>'.get_lang('ResetLP').'</th>';
  754. }
  755. ?>
  756. </tr>
  757. </thead>
  758. <tbody>
  759. <?php
  760. $i = 0;
  761. foreach ($rs_lp as $learnpath) {
  762. $lp_id = intval($learnpath->getId());
  763. $lp_name = $learnpath->getName();
  764. $any_result = false;
  765. // Get progress in lp
  766. $progress = Tracking::get_avg_student_progress(
  767. $student_id,
  768. $course_code,
  769. array($lp_id),
  770. $sessionId
  771. );
  772. if ($progress === null) {
  773. $progress = '0%';
  774. } else {
  775. $any_result = true;
  776. }
  777. // Get time in lp
  778. $total_time = Tracking::get_time_spent_in_lp(
  779. $student_id,
  780. $course_code,
  781. array($lp_id),
  782. $sessionId
  783. );
  784. if (!empty($total_time)) {
  785. $any_result = true;
  786. }
  787. // Get last connection time in lp
  788. $start_time = Tracking::get_last_connection_time_in_lp(
  789. $student_id,
  790. $course_code,
  791. $lp_id,
  792. $sessionId
  793. );
  794. if (!empty($start_time)) {
  795. $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
  796. } else {
  797. $start_time = '-';
  798. }
  799. if (!empty($total_time)) $any_result = true;
  800. // Quiz in lp
  801. $score = Tracking::get_avg_student_score(
  802. $student_id,
  803. $course_code,
  804. array($lp_id),
  805. $sessionId
  806. );
  807. // Latest exercise results in a LP
  808. $score_latest = Tracking:: get_avg_student_score(
  809. $student_id,
  810. $course_code,
  811. array($lp_id),
  812. $sessionId,
  813. false,
  814. true
  815. );
  816. if ($i % 2 == 0) {
  817. $css_class = "row_even";
  818. } else {
  819. $css_class = "row_odd";
  820. }
  821. $i++;
  822. // csv export content
  823. $csv_content[] = array (
  824. api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
  825. api_time_to_hms($total_time),
  826. $score . '%',
  827. $score_latest . '%',
  828. $progress.'%',
  829. $start_time
  830. );
  831. echo '<tr class="'.$css_class.'">';
  832. echo Display::tag('td', stripslashes($lp_name));
  833. echo Display::tag('td', api_time_to_hms($total_time));
  834. if (!is_null($score)) {
  835. if (is_numeric($score)) {
  836. $score = $score.'%';
  837. }
  838. }
  839. echo Display::tag('td', $score);
  840. if (!is_null($score_latest)) {
  841. if (is_numeric($score_latest)) {
  842. $score_latest = $score_latest.'%';
  843. }
  844. }
  845. echo Display::tag('td', $score_latest);
  846. if (is_numeric($progress)) {
  847. $progress = $progress.'%';
  848. } else {
  849. $progress = '-';
  850. }
  851. echo Display::tag('td', $progress);
  852. //Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
  853. //which implies several other changes not a priority right now
  854. echo Display::tag('td', $start_time);
  855. if ($any_result === true) {
  856. $from = '';
  857. if ($from_myspace) {
  858. $from ='&from=myspace';
  859. }
  860. $link = Display::url(
  861. Display::return_icon('2rightarrow.png', get_lang('Details')),
  862. 'lp_tracking.php?cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).$from.'&origin='.$origin.'&lp_id='.$learnpath->getId().'&student_id='.$user_info['user_id'].'&id_session='.$sessionId
  863. );
  864. echo Display::tag('td', $link);
  865. }
  866. if (api_is_allowed_to_edit()) {
  867. echo '<td>';
  868. if ($any_result === true) {
  869. echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.$origin.'&lp_id='.$learnpath->getId().'&student='.$user_info['user_id'].'&details=true&id_session='.$sessionId.'">';
  870. echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
  871. echo '</a>';
  872. }
  873. echo '</td>';
  874. echo '</tr>';
  875. }
  876. $data_learnpath[$i][] = $lp_name;
  877. $data_learnpath[$i][] = $progress . '%';
  878. }
  879. }
  880. ?>
  881. </tbody>
  882. </table>
  883. </div>
  884. <?php } ?>
  885. <!-- line about exercises -->
  886. <?php if ($user_info['status'] != INVITEE) { ?>
  887. <div class="table-responsive">
  888. <table class="table table-striped table-hover">
  889. <thead>
  890. <tr>
  891. <th><?php echo get_lang('Exercises'); ?></th>
  892. <th><?php echo get_lang('LearningPath');?></th>
  893. <th><?php echo get_lang('AvgCourseScore').' '.Display :: return_icon('info3.gif', get_lang('AverageScore'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
  894. <th><?php echo get_lang('Attempts'); ?></th>
  895. <th><?php echo get_lang('LatestAttempt'); ?></th>
  896. <th><?php echo get_lang('AllAttempts'); ?></th>
  897. </tr>
  898. </thead>
  899. <tbody>
  900. <?php
  901. $csv_content[] = array();
  902. $csv_content[] = array(
  903. get_lang('Exercises'),
  904. get_lang('LearningPath'),
  905. get_lang('AvgCourseScore'),
  906. get_lang('Attempts')
  907. );
  908. $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
  909. $sql = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
  910. WHERE
  911. quiz.c_id = ".$courseInfo['real_id']." AND
  912. (quiz.session_id = $sessionId OR quiz.session_id = 0) AND
  913. active IN (0, 1)
  914. ORDER BY quiz.title ASC ";
  915. $result_exercices = Database::query($sql);
  916. $i = 0;
  917. if (Database :: num_rows($result_exercices) > 0) {
  918. while ($exercices = Database :: fetch_array($result_exercices)) {
  919. $exercise_id = intval($exercices['id']);
  920. $count_attempts = Tracking::count_student_exercise_attempts(
  921. $student_id,
  922. $courseInfo['real_id'],
  923. $exercise_id,
  924. 0,
  925. 0,
  926. $sessionId,
  927. 2
  928. );
  929. $score_percentage = Tracking::get_avg_student_exercise_score(
  930. $student_id,
  931. $course_code,
  932. $exercise_id,
  933. $sessionId,
  934. 1,
  935. 0
  936. );
  937. if (!isset($score_percentage) && $count_attempts > 0) {
  938. $scores_lp = Tracking::get_avg_student_exercise_score(
  939. $student_id,
  940. $course_code,
  941. $exercise_id,
  942. $sessionId,
  943. 2,
  944. 1
  945. );
  946. $score_percentage = $scores_lp[0];
  947. $lp_name = $scores_lp[1];
  948. } else {
  949. $lp_name = '-';
  950. }
  951. $lp_name = !empty($lp_name) ? $lp_name : get_lang('NoLearnpath');
  952. if ($i % 2) {
  953. $css_class = 'row_odd';
  954. } else {
  955. $css_class = 'row_even';
  956. }
  957. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  958. echo '<td>';
  959. if (!empty($lp_name)) {
  960. echo $lp_name;
  961. } else {
  962. echo '-';
  963. }
  964. echo '</td>';
  965. echo '<td>';
  966. if ($count_attempts > 0) {
  967. echo $score_percentage . '%';
  968. } else {
  969. echo '-';
  970. $score_percentage = 0;
  971. }
  972. echo '</td>';
  973. echo '<td>'.$count_attempts.'</td>';
  974. echo '<td>';
  975. $sql = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
  976. WHERE
  977. exe_exo_id ="'.$exercise_id.'" AND
  978. exe_user_id ="'.$student_id.'" AND
  979. c_id = '.$courseInfo['real_id'].' AND
  980. session_id ="'.$sessionId.'" AND
  981. status = ""
  982. ORDER BY exe_date DESC
  983. LIMIT 1';
  984. $result_last_attempt = Database::query($sql);
  985. if (Database :: num_rows($result_last_attempt) > 0) {
  986. $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
  987. if ($count_attempts > 0)
  988. echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$sessionId.'&student='.$student_id.'&origin='.(empty($origin)?'tracking':$origin).'">
  989. '.Display::return_icon('quiz.gif').'
  990. </a>';
  991. }
  992. echo '</td>';
  993. echo '<td>';
  994. $all_attempt_url = "../exercice/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$sessionId";
  995. echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url );
  996. echo '</td></tr>';
  997. $data_exercices[$i][] = $exercices['title'];
  998. $data_exercices[$i][] = $score_percentage . '%';
  999. $data_exercices[$i][] = $count_attempts;
  1000. $csv_content[] = array(
  1001. $exercices['title'],
  1002. $lp_name,
  1003. $score_percentage,
  1004. $count_attempts
  1005. );
  1006. $i++;
  1007. }
  1008. } else {
  1009. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  1010. }
  1011. ?>
  1012. </tbody>
  1013. </table>
  1014. </div>
  1015. <?php
  1016. }
  1017. //@when using sessions we do not show the survey list
  1018. if (empty($sessionId)) {
  1019. $survey_list = SurveyManager::get_surveys($course_code, $sessionId);
  1020. $survey_data = array();
  1021. foreach($survey_list as $survey) {
  1022. $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $courseInfo['real_id']);
  1023. $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
  1024. if (in_array($student_id, $user_list)) {
  1025. $survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
  1026. }
  1027. $data = array('title' => $survey['title'], 'done' => $survey_done);
  1028. $survey_data[] = $data;
  1029. }
  1030. if (!empty($survey_list)) {
  1031. $table = new HTML_Table(array('class' => 'data_table'));
  1032. $header_names = array(get_lang('Survey'), get_lang('Answered'));
  1033. $row = 0;
  1034. $column = 0;
  1035. foreach ($header_names as $item) {
  1036. $table->setHeaderContents($row, $column, $item);
  1037. $column++;
  1038. }
  1039. $row = 1;
  1040. if (!empty($survey_data)) {
  1041. foreach ($survey_data as $data) {
  1042. $column = 0;
  1043. $table->setCellContents($row, $column, $data);
  1044. $class = 'class="row_odd"';
  1045. if($row % 2) {
  1046. $class = 'class="row_even"';
  1047. }
  1048. $table->setRowAttributes($row, $class, true);
  1049. $column++;
  1050. $row++;
  1051. }
  1052. }
  1053. echo $table->toHtml();
  1054. }
  1055. }
  1056. // line about other tools
  1057. ?>
  1058. <div class="table-responsive">
  1059. <table class="table table-striped table-hover">
  1060. <thead>
  1061. <tr>
  1062. <th colspan="2"><?php echo get_lang('OtherTools'); ?></th>
  1063. </tr>
  1064. </thead>
  1065. <tbody>
  1066. <?php
  1067. $csv_content[] = array ();
  1068. $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $sessionId);
  1069. $messages = Tracking::count_student_messages($student_id, $course_code, $sessionId);
  1070. $links = Tracking::count_student_visited_links($student_id, $courseInfo['real_id'], $sessionId);
  1071. $chat_last_connection = Tracking::chat_last_connection($student_id, $courseInfo['real_id'], $sessionId);
  1072. $documents = Tracking::count_student_downloaded_documents($student_id, $courseInfo['real_id'], $sessionId);
  1073. $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $sessionId);
  1074. $csv_content[] = array(
  1075. get_lang('OtherTools')
  1076. );
  1077. $csv_content[] = array(
  1078. get_lang('Student_publication'),
  1079. $nb_assignments
  1080. );
  1081. $csv_content[] = array(
  1082. get_lang('Messages'),
  1083. $messages
  1084. );
  1085. $csv_content[] = array(
  1086. get_lang('LinksDetails'),
  1087. $links
  1088. );
  1089. $csv_content[] = array(
  1090. get_lang('DocumentsDetails'),
  1091. $documents
  1092. );
  1093. $csv_content[] = array(
  1094. get_lang('UploadedDocuments'),
  1095. $uploaded_documents
  1096. );
  1097. $csv_content[] = array(
  1098. get_lang('ChatLastConnection'),
  1099. $chat_last_connection
  1100. );
  1101. ?>
  1102. <tr><!-- assignments -->
  1103. <td width="40%"><?php echo get_lang('Student_publication') ?></td>
  1104. <td><?php echo $nb_assignments ?></td>
  1105. </tr>
  1106. <tr><!-- messages -->
  1107. <td><?php echo get_lang('Forum').' - '.get_lang('NumberOfPostsForThisUser') ?></td>
  1108. <td><?php echo $messages ?></td>
  1109. </tr>
  1110. <tr><!-- links -->
  1111. <td><?php echo get_lang('LinksDetails') ?></td>
  1112. <td><?php echo $links ?></td>
  1113. </tr>
  1114. <tr><!-- downloaded documents -->
  1115. <td><?php echo get_lang('DocumentsDetails') ?></td>
  1116. <td><?php echo $documents ?></td>
  1117. </tr>
  1118. <tr><!-- uploaded documents -->
  1119. <td><?php echo get_lang('UploadedDocuments') ?></td>
  1120. <td><?php echo $uploaded_documents ?></td>
  1121. </tr>
  1122. <tr><!-- Chats -->
  1123. <td><?php echo get_lang('ChatLastConnection') ?></td>
  1124. <td><?php echo $chat_last_connection; ?></td>
  1125. </tr>
  1126. </tbody>
  1127. </table>
  1128. </div>
  1129. <?php
  1130. } //end details
  1131. }
  1132. if ($export) {
  1133. ob_end_clean();
  1134. switch ($export) {
  1135. case 'csv':
  1136. Export::arrayToCsv($csv_content, 'reporting_student');
  1137. break;
  1138. case 'xls':
  1139. Export::arrayToXls($csv_content, 'reporting_student');
  1140. break;
  1141. }
  1142. exit;
  1143. }
  1144. Display :: display_footer();