myStudents.php 37 KB

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