myStudents.php 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Implements the tracking of students in the Reporting pages
  5. * @package chamilo.mySpace
  6. */
  7. // name of the language file that needs to be included
  8. $language_file = array('registration', 'index', 'tracking', 'exercice', 'admin', 'gradebook');
  9. require '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
  11. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  13. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  14. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  15. require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
  16. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
  17. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
  18. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
  19. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
  20. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
  21. require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
  22. require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
  23. $htmlHeadXtra[] = '<script type="text/javascript">
  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_csv = isset ($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  31. if ($export_csv) {
  32. ob_start();
  33. }
  34. $csv_content = array ();
  35. $from_myspace = false;
  36. if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
  37. $from_myspace = true;
  38. $this_section = SECTION_TRACKING;
  39. } else {
  40. $this_section = SECTION_COURSES;
  41. }
  42. $nameTools = get_lang("StudentDetails");
  43. $cidReset = true;
  44. $get_course_code = Security :: remove_XSS($_GET['course']);
  45. if (isset ($_GET['details'])) {
  46. if (!empty ($_GET['origin']) && $_GET['origin'] == 'user_course') {
  47. $course_info = CourseManager :: get_course_information($get_course_code);
  48. if (empty ($cidReq)) {
  49. $interbreadcrumb[] = array (
  50. "url" => api_get_path(WEB_COURSE_PATH) . $course_info['directory'],
  51. 'name' => $course_info['title']
  52. );
  53. }
  54. $interbreadcrumb[] = array (
  55. "url" => "../user/user.php?cidReq=" . $get_course_code,
  56. "name" => get_lang("Users")
  57. );
  58. } else
  59. if (!empty ($_GET['origin']) && $_GET['origin'] == 'tracking_course') {
  60. $course_info = CourseManager :: get_course_information($get_course_code);
  61. if (empty ($cidReq)) {
  62. //$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['title']);
  63. }
  64. $interbreadcrumb[] = array (
  65. "url" => "../tracking/courseLog.php?cidReq=" . $get_course_code . '&studentlist=true&id_session=' . (empty ($_SESSION['id_session']) ? '' : $_SESSION['id_session']),
  66. "name" => get_lang("Tracking")
  67. );
  68. } else
  69. if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  70. $interbreadcrumb[] = array (
  71. 'url' => '../admin/index.php',
  72. "name" => get_lang('PlatformAdmin')
  73. );
  74. $interbreadcrumb[] = array (
  75. 'url' => "../admin/session_list.php",
  76. "name" => get_lang('SessionList')
  77. );
  78. $interbreadcrumb[] = array (
  79. 'url' => "../admin/resume_session.php?id_session=" . Security :: remove_XSS($_GET['id_session']),
  80. "name" => get_lang('SessionOverview')
  81. );
  82. } else {
  83. $interbreadcrumb[] = array (
  84. "url" => "index.php",
  85. "name" => get_lang('MySpace')
  86. );
  87. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  88. $interbreadcrumb[] = array (
  89. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  90. "name" => get_lang("CoachStudents")
  91. );
  92. $interbreadcrumb[] = array (
  93. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']) . '&id_coach=' . Security :: remove_XSS($_GET['id_coach']),
  94. "name" => get_lang("StudentDetails")
  95. );
  96. } else {
  97. $interbreadcrumb[] = array (
  98. "url" => "student.php",
  99. "name" => get_lang("MyStudents")
  100. );
  101. $interbreadcrumb[] = array (
  102. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
  103. "name" => get_lang("StudentDetails")
  104. );
  105. }
  106. }
  107. $nameTools = get_lang("DetailsStudentInCourse");
  108. } else {
  109. if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  110. $interbreadcrumb[] = array (
  111. 'url' => '../admin/index.php',
  112. "name" => get_lang('PlatformAdmin')
  113. );
  114. $interbreadcrumb[] = array (
  115. 'url' => "../admin/session_list.php",
  116. "name" => get_lang('SessionList')
  117. );
  118. $interbreadcrumb[] = array (
  119. 'url' => "../admin/resume_session.php?id_session=" . Security :: remove_XSS($_GET['id_session']),
  120. "name" => get_lang('SessionOverview')
  121. );
  122. } else {
  123. $interbreadcrumb[] = array (
  124. "url" => "index.php",
  125. "name" => get_lang('MySpace')
  126. );
  127. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  128. if (isset ($_GET['id_session']) && intval($_GET['id_session']) != 0) {
  129. $interbreadcrumb[] = array (
  130. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']) . "&id_session=" . $_GET['id_session'],
  131. "name" => get_lang("CoachStudents")
  132. );
  133. } else {
  134. $interbreadcrumb[] = array (
  135. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  136. "name" => get_lang("CoachStudents")
  137. );
  138. }
  139. } else {
  140. $interbreadcrumb[] = array (
  141. "url" => "student.php",
  142. "name" => get_lang("MyStudents")
  143. );
  144. }
  145. }
  146. }
  147. api_block_anonymous_users();
  148. if (!api_is_allowed_to_edit() && !api_is_coach() && !api_is_drh() && $_user['status'] != SESSIONADMIN && !api_is_platform_admin(true)) {
  149. api_not_allowed(true);
  150. }
  151. Display :: display_header($nameTools);
  152. /*
  153. * MAIN CODE
  154. */
  155. // Database Table Definitions
  156. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  157. $tbl_session_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
  158. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  159. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  160. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  161. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  162. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  163. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  164. $tbl_stats_exercices_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  165. $tbl_course_lp_view = 'lp_view';
  166. $tbl_course_lp_view_item = 'lp_item_view';
  167. $tbl_course_lp_item = 'lp_item';
  168. $tbl_course_lp = 'lp';
  169. $tbl_course_quiz = 'quiz';
  170. $course_quiz_question = 'quiz_question';
  171. $course_quiz_rel_question = 'quiz_rel_question';
  172. $course_quiz_answer = 'quiz_answer';
  173. $course_student_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
  174. if (isset($_GET['user_id']) && $_GET['user_id'] != "") {
  175. $user_id = intval($_GET['user_id']);
  176. } else {
  177. $user_id = $_user['user_id'];
  178. }
  179. $session_id = intval($_GET['id_session']);
  180. if (!empty ($_GET['student'])) {
  181. $student_id = intval($_GET['student']);
  182. // infos about user
  183. $info_user = UserManager :: get_user_info_by_id($student_id);
  184. if (api_is_drh() && !UserManager::is_user_followed_by_drh($student_id, $_user['user_id'])) {
  185. api_not_allowed();
  186. }
  187. $info_user['name'] = api_get_person_name($info_user['firstname'], $info_user['lastname']);
  188. // Actions bar
  189. echo '<div class="actions">';
  190. echo '<a href="javascript: void(0);" onclick="javascript: window.print();"><img src="../img/printmgr.gif">&nbsp;' . get_lang('Print') . '</a>';
  191. echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv"><img src="../img/excel.gif">&nbsp;' . get_lang('ExportAsCSV') . '</a>';
  192. if (!empty ($info_user['email'])) {
  193. $send_mail = Display :: return_icon('send_mail.gif', get_lang('SendMail')) . ' ' . Display :: encrypted_mailto_link($info_user['email'], get_lang('SendMail'));
  194. } else {
  195. $send_mail = Display :: return_icon('send_mail.gif', get_lang('SendMail')) . ' ' . get_lang('SendMail');
  196. }
  197. echo $send_mail;
  198. if (!empty ($_GET['student']) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL
  199. echo '<a href="access_details.php?student=' . Security :: remove_XSS($_GET['student']) . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq='.Security::remove_XSS($_GET['course']).'&amp;id_session='.$session_id.'">' . Display :: return_icon('statistics.gif', get_lang('AccessDetails')) . ' ' . get_lang('AccessDetails') . '</a>';
  200. }
  201. echo '</div>';
  202. // is the user online ?
  203. $student_online = Security :: remove_XSS($_GET['student']);
  204. $users_online = who_is_online(30);
  205. foreach ($users_online as $online) {
  206. if (in_array($_GET['student'], $online)) {
  207. $online = get_lang('Yes');
  208. break;
  209. } else {
  210. $online = get_lang('No');
  211. }
  212. }
  213. // get average of score and average of progress by student
  214. $avg_student_progress = $avg_student_score = $nb_courses = 0;
  215. $course_id = Security :: remove_XSS($_GET['course']);
  216. if (!CourseManager :: is_user_subscribed_in_course($info_user['user_id'], $course_id, true)) {
  217. unset ($courses[$key]);
  218. } else {
  219. $nb_courses++;
  220. $avg_student_progress = Tracking::get_avg_student_progress($info_user['user_id'], $course_id, array(), $session_id);
  221. //the score inside the Reporting table
  222. $avg_student_score = Tracking::get_avg_student_score($info_user['user_id'], $course_id, array(), $session_id);
  223. }
  224. $avg_student_progress = round($avg_student_progress, 2);
  225. $avg_student_score = round($avg_student_score, 2);
  226. // time spent on the course
  227. $time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_id, $session_id));
  228. // get information about connections on the platform by student
  229. $first_connection_date = Tracking :: get_first_connection_date($info_user['user_id']);
  230. if ($first_connection_date == '') {
  231. $first_connection_date = get_lang('NoConnexion');
  232. }
  233. $last_connection_date = Tracking :: get_last_connection_date($info_user['user_id'], true);
  234. if ($last_connection_date == '') {
  235. $last_connection_date = get_lang('NoConnexion');
  236. }
  237. // cvs informations
  238. $csv_content[] = array (
  239. get_lang('Informations', '')
  240. );
  241. $csv_content[] = array (
  242. get_lang('Name', ''),
  243. get_lang('Email', ''),
  244. get_lang('Tel', '')
  245. );
  246. $csv_content[] = array (
  247. $info_user['name'],
  248. $info_user['email'],
  249. $info_user['phone']
  250. );
  251. $csv_content[] = array ();
  252. // csv tracking
  253. $csv_content[] = array (
  254. get_lang('Tracking', '')
  255. );
  256. $csv_content[] = array (
  257. get_lang('FirstLogin', ''),
  258. get_lang('LatestLogin', ''),
  259. get_lang('TimeSpentInTheCourse', ''),
  260. get_lang('Progress', ''),
  261. get_lang('Score', '')
  262. );
  263. $csv_content[] = array (
  264. strip_tags($first_connection_date),
  265. strip_tags($last_connection_date),
  266. $time_spent_on_the_course,
  267. $avg_student_progress . '%',
  268. $avg_student_score . '%'
  269. );
  270. ?>
  271. <a name="infosStudent"></a>
  272. <table width="100%" border="0" >
  273. <tr>
  274. <?php
  275. $image_array = UserManager :: get_user_picture_path_by_id($info_user['user_id'], 'web', false, true);
  276. echo '<td class="borderRight" width="10%" valign="top">';
  277. // get the path,width and height from original picture
  278. $image_file = $image_array['dir'] . $image_array['file'];
  279. $big_image = $image_array['dir'] . 'big_' . $image_array['file'];
  280. $big_image_size = api_getimagesize($big_image);
  281. $big_image_width = $big_image_size[0];
  282. $big_image_height = $big_image_size[1];
  283. $url_big_image = $big_image . '?rnd=' . time();
  284. $img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' .
  285. 'alt="' . api_get_person_name($info_user['lastname'], $info_user['firstname']) . '" ' .
  286. 'style="float:' . ($text_dir == 'rtl' ? 'left' : 'right') . '; padding:5px;" ';
  287. if ($image_array['file'] == 'unknown.jpg') {
  288. echo '<img ' . $img_attributes . ' />';
  289. } else {
  290. echo '<input type="image" ' . $img_attributes . ' onclick="javascript: return show_image(\'' . $url_big_image . '\',\'' . $big_image_width . '\',\'' . $big_image_height . '\');"/>';
  291. }
  292. echo '</td>';
  293. ?>
  294. <td width="40%" valign="top">
  295. <table width="100%" class="data_table">
  296. <tr>
  297. <th><?php echo get_lang('Information'); ?></th>
  298. </tr>
  299. <tr>
  300. <td>
  301. <?php
  302. echo get_lang('Name') . ' : ';
  303. echo $info_user['name'];
  304. ?>
  305. </td>
  306. </tr>
  307. <tr>
  308. <td>
  309. <?php
  310. echo get_lang('Email') . ' : ';
  311. if (!empty ($info_user['email'])) {
  312. echo '<a href="mailto:' . $info_user['email'] . '">' . $info_user['email'] . '</a>';
  313. } else {
  314. echo get_lang('NoEmail');
  315. }
  316. ?>
  317. </td>
  318. </tr>
  319. <tr>
  320. <td>
  321. <?php
  322. echo get_lang('Tel') . ' : ';
  323. if (!empty ($info_user['phone'])) {
  324. echo $info_user['phone'];
  325. } else {
  326. echo get_lang('NoTel');
  327. }
  328. ?>
  329. </td>
  330. </tr>
  331. <tr>
  332. <td>
  333. <?php
  334. echo get_lang('OfficialCode') . ' : ';
  335. if (!empty ($info_user['official_code'])) {
  336. echo $info_user['official_code'];
  337. } else {
  338. echo get_lang('NoOfficialCode');
  339. }
  340. ?>
  341. </td>
  342. </tr>
  343. <tr>
  344. <td>
  345. <?php
  346. echo get_lang('OnLine') . ' : ';
  347. echo $online;
  348. ?>
  349. </td>
  350. </tr>
  351. <?php
  352. // Display timezone if the user selected one and if the admin allows the use of user's timezone
  353. $timezone = null;
  354. $timezone_user = UserManager::get_extra_user_data_by_field($info_user['user_id'],'timezone');
  355. $use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
  356. if ($timezone_user['timezone'] != null && $use_users_timezone == 'true') {
  357. $timezone = $timezone_user['timezone'];
  358. }
  359. if ($timezone !== null) {
  360. ?>
  361. <tr>
  362. <td>
  363. <?php
  364. echo get_lang('Timezone') . ' : ';
  365. echo $timezone;
  366. ?>
  367. </td>
  368. </tr>
  369. <?php
  370. }
  371. ?>
  372. </table>
  373. </td>
  374. <td class="borderLeft" width="35%" valign="top">
  375. <table width="100%" class="data_table">
  376. <tr>
  377. <th colspan="2"><?php echo get_lang('Tracking'); ?></th>
  378. </tr>
  379. <tr><td align="right"><?php echo get_lang('FirstLogin') ?></td>
  380. <td align="left"><?php echo $first_connection_date ?></td>
  381. </tr>
  382. <tr>
  383. <td align="right"><?php echo get_lang('LatestLogin') ?></td>
  384. <td align="left"><?php echo $last_connection_date ?></td>
  385. </tr>
  386. <?php if (isset($_GET['details']) && $_GET['details'] == 'true') {?>
  387. <tr>
  388. <td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
  389. <td align="left"><?php echo $time_spent_on_the_course ?></td>
  390. </tr>
  391. <tr>
  392. <td align="right">
  393. <?php
  394. echo get_lang('Progress');
  395. Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));
  396. ?>
  397. </td>
  398. <td align="left"><?php echo $avg_student_progress.'%' ?></td>
  399. </tr>
  400. <tr>
  401. <td align="right">
  402. <?php
  403. echo get_lang('Score');
  404. Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));
  405. ?>
  406. </td>
  407. <td align="left"><?php echo $avg_student_score.'%' ?></td>
  408. </tr>
  409. <?php } ?>
  410. </table>
  411. </td>
  412. </tr>
  413. </table>
  414. <?php
  415. if (!empty ($_GET['details'])) { ?>
  416. <table class="data_table">
  417. <tr>
  418. <td colspan="5" style="border-width: 0px;">&nbsp;</td>
  419. </tr>
  420. <?php
  421. $course_code = $_GET['course'];
  422. $info_course = CourseManager :: get_course_information($course_code);
  423. $coachs_name = '';
  424. $session_name = '';
  425. $nb_login = Tracking :: count_login_per_student($info_user['user_id'], $_GET['course']);
  426. //get coach and session_name if there is one and if session_mode is activated
  427. if (api_get_setting('use_session_mode') == 'true' && $session_id > 0) {
  428. $session_info = api_get_session_info($session_id);
  429. $course_coachs = api_get_coachs_from_course($session_id,$course_code);
  430. $nb_login = '';
  431. if (!empty($course_coachs)) {
  432. $info_tutor_name = array();
  433. foreach ($course_coachs as $course_coach) {
  434. $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
  435. }
  436. $info_course['tutor_name'] = implode(",",$info_tutor_name);
  437. } elseif ($session_coach_id != 0) {
  438. $session_coach_id = intval($session_info['id_coach']);
  439. $coach_info = UserManager::get_user_info_by_id($session_coach_id);
  440. $info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
  441. }
  442. $coachs_name = $info_course['tutor_name'];
  443. $session_name = $session_info['name'];
  444. } // end if(api_get_setting('use_session_mode')=='true')
  445. $table_title = $info_course['title'].($nb_login?'&nbsp;|&nbsp;'.get_lang('CountToolAccess').' : '.$nb_login:'').($session_name?'&nbsp;|&nbsp;'.get_lang('Session').' : '.ucfirst($session_name):'').($coachs_name?'&nbsp;|&nbsp;'.get_lang('Tutor').' : '.stripslashes($coachs_name):'');
  446. $csv_content[] = array ();
  447. $csv_content[] = array (str_replace('&nbsp;', '', $table_title));
  448. ?>
  449. <tr>
  450. <td colspan="6">
  451. <strong><?php echo $table_title; ?></strong>
  452. </td>
  453. </tr>
  454. </table>
  455. <!-- line about learnpaths -->
  456. <table class="data_table">
  457. <tr>
  458. <th>
  459. <?php echo get_lang('Learnpaths');?>
  460. </th>
  461. <th>
  462. <?php
  463. echo get_lang('Time');
  464. Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array (
  465. 'align' => 'absmiddle',
  466. 'hspace' => '3px'
  467. ));
  468. ?>
  469. </th>
  470. <th>
  471. <?php
  472. echo get_lang('Score');
  473. Display :: display_icon('info3.gif', get_lang('LPTestScore'), array (
  474. 'align' => 'absmiddle',
  475. 'hspace' => '3px'
  476. ));
  477. ?>
  478. </th>
  479. <th>
  480. <?php
  481. echo get_lang('Progress');
  482. Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array (
  483. 'align' => 'absmiddle',
  484. 'hspace' => '3px'
  485. ));
  486. ?>
  487. </th>
  488. <th>
  489. <?php
  490. echo get_lang('LastConnexion');
  491. Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array (
  492. 'align' => 'absmiddle',
  493. 'hspace' => '3px'
  494. ));
  495. ?>
  496. </th>
  497. <th>
  498. <?php echo get_lang('Details');?>
  499. </th>
  500. </tr>
  501. <?php
  502. $headerLearnpath = array (
  503. get_lang('Learnpath'),
  504. get_lang('Time'),
  505. get_lang('Progress'),
  506. get_lang('LastConnexion')
  507. );
  508. $t_lp = Database :: get_course_table(TABLE_LP_MAIN, $info_course['db_name']);
  509. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  510. $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION, $info_course['db_name']);
  511. // csv export headers
  512. $csv_content[] = array ();
  513. $csv_content[] = array (
  514. get_lang('Learnpath', ''),
  515. get_lang('Time', ''),
  516. get_lang('Score', ''),
  517. get_lang('Progress', ''),
  518. get_lang('LastConnexion', '')
  519. );
  520. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE lp.session_id = $session_id ORDER BY lp.name ASC";
  521. $rs_lp = Database::query($sql_lp);
  522. if (Database :: num_rows($rs_lp) > 0) {
  523. $i = 0;
  524. while ($learnpath = Database :: fetch_array($rs_lp)) {
  525. $lp_id = intval($learnpath['id']);
  526. $lp_name = $learnpath['name'];
  527. $any_result = false;
  528. // Get progress in lp
  529. $progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id));
  530. if ($progress === null) $progress = '0%';
  531. else $any_result = true;
  532. // Get time in lp
  533. $total_time = Tracking::get_time_spent_in_lp($student_id, $course_code, array($lp_id));
  534. if (!empty($total_time)) $any_result = true;
  535. // Get last connection time in lp
  536. $start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id);
  537. if (!empty($total_time)) $any_result = true;
  538. // Quizz in lp
  539. $score = Tracking :: get_avg_student_score($student_id, $course_code, array($lp_id));
  540. if ($i % 2 == 0) $css_class = "row_odd";
  541. else $css_class = "row_even";
  542. $i++;
  543. // csv export content
  544. $csv_content[] = array (
  545. api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
  546. api_time_to_hms($total_time),
  547. $score . '%',
  548. $progress,
  549. api_convert_and_format_date($start_time, "%Y-%m-%d")
  550. );
  551. ?>
  552. <tr class="<?php echo $css_class;?>">
  553. <td>
  554. <?php echo stripslashes($lp_name); ?>
  555. </td>
  556. <td align="center">
  557. <?php echo api_time_to_hms($total_time) ?>
  558. </td>
  559. <td align="center">
  560. <?php
  561. if (!is_null($score)) {
  562. echo $score . '%';
  563. } else {
  564. if ('0' == $progress {
  565. 0 }) {
  566. echo '/';
  567. } else {
  568. echo '0%';
  569. }
  570. $score = 0;
  571. }
  572. ?>
  573. </td>
  574. <td align="center">
  575. <?php echo $progress ?>
  576. </td>
  577. <td align="center">
  578. <?php
  579. if ($start_time != '' && $start_time > 0) {
  580. echo api_convert_and_format_date($start_time, DATE_FORMAT_SHORT);
  581. } else {
  582. echo '-';
  583. }
  584. ?>
  585. </td>
  586. <td align="center">
  587. <?php
  588. if ($any_result === true) {
  589. $from = '';
  590. if ($from_myspace) {
  591. $from ='&from=myspace';
  592. }
  593. ?>
  594. <a href="lp_tracking.php?course=<?php echo Security::remove_XSS($_GET['course']).$from; ?>&origin=<?php echo Security::remove_XSS($_GET['origin']) ?>&lp_id=<?php echo $learnpath['id']?>&student_id=<?php echo $info_user['user_id'] ?>&session_id=<?php echo $session_id ?>">
  595. <img src="../img/2rightarrow.gif" border="0" />
  596. </a>
  597. <?php
  598. }
  599. ?>
  600. </td>
  601. </tr>
  602. <?php
  603. $data_learnpath[$i][] = $lp_name;
  604. $data_learnpath[$i][] = $progress . '%';
  605. $i++;
  606. }
  607. } else {
  608. echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
  609. }
  610. ?>
  611. </table>
  612. <!-- line about exercises -->
  613. <table class="data_table">
  614. <tr>
  615. <th><?php echo get_lang('Exercices'); ?></th>
  616. <th><?php echo get_lang('Score').Display :: return_icon('info3.gif', get_lang('LastScoreTest'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
  617. <th><?php echo get_lang('Attempts'); ?></th>
  618. <th><?php echo get_lang('CorrectTest'); ?></th>
  619. </tr>
  620. <?php
  621. $csv_content[] = array ();
  622. $csv_content[] = array (
  623. get_lang('Exercices'),
  624. get_lang('Score'),
  625. get_lang('Attempts')
  626. );
  627. $t_tool = Database :: get_course_table(TABLE_TOOL_LIST, $info_course['db_name']);
  628. $sql = 'SELECT visibility FROM ' . $t_tool . ' WHERE name="quiz"';
  629. $result_visibility_quizz = Database::query($sql);
  630. $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST, $info_course['db_name']);
  631. if (Database :: result($result_visibility_quizz, 0, 'visibility') == 1) {
  632. $sql_exercices = "SELECT quiz.title,id
  633. FROM " . $t_quiz . " AS quiz
  634. WHERE active='1' AND quiz.session_id = $session_id ORDER BY quiz.title ASC
  635. ";
  636. $result_exercices = Database::query($sql_exercices);
  637. $i = 0;
  638. if (Database :: num_rows($result_exercices) > 0) {
  639. while ($exercices = Database :: fetch_array($result_exercices)) {
  640. $exercise_id = intval($exercices['id']);
  641. $count_attempts = Tracking::count_student_exercise_attempts($student_id, $course_code, $exercise_id);
  642. $score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id);
  643. $csv_content[] = array (
  644. $exercices['title'],
  645. $score_percentage . '%',
  646. $count_attempts
  647. );
  648. if ($i % 2 == 0) $css_class = 'row_odd';
  649. else $css_class = 'row_even';
  650. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  651. echo '<td align="center">';
  652. if ($count_attempts > 0) {
  653. echo $score_percentage . '%';
  654. } else {
  655. echo '/';
  656. $score_percentage = 0;
  657. }
  658. echo '</td>';
  659. echo '<td align="center">'.$count_attempts.'</td>';
  660. echo '<td align="center">';
  661. $sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="'.$exercise_id.'" AND exe_user_id="'.$student_id.'" AND exe_cours_id="'.$course_code.'" AND orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY exe_date DESC LIMIT 1';
  662. $result_last_attempt = Database::query($sql_last_attempt);
  663. if (Database :: num_rows($result_last_attempt) > 0) {
  664. $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
  665. if ($count_attempts > 0)
  666. echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&student='.$student_id.'&origin='.(empty($_GET['origin'])?'tracking':Security::remove_XSS($_GET['origin'])).'"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
  667. }
  668. echo '</td></tr>';
  669. $data_exercices[$i][] = $exercices['title'];
  670. $data_exercices[$i][] = $score_percentage . '%';
  671. $data_exercices[$i][] = $count_attempts;
  672. $i++;
  673. }
  674. } else {
  675. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  676. }
  677. } else {
  678. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  679. }
  680. ?>
  681. </table>
  682. <!-- line about other tools -->
  683. <table class="data_table">
  684. <tr>
  685. <td>
  686. <?php
  687. $csv_content[] = array ();
  688. $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $session_id);
  689. $messages = Tracking::count_student_messages($student_id, $course_code, $session_id);
  690. $links = Tracking::count_student_visited_links($student_id, $course_code, $session_id);
  691. $chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
  692. $documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
  693. $csv_content[] = array (
  694. get_lang('Student_publication'),
  695. $nb_assignments
  696. );
  697. $csv_content[] = array (
  698. get_lang('Messages'),
  699. $messages
  700. );
  701. $csv_content[] = array (
  702. get_lang('LinksDetails'),
  703. $links
  704. );
  705. $csv_content[] = array (
  706. get_lang('DocumentsDetails'),
  707. $documents
  708. );
  709. $csv_content[] = array (
  710. get_lang('ChatLastConnection'),
  711. $chat_last_connection
  712. );
  713. ?>
  714. <tr>
  715. <th colspan="2">
  716. <?php echo get_lang('OtherTools'); ?>
  717. </th>
  718. </tr>
  719. <tr><!-- assignments -->
  720. <td width="40%">
  721. <?php echo get_lang('Student_publication') ?>
  722. </td>
  723. <td>
  724. <?php echo $nb_assignments ?>
  725. </td>
  726. </tr>
  727. <tr><!-- messages -->
  728. <td>
  729. <?php echo get_lang('Messages') ?>
  730. </td>
  731. <td>
  732. <?php echo $messages ?>
  733. </td>
  734. </tr>
  735. <tr><!-- links -->
  736. <td>
  737. <?php echo get_lang('LinksDetails') ?>
  738. </td>
  739. <td>
  740. <?php echo $links ?>
  741. </td>
  742. </tr>
  743. <tr><!-- documents -->
  744. <td>
  745. <?php echo get_lang('DocumentsDetails') ?>
  746. </td>
  747. <td>
  748. <?php echo $documents ?>
  749. </td>
  750. </tr>
  751. <tr><!-- Chats -->
  752. <td>
  753. <?php echo get_lang('ChatLastConnection') ?>
  754. </td>
  755. <td>
  756. <?php echo $chat_last_connection; ?>
  757. </td>
  758. </tr>
  759. </table>
  760. </td>
  761. </tr>
  762. </table>
  763. </table>
  764. <br />
  765. <?php
  766. } else {
  767. $courses_in_session = array ();
  768. if (!api_is_platform_admin(true) && $_user['status'] != DRH) {
  769. // courses followed by user where we are coach
  770. if (!isset ($_GET['id_coach'])) {
  771. $sessions_coached_by_user = Tracking::get_sessions_coached_by_user($_user['user_id']);
  772. foreach ($sessions_coached_by_user as $session_coached_by_user) {
  773. $sid = intval($session_coached_by_user['id']);
  774. $courses_followed_by_coach = Tracking :: get_courses_followed_by_coach($_user['user_id'], $sid);
  775. $courses_in_session[$sid] = $courses_followed_by_coach;
  776. }
  777. } else {
  778. $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(intval($_GET['id_coach']));
  779. foreach ($sessions_coached_by_user as $session_coached_by_user) {
  780. $sid = intval($session_coached_by_user['id']);
  781. $courses_followed_by_coach = Tracking :: get_courses_followed_by_coach(intval($_GET['id_coach']), $sid);
  782. $courses_in_session[$sid] = $courses_followed_by_coach;
  783. }
  784. }
  785. } else {
  786. $sql = 'SELECT course_code FROM ' . $tbl_course_user . ' WHERE relation_type<>'.COURSE_RELATION_TYPE_RRHH.' AND user_id=' . Database :: escape_string($info_user['user_id']);
  787. $rs = Database::query($sql);
  788. while ($row = Database :: fetch_array($rs)) {
  789. $courses_in_session[0][] = $row['course_code'];
  790. }
  791. // get the list of sessions where the user is subscribed as student
  792. $sql = 'SELECT id_session, course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($info_user['user_id']);
  793. $rs = Database::query($sql);
  794. $tmp_sessions = array();
  795. while ($row = Database :: fetch_array($rs)) {
  796. $tmp_sessions[] = $row['id_session'];
  797. if (in_array($row['id_session'],$tmp_sessions)) {
  798. $courses_in_session[$row['id_session']][] = $row['course_code'];
  799. }
  800. }
  801. }
  802. $csv_content[] = array ();
  803. $csv_content[] = array (
  804. get_lang('Session', ''),
  805. get_lang('Course', ''),
  806. get_lang('Time', ''),
  807. get_lang('Progress', ''),
  808. get_lang('Score', ''),
  809. get_lang('AttendancesFaults', ''),
  810. get_lang('Evaluations')
  811. );
  812. $attendance = new Attendance();
  813. foreach ($courses_in_session as $key => $courses) {
  814. $session_id = $key;
  815. $session_info = api_get_session_info($session_id);
  816. $session_name = $session_info['name'];
  817. $date_start = '';
  818. if (!empty ($session_info['date_start'])) {
  819. $date_start = explode('-', $session_info['date_start']);
  820. $date_start = $date_start[2] . '/' . $date_start[1] . '/' . $date_start[0];
  821. }
  822. $date_end = '';
  823. if (!empty ($session_info['date_end'])) {
  824. $date_end = explode('-', $session_info['date_end']);
  825. $date_end = $date_end[2] . '/' . $date_end[1] . '/' . $date_end[0];
  826. }
  827. $date_session = get_lang('From') . ' ' . $date_start . ' ' . get_lang('To') . ' ' . $date_end;
  828. $title = '';
  829. if (empty($session_id)) {
  830. $title = get_lang('TrainingsWithoutSessions');
  831. } else {
  832. $title = ucfirst($session_name).($date_session?' ('.$date_session.')':'');
  833. }
  834. // courses
  835. echo '<h4>'.$title.'</h4>';
  836. echo '<table class="data_table">';
  837. echo '<tr>
  838. <th>'.get_lang('Course').'</th>
  839. <th>'.get_lang('Time').'</th>
  840. <th>'.get_lang('Progress').'</th>
  841. <th>'.get_lang('Score').'</th>
  842. <th>'.get_lang('AttendancesFaults').'</th>
  843. <th>'.get_lang('Evaluations').'</th>
  844. <th>'.get_lang('Details').'</th>
  845. </tr>';
  846. if (!empty($courses)) {
  847. foreach ($courses as $course_code) {
  848. if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
  849. $course_info = CourseManager :: get_course_information($course_code);
  850. $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_code, $session_id));
  851. // get average of faults in attendances by student
  852. $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $session_id);
  853. if (!empty($results_faults_avg['total'])) {
  854. if (api_is_drh()) {
  855. $attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  856. } else {
  857. $attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
  858. }
  859. } else {
  860. $attendances_faults_avg = '0/0 (0%)';
  861. }
  862. // get evaluatios by student
  863. $cats = Category::load(null, null, $course_code, null, null, $session_id);
  864. $scoretotal = array();
  865. if (isset($cats)) {
  866. if (!empty($session_id)) {
  867. $scoretotal= $cats[0]->calc_score($student_id, $course_code, $session_id);
  868. } else {
  869. $scoretotal= $cats[0]->calc_score($student_id, $course_code);
  870. }
  871. }
  872. $scoretotal_display = '0/0 (0%)';
  873. if (!empty($scoretotal)) {
  874. /*
  875. if (api_is_drh()) {
  876. $session_param = !empty($session_id)?'&id_session='.$session_id:'';
  877. $scoretotal_display = '<a title="'.get_lang('GoAssessments').'" href="'.api_get_path(WEB_CODE_PATH).'gradebook/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)</a>';
  878. } else {
  879. $scoretotal_display = round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
  880. }
  881. */
  882. $scoretotal_display = round($scoretotal[0],2).'/'.round($scoretotal[1],2).'('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
  883. }
  884. $progress = Tracking::get_avg_student_progress($info_user['user_id'], $course_code, null, $session_id);
  885. $score = Tracking :: get_avg_student_score($info_user['user_id'], $course_code, null, $session_id);
  886. $progress = empty($progress) ? '0%' : $progress.'%';
  887. $score = empty($score) ? '0%' : $score.'%';
  888. $csv_content[] = array (
  889. $session_name,
  890. $course_info['title'],
  891. $time_spent_on_course,
  892. $progress,
  893. $score,
  894. $attendances_faults_avg,
  895. $scoretotal_display
  896. );
  897. echo '
  898. <tr>
  899. <td align="right">'.$course_info['title'].'</td>
  900. <td align="right">'.$time_spent_on_course .'</td>
  901. <td align="right">'.$progress.'</td>
  902. <td align="right">'.$score.'</td>
  903. <td align="right">'.$attendances_faults_avg.'</td>
  904. <td align="right">'.$scoretotal_display.'</td>';
  905. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  906. echo '<td align="center" width="10"><a href="'.api_get_self().'?student='.$info_user['user_id'].'&details=true&course='.$course_info['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
  907. } else {
  908. echo '<td align="center" width="10"><a href="'.api_get_self().'?student='.$info_user['user_id'].'&details=true&course='.$course_info['code'].'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
  909. }
  910. echo '</tr>';
  911. }
  912. }
  913. } else {
  914. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  915. }
  916. echo '</table>';
  917. }
  918. } //end of else !empty($details)
  919. ?>
  920. <?php
  921. if (!empty ($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course') {
  922. ?>
  923. <br /><br />
  924. <?php
  925. }
  926. if (!empty ($_GET['exe_id'])) {
  927. $t_q = Database :: get_course_table(TABLE_QUIZ_TEST, $info_course['db_name']);
  928. $t_qq = Database :: get_course_table(TABLE_QUIZ_QUESTION, $info_course['db_name']);
  929. $t_qa = Database :: get_course_table(TABLE_QUIZ_ANSWER, $info_course['db_name']);
  930. $t_qtq = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION, $info_course['db_name']);
  931. $sql_exercice_details = "SELECT qq.question, qq.ponderation, qq.id
  932. FROM " . $t_qq . " as qq
  933. INNER JOIN " . $t_qtq . " as qrq
  934. ON qrq.question_id = qq.id
  935. AND qrq.exercice_id = " . intval($_GET['exe_id']);
  936. $result_exercice_details = Database::query($sql_exercice_details);
  937. $sql_ex_name = "SELECT quiz.title
  938. FROM " . $t_q . " AS quiz
  939. WHERE quiz.id = " . intval($_GET['exe_id']);
  940. ;
  941. $resultExName = Database::query($sql_ex_name);
  942. $exName = Database :: fetch_array($resultExName);
  943. echo "<table class='data_table'>
  944. <tr>
  945. <th colspan='2'>
  946. " . $exName['title'] . "
  947. </th>
  948. </tr>
  949. ";
  950. while ($exerciceDetails = Database :: fetch_array($result_exercice_details)) {
  951. $sqlAnswer = " SELECT qa.comment, qa.answer
  952. FROM " . $t_qa . " as qa
  953. WHERE qa.question_id = " . $exerciceDetails['id'];
  954. $resultAnswer = Database::query($sqlAnswer);
  955. echo "<a name='infosExe'></a>";
  956. echo "
  957. <tr>
  958. <td colspan='2'>
  959. <strong>" . $exerciceDetails['question'] . ' /' . $exerciceDetails['ponderation'] . "</strong>
  960. </td>
  961. </tr>
  962. ";
  963. while ($answer = Database :: fetch_array($resultAnswer)) {
  964. echo "
  965. <tr>
  966. <td>
  967. " . $answer['answer'] . "
  968. </td>
  969. <td>
  970. ";
  971. if (!empty ($answer['comment']))
  972. echo $answer['comment'];
  973. else
  974. echo get_lang('NoComment');
  975. echo "
  976. </td>
  977. </tr>
  978. ";
  979. }
  980. }
  981. echo "</table>";
  982. }
  983. //YW - commented out because it doesn't seem to be used
  984. //$header = array_merge($headerLearnpath,$headerExercices,$headerProductions);
  985. }
  986. if ($export_csv) {
  987. ob_end_clean();
  988. Export :: export_table_csv($csv_content, 'reporting_student');
  989. exit;
  990. }
  991. /*
  992. ==============================================================================
  993. FOOTER
  994. ==============================================================================
  995. */
  996. Display :: display_footer();