myStudents.php 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  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', 'survey');
  9. require_once '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  11. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  12. require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
  13. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
  14. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
  15. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
  16. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
  17. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
  18. require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
  19. require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php';
  20. api_block_anonymous_users();
  21. if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) {
  22. api_not_allowed(true);
  23. }
  24. $htmlHeadXtra[] = '<script>
  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 = SECTION_TRACKING;
  40. } else {
  41. $this_section = SECTION_COURSES;
  42. }
  43. $nameTools = get_lang('StudentDetails');
  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. // Database Table Definitions
  148. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  149. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  150. if (isset($_GET['user_id']) && $_GET['user_id'] != "") {
  151. $user_id = intval($_GET['user_id']);
  152. } else {
  153. $user_id = api_get_user_id();
  154. }
  155. $session_id = intval($_GET['id_session']);
  156. if (empty($session_id)) {
  157. $session_id = api_get_session_id();
  158. }
  159. $student_id = intval($_GET['student']);
  160. // Action behaviour
  161. $check= Security::check_token('get');
  162. if ($check) {
  163. switch ($_GET['action']) {
  164. case 'reset_lp' :
  165. $course = isset($_GET['course']) ? $_GET['course']:"";
  166. $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']):"";
  167. if (api_is_allowed_to_edit() && !empty($course) && !empty($lp_id) && !empty($student_id)) {
  168. $course_info = api_get_course_info($course);
  169. delete_student_lp_events($student_id, $lp_id, $course_info, $session_id);
  170. //@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334
  171. $message = Display::return_message(get_lang('LPWasReset'),'success');
  172. }
  173. break;
  174. default:
  175. break;
  176. }
  177. Security::clear_token();
  178. }
  179. // infos about user
  180. $user_info = api_get_user_info($student_id);
  181. $courses_in_session = array();
  182. //See #4676
  183. $drh_can_access_all_courses = false;
  184. if (api_is_drh()) {
  185. $drh_can_access_all_courses = true;
  186. }
  187. $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
  188. $courses_in_session_by_coach = array();
  189. $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
  190. //RRHH or session admin
  191. if (api_is_session_admin() || api_is_drh()) {
  192. $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
  193. $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
  194. if (!empty($session_by_session_admin)) {
  195. foreach ($session_by_session_admin as $session_coached_by_user) {
  196. $courses_followed_by_coach = Tracking :: get_courses_list_from_session($session_coached_by_user['id']);
  197. $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
  198. }
  199. }
  200. }
  201. // Teacher or admin
  202. if (!empty($sessions_coached_by_user)) {
  203. foreach ($sessions_coached_by_user as $session_coached_by_user) {
  204. $sid = intval($session_coached_by_user['id']);
  205. $courses_followed_by_coach = Tracking :: get_courses_followed_by_coach(api_get_user_id(), $sid);
  206. $courses_in_session_by_coach[$sid] = $courses_followed_by_coach;
  207. }
  208. }
  209. $sql = "SELECT course_code FROM $tbl_course_user WHERE relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND user_id = ".intval($user_info['user_id']);
  210. $rs = Database::query($sql);
  211. while ($row = Database :: fetch_array($rs)) {
  212. if ($drh_can_access_all_courses) {
  213. $courses_in_session[0][] = $row['course_code'];
  214. } else {
  215. if (isset($courses[$row['course_code']])) {
  216. $courses_in_session[0][] = $row['course_code'];
  217. }
  218. }
  219. }
  220. // Get the list of sessions where the user is subscribed as student
  221. $sql = 'SELECT id_session, course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($user_info['user_id']);
  222. $rs = Database::query($sql);
  223. $tmp_sessions = array();
  224. while ($row = Database :: fetch_array($rs)) {
  225. $tmp_sessions[] = $row['id_session'];
  226. if ($drh_can_access_all_courses) {
  227. if (in_array($row['id_session'], $tmp_sessions)) {
  228. $courses_in_session[$row['id_session']][] = $row['course_code'];
  229. }
  230. } else {
  231. if (isset($courses_in_session_by_coach[$row['id_session']])) {
  232. if (in_array($row['id_session'], $tmp_sessions)) {
  233. $courses_in_session[$row['id_session']][] = $row['course_code'];
  234. }
  235. }
  236. }
  237. }
  238. /*if (empty($courses_in_session)) {
  239. Display :: display_header($nameTools);
  240. echo '<div class="actions">';
  241. echo '<a href="javascript: window.back();" ">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  242. echo '</div>';
  243. Display::display_warning_message(get_lang('NoDataAvailable'));
  244. Display::display_footer();
  245. exit;
  246. }*/
  247. if (!empty($student_id)) {
  248. if (api_is_drh() && !UserManager::is_user_followed_by_drh($student_id, api_get_user_id())) {
  249. api_not_allowed();
  250. }
  251. }
  252. Display :: display_header($nameTools);
  253. if (isset($message)) {
  254. echo $message;
  255. }
  256. if (!empty($student_id)) {
  257. // Actions bar
  258. echo '<div class="actions">';
  259. echo '<a href="javascript: window.back();" ">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  260. echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
  261. echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
  262. if (!empty ($user_info['email'])) {
  263. $send_mail = '<a href="mailto:'.$user_info['email'].'">'.Display :: return_icon('mail_send.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM).'</a>';
  264. } else {
  265. $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM);
  266. }
  267. echo $send_mail;
  268. if (!empty($student_id) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL
  269. echo '<a href="access_details.php?student=' . $student_id . '&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.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>';
  270. }
  271. echo '</div>';
  272. // is the user online ?
  273. if (user_is_online($_GET['student'])) {
  274. $online = get_lang('Yes');
  275. } else {
  276. $online = get_lang('No');
  277. }
  278. // get average of score and average of progress by student
  279. $avg_student_progress = $avg_student_score = 0;
  280. $course_code = Security :: remove_XSS($_GET['course']);
  281. if (!CourseManager :: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
  282. unset($courses[$key]);
  283. } else {
  284. $avg_student_progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, array(), $session_id);
  285. //the score inside the Reporting table
  286. $avg_student_score = Tracking::get_avg_student_score($user_info['user_id'], $course_code, array(), $session_id);
  287. //var_dump($avg_student_score);
  288. }
  289. $avg_student_progress = round($avg_student_progress, 2);
  290. // time spent on the course
  291. $time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
  292. // get information about connections on the platform by student
  293. $first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']);
  294. if ($first_connection_date == '') {
  295. $first_connection_date = get_lang('NoConnexion');
  296. }
  297. $last_connection_date = Tracking :: get_last_connection_date($user_info['user_id'], true);
  298. if ($last_connection_date == '') {
  299. $last_connection_date = get_lang('NoConnexion');
  300. }
  301. // cvs informations
  302. $csv_content[] = array (
  303. get_lang('Informations', '')
  304. );
  305. $csv_content[] = array (
  306. get_lang('Name', ''),
  307. get_lang('Email', ''),
  308. get_lang('Tel', '')
  309. );
  310. $csv_content[] = array (
  311. $user_info['complete_name'],
  312. $user_info['email'],
  313. $user_info['phone']
  314. );
  315. $csv_content[] = array ();
  316. // csv tracking
  317. $csv_content[] = array (
  318. get_lang('Tracking', '')
  319. );
  320. $csv_content[] = array (
  321. get_lang('FirstLogin', ''),
  322. get_lang('LatestLogin', ''),
  323. get_lang('TimeSpentInTheCourse', ''),
  324. get_lang('Progress', ''),
  325. get_lang('Score', '')
  326. );
  327. $csv_content[] = array (
  328. strip_tags($first_connection_date),
  329. strip_tags($last_connection_date),
  330. $time_spent_on_the_course,
  331. $avg_student_progress . '%',
  332. $avg_student_score
  333. );
  334. //Show title
  335. $info_course = CourseManager :: get_course_information($course_code);
  336. $coachs_name = '';
  337. $session_name = '';
  338. $nb_login = Tracking :: count_login_per_student($user_info['user_id'], $_GET['course']);
  339. //get coach and session_name if there is one and if session_mode is activated
  340. if ($session_id > 0) {
  341. $session_info = api_get_session_info($session_id);
  342. $course_coachs = api_get_coachs_from_course($session_id, $course_code);
  343. $nb_login = '';
  344. if (!empty($course_coachs)) {
  345. $info_tutor_name = array();
  346. foreach ($course_coachs as $course_coach) {
  347. $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
  348. }
  349. $info_course['tutor_name'] = implode(",",$info_tutor_name);
  350. } elseif ($session_coach_id != 0) {
  351. $session_coach_id = intval($session_info['id_coach']);
  352. $coach_info = UserManager::get_user_info_by_id($session_coach_id);
  353. $info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
  354. }
  355. $coachs_name = $info_course['tutor_name'];
  356. $session_name = $session_info['name'];
  357. } // end
  358. $info_course = CourseManager :: get_course_information($get_course_code);
  359. $table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).$user_info['complete_name'];
  360. echo Display::page_subheader($table_title);
  361. echo '<table width="100%" border="0">';
  362. echo '<tr>';
  363. $image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true);
  364. echo '<td class="borderRight" width="10%" valign="top">';
  365. // get the path,width and height from original picture
  366. $image_file = $image_array['dir'] . $image_array['file'];
  367. $big_image = $image_array['dir'] . 'big_' . $image_array['file'];
  368. $big_image_size = api_getimagesize($big_image);
  369. $big_image_width = $big_image_size['width'];
  370. $big_image_height = $big_image_size['height'];
  371. $url_big_image = $big_image . '?rnd=' . time();
  372. $img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' .
  373. 'alt="' . $user_info['complete_name']. '" ' .
  374. 'style="float:' . ($text_dir == 'rtl' ? 'right' : 'left') . '; padding:5px;" ';
  375. if ($image_array['file'] == 'unknown.jpg') {
  376. echo '<img ' . $img_attributes . ' />';
  377. } else {
  378. echo '<input type="image" ' . $img_attributes . ' onclick="javascript: return show_image(\'' . $url_big_image . '\',\'' . $big_image_width . '\',\'' . $big_image_height . '\');"/>';
  379. }
  380. echo '</td>';
  381. ?>
  382. <td width="40%" valign="top">
  383. <table width="100%" class="data_table">
  384. <tr>
  385. <th><?php echo get_lang('Information'); ?></th>
  386. </tr>
  387. <tr>
  388. <td><?php echo get_lang('Name') . ' : '.$user_info['complete_name']; ?></td>
  389. </tr>
  390. <tr>
  391. <td><?php echo get_lang('Email') . ' : ';
  392. if (!empty ($user_info['email'])) {
  393. echo '<a href="mailto:' . $user_info['email'] . '">' . $user_info['email'] . '</a>';
  394. } else {
  395. echo get_lang('NoEmail');
  396. } ?>
  397. </td>
  398. </tr>
  399. <tr>
  400. <td> <?php echo get_lang('Tel') . ' : ';
  401. if (!empty ($user_info['phone'])) {
  402. echo $user_info['phone'];
  403. } else {
  404. echo get_lang('NoTel');
  405. }
  406. ?>
  407. </td>
  408. </tr>
  409. <tr>
  410. <td> <?php echo get_lang('OfficialCode') . ' : ';
  411. if (!empty ($user_info['official_code'])) {
  412. echo $user_info['official_code'];
  413. } else {
  414. echo get_lang('NoOfficialCode');
  415. }
  416. ?>
  417. </td>
  418. </tr>
  419. <tr>
  420. <td><?php echo get_lang('OnLine') . ' : '.$online; ?> </td>
  421. </tr>
  422. <?php
  423. // Display timezone if the user selected one and if the admin allows the use of user's timezone
  424. $timezone = null;
  425. $timezone_user = UserManager::get_extra_user_data_by_field($user_info['user_id'],'timezone');
  426. $use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
  427. if ($timezone_user['timezone'] != null && $use_users_timezone == 'true') {
  428. $timezone = $timezone_user['timezone'];
  429. }
  430. if ($timezone !== null) {
  431. ?>
  432. <tr>
  433. <td> <?php echo get_lang('Timezone') . ' : '.$timezone; ?> </td>
  434. </tr>
  435. <?php
  436. }
  437. ?>
  438. </table>
  439. </td>
  440. <td class="borderLeft" width="35%" valign="top">
  441. <table width="100%" class="data_table">
  442. <tr>
  443. <th colspan="2"><?php echo get_lang('Tracking'); ?></th>
  444. </tr>
  445. <tr><td align="right"><?php echo get_lang('FirstLogin') ?></td>
  446. <td align="left"><?php echo $first_connection_date ?></td>
  447. </tr>
  448. <tr>
  449. <td align="right"><?php echo get_lang('LatestLogin') ?></td>
  450. <td align="left"><?php echo $last_connection_date ?></td>
  451. </tr>
  452. <?php if (isset($_GET['details']) && $_GET['details'] == 'true') {?>
  453. <tr>
  454. <td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
  455. <td align="left"><?php echo $time_spent_on_the_course ?></td>
  456. </tr>
  457. <tr>
  458. <td align="right"><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));?></td>
  459. <td align="left"><?php echo $avg_student_progress.'%' ?></td>
  460. </tr>
  461. <tr>
  462. <td align="right"><?php echo get_lang('Score').' '; Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?>
  463. </td>
  464. <td align="left"><?php if (is_numeric($avg_student_score)) { echo $avg_student_score.'%';} else { echo $avg_student_score ;} ?></td>
  465. </tr>
  466. <?php
  467. if (!empty($nb_login)) {
  468. echo '<tr><td align="right">'.get_lang('CountToolAccess').'</td>';
  469. echo '<td align="left">'.$nb_login.'</td>';
  470. echo '</tr>';
  471. }
  472. } ?>
  473. </table>
  474. </td>
  475. </tr>
  476. </table>
  477. <?php
  478. $table_title = '';
  479. if (!empty($session_id)) {
  480. $session_name = api_get_session_name($session_id);
  481. $table_title = ($session_name? Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.' ':'');
  482. }
  483. if (!empty($info_course['title'])) {
  484. $table_title .= ($info_course ? Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$info_course['title'].' ':'');
  485. }
  486. echo Display::page_subheader($table_title);
  487. if (empty($_GET['details'])) {
  488. $csv_content[] = array ();
  489. $csv_content[] = array (
  490. get_lang('Session', ''),
  491. get_lang('Course', ''),
  492. get_lang('Time', ''),
  493. get_lang('Progress', ''),
  494. get_lang('Score', ''),
  495. get_lang('AttendancesFaults', ''),
  496. get_lang('Evaluations')
  497. );
  498. $attendance = new Attendance();
  499. foreach ($courses_in_session as $key => $courses) {
  500. $session_id = $key;
  501. $session_info = api_get_session_info($session_id);
  502. $session_name = $session_info['name'];
  503. $date_start = '';
  504. if (!empty($session_info['date_start']) && $session_info['date_start'] != '0000-00-00') {
  505. $date_start = api_format_date($session_info['date_start'], DATE_FORMAT_SHORT);
  506. }
  507. $date_end = '';
  508. if (!empty($session_info['date_end']) && $session_info['date_end'] != '0000-00-00') {
  509. $date_end = api_format_date($session_info['date_end'], DATE_FORMAT_SHORT);
  510. }
  511. if (!empty($date_start) && !empty($date_end)) {
  512. $date_session = get_lang('From') . ' ' . $date_start . ' ' . get_lang('Until') . ' ' . $date_end;
  513. }
  514. $title = '';
  515. if (empty($session_id)) {
  516. $title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
  517. } else {
  518. $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':'');
  519. }
  520. // Courses
  521. echo '<h3>'.$title.'</h3>';
  522. echo '<table class="data_table">';
  523. echo '<tr>
  524. <th>'.get_lang('Course').'</th>
  525. <th>'.get_lang('Time').'</th>
  526. <th>'.get_lang('Progress').'</th>
  527. <th>'.get_lang('Score').'</th>
  528. <th>'.get_lang('AttendancesFaults').'</th>
  529. <th>'.get_lang('Evaluations').'</th>
  530. <th>'.get_lang('Details').'</th>
  531. </tr>';
  532. if (!empty($courses)) {
  533. foreach ($courses as $course_code) {
  534. if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
  535. $course_info = CourseManager :: get_course_information($course_code);
  536. $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
  537. // get average of faults in attendances by student
  538. $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $session_id);
  539. if (!empty($results_faults_avg['total'])) {
  540. if (api_is_drh()) {
  541. $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>';
  542. } else {
  543. $attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
  544. }
  545. } else {
  546. $attendances_faults_avg = '0/0 (0%)';
  547. }
  548. // get evaluatios by student
  549. $cats = Category::load(null, null, $course_code, null, null, $session_id);
  550. $scoretotal = array();
  551. if (isset($cats) && isset($cats[0])) {
  552. if (!empty($session_id)) {
  553. $scoretotal= $cats[0]->calc_score($student_id, $course_code, $session_id);
  554. } else {
  555. $scoretotal= $cats[0]->calc_score($student_id, $course_code);
  556. }
  557. }
  558. $scoretotal_display = '0/0 (0%)';
  559. if (!empty($scoretotal)) {
  560. $scoretotal_display = round($scoretotal[0],1).'/'.round($scoretotal[1],1).' ('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
  561. }
  562. $progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, null, $session_id);
  563. $score = Tracking :: get_avg_student_score($user_info['user_id'], $course_code, null, $session_id);
  564. $progress = empty($progress) ? '0%' : $progress.'%';
  565. $score = empty($score) ? '0%' : $score.'%';
  566. $csv_content[] = array (
  567. $session_name,
  568. $course_info['title'],
  569. $time_spent_on_course,
  570. $progress,
  571. $score,
  572. $attendances_faults_avg,
  573. $scoretotal_display
  574. );
  575. echo '<tr>
  576. <td >'.$course_info['title'].'</td>
  577. <td >'.$time_spent_on_course .'</td>
  578. <td >'.$progress.'</td>
  579. <td >'.$score.'</td>
  580. <td >'.$attendances_faults_avg.'</td>
  581. <td >'.$scoretotal_display.'</td>';
  582. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  583. echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['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>';
  584. } else {
  585. echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['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>';
  586. }
  587. echo '</tr>';
  588. }
  589. }
  590. } else {
  591. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  592. }
  593. echo '</table>';
  594. }
  595. } else {
  596. $csv_content[] = array ();
  597. $csv_content[] = array (str_replace('&nbsp;', '', $table_title));
  598. $t_lp = Database :: get_course_table(TABLE_LP_MAIN);
  599. // csv export headers
  600. $csv_content[] = array ();
  601. $csv_content[] = array (
  602. get_lang('Learnpath', ''),
  603. get_lang('Time', ''),
  604. get_lang('AverageScore', ''),
  605. get_lang('LatestScore', ''),
  606. get_lang('Progress', ''),
  607. get_lang('LastConnexion', '')
  608. );
  609. if (empty($session_id)) {
  610. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE session_id = 0 AND c_id = {$info_course['real_id']} ORDER BY lp.display_order";
  611. } else {
  612. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE c_id = {$info_course['real_id']} ORDER BY lp.display_order";
  613. }
  614. $rs_lp = Database::query($sql_lp);
  615. $token = Security::get_token();
  616. if (Database :: num_rows($rs_lp) > 0) {
  617. ?>
  618. <!-- LPs-->
  619. <table class="data_table">
  620. <tr>
  621. <th><?php echo get_lang('Learnpaths');?></th>
  622. <th><?php echo get_lang('Time').' '; Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  623. <th><?php echo get_lang('AverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInAllAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  624. <th><?php echo get_lang('LatestAttemptAverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  625. <th><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
  626. <th><?php echo get_lang('LastConnexion').' '; Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
  627. <?php
  628. echo '<th>'.get_lang('Details').'</th>';
  629. if (api_is_allowed_to_edit()) {
  630. echo '<th>'.get_lang('ResetLP').'</th>';
  631. }
  632. ?>
  633. </tr>
  634. <?php
  635. $i = 0;
  636. while ($learnpath = Database :: fetch_array($rs_lp)) {
  637. $lp_id = intval($learnpath['id']);
  638. $lp_name = $learnpath['name'];
  639. $any_result = false;
  640. // Get progress in lp
  641. $progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
  642. if ($progress === null) {
  643. $progress = '0%';
  644. } else {
  645. $any_result = true;
  646. }
  647. // Get time in lp
  648. $total_time = Tracking::get_time_spent_in_lp($student_id, $course_code, array($lp_id),$session_id);
  649. if (!empty($total_time)) $any_result = true;
  650. // Get last connection time in lp
  651. $start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id);
  652. if (!empty($start_time)) {
  653. $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
  654. } else {
  655. $start_time = '-';
  656. }
  657. if (!empty($total_time)) $any_result = true;
  658. // Quizz in lp
  659. $score = Tracking::get_avg_student_score($student_id, $course_code, array($lp_id),$session_id);
  660. // Latest exercise results in a LP
  661. $score_latest = Tracking :: get_avg_student_score($student_id, $course_code, array($lp_id),$session_id, false, true);
  662. if ($i % 2 == 0) $css_class = "row_even";
  663. else $css_class = "row_odd";
  664. $i++;
  665. // csv export content
  666. $csv_content[] = array (
  667. api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
  668. api_time_to_hms($total_time),
  669. $score . '%',
  670. $score_latest . '%',
  671. $progress.'%',
  672. $start_time
  673. );
  674. echo '<tr class="'.$css_class.'">';
  675. echo Display::tag('td', stripslashes($lp_name));
  676. echo Display::tag('td', api_time_to_hms($total_time));
  677. if (!is_null($score)) {
  678. if (is_numeric($score)) {
  679. $score = $score.'%';
  680. }
  681. }
  682. echo Display::tag('td', $score);
  683. if (!is_null($score_latest)) {
  684. if (is_numeric($score_latest)) {
  685. $score_latest = $score_latest.'%';
  686. }
  687. }
  688. echo Display::tag('td', $score_latest);
  689. if (is_numeric($progress)) {
  690. $progress = $progress.'%';
  691. } else {
  692. $progress = '-';
  693. }
  694. echo Display::tag('td', $progress);
  695. //Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
  696. //which implies several other changes not a priority right now
  697. echo Display::tag('td', $start_time);
  698. if ($any_result === true) {
  699. $from = '';
  700. if ($from_myspace) {
  701. $from ='&from=myspace';
  702. }
  703. $link = Display::url('<img src="../img/2rightarrow.gif" border="0" />','lp_tracking.php?course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id);
  704. echo Display::tag('td', $link);
  705. }
  706. if (api_is_allowed_to_edit()) {
  707. echo '<td>';
  708. if ($any_result === true) {
  709. echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
  710. echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
  711. echo '</a>';
  712. }
  713. echo '</td>';
  714. echo '</tr>';
  715. }
  716. $data_learnpath[$i][] = $lp_name;
  717. $data_learnpath[$i][] = $progress . '%';
  718. }
  719. } else {
  720. //echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
  721. }
  722. ?>
  723. </table>
  724. <!-- line about exercises -->
  725. <table class="data_table">
  726. <tr>
  727. <th><?php echo get_lang('Exercices'); ?></th>
  728. <th><?php echo get_lang('AverageScore').' '.Display :: return_icon('info3.gif', get_lang('AverageScore'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
  729. <th><?php echo get_lang('Attempts'); ?></th>
  730. <th><?php echo get_lang('LatestAttempt'); ?></th>
  731. <th><?php echo get_lang('AllAttempts'); ?></th>
  732. </tr>
  733. <?php
  734. $csv_content[] = array ();
  735. $csv_content[] = array (
  736. get_lang('Exercices'),
  737. get_lang('Score'),
  738. get_lang('Attempts')
  739. );
  740. $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
  741. $sql_exercices = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
  742. WHERE quiz.c_id = ".$info_course['real_id']." AND
  743. active='1' AND
  744. (quiz.session_id = $session_id OR quiz.session_id = 0)
  745. ORDER BY quiz.title ASC ";
  746. $result_exercices = Database::query($sql_exercices);
  747. $i = 0;
  748. if (Database :: num_rows($result_exercices) > 0) {
  749. while ($exercices = Database :: fetch_array($result_exercices)) {
  750. $exercise_id = intval($exercices['id']);
  751. $count_attempts = Tracking::count_student_exercise_attempts($student_id, $course_code, $exercise_id, 0, 0, $session_id);
  752. $score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id, $session_id);
  753. $csv_content[] = array (
  754. $exercices['title'],
  755. $score_percentage . '%',
  756. $count_attempts
  757. );
  758. if ($i % 2) $css_class = 'row_odd';
  759. else $css_class = 'row_even';
  760. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  761. echo '<td>';
  762. if ($count_attempts > 0) {
  763. echo $score_percentage . '%';
  764. } else {
  765. echo '-';
  766. $score_percentage = 0;
  767. }
  768. echo '</td>';
  769. echo '<td>'.$count_attempts.'</td>';
  770. echo '<td>';
  771. $sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
  772. WHERE exe_exo_id ="'.$exercise_id.'" AND
  773. exe_user_id ="'.$student_id.'" AND
  774. exe_cours_id ="'.$course_code.'" AND
  775. session_id ="'.$session_id.'" AND
  776. status = "" AND
  777. orig_lp_id = 0 AND
  778. orig_lp_item_id = 0
  779. ORDER BY exe_date DESC LIMIT 1';
  780. $result_last_attempt = Database::query($sql_last_attempt);
  781. if (Database :: num_rows($result_last_attempt) > 0) {
  782. $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
  783. if ($count_attempts > 0)
  784. echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$session_id.'&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>';
  785. }
  786. echo '</td>';
  787. echo '<td>';
  788. $all_attempt_url = "../exercice/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$session_id";
  789. echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url );
  790. echo '</td></tr>';
  791. $data_exercices[$i][] = $exercices['title'];
  792. $data_exercices[$i][] = $score_percentage . '%';
  793. $data_exercices[$i][] = $count_attempts;
  794. $i++;
  795. }
  796. } else {
  797. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  798. }
  799. echo '</table>';
  800. //@when using sessions we do not show the survey list
  801. if (empty($session_id)) {
  802. $survey_list = survey_manager::get_surveys($course_code, $session_id);
  803. $survey_data = array();
  804. foreach($survey_list as $survey) {
  805. $user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $info_course['real_id']);
  806. $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
  807. if (in_array($student_id, $user_list)) {
  808. $survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
  809. }
  810. $data = array('title' => $survey['title'], 'done' => $survey_done);
  811. $survey_data[] = $data;
  812. }
  813. if (!empty($survey_list)) {
  814. $table = new HTML_Table(array('class' => 'data_table'));
  815. $header_names = array(get_lang('Survey'), get_lang('Answered'));
  816. $row = 0;
  817. $column = 0;
  818. foreach ($header_names as $item) {
  819. $table->setHeaderContents($row, $column, $item);
  820. $column++;
  821. }
  822. $row = 1;
  823. if (!empty($survey_data)) {
  824. foreach ($survey_data as $data) {
  825. $column = 0;
  826. $table->setCellContents($row, $column, $data);
  827. //$table->setRowAttributes($row, 'style="text-align:center"');
  828. $class = 'class="row_odd"';
  829. if($row % 2) {
  830. $class = 'class="row_even"';
  831. }
  832. $table->setRowAttributes($row, $class, true);
  833. $column++;
  834. $row++;
  835. }
  836. }
  837. echo $table->toHtml();
  838. }
  839. }
  840. // line about other tools
  841. echo '<table class="data_table">';
  842. $csv_content[] = array ();
  843. $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $session_id);
  844. $messages = Tracking::count_student_messages($student_id, $course_code, $session_id);
  845. $links = Tracking::count_student_visited_links($student_id, $course_code, $session_id);
  846. $chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
  847. $documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
  848. $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id);
  849. $csv_content[] = array (
  850. get_lang('Student_publication'),
  851. $nb_assignments
  852. );
  853. $csv_content[] = array (
  854. get_lang('Messages'),
  855. $messages
  856. );
  857. $csv_content[] = array (
  858. get_lang('LinksDetails'),
  859. $links
  860. );
  861. $csv_content[] = array (
  862. get_lang('DocumentsDetails'),
  863. $documents
  864. );
  865. $csv_content[] = array (
  866. get_lang('UploadedDocuments'),
  867. $uploaded_documents
  868. );
  869. $csv_content[] = array (
  870. get_lang('ChatLastConnection'),
  871. $chat_last_connection
  872. );
  873. ?>
  874. <tr>
  875. <th colspan="2"><?php echo get_lang('OtherTools'); ?></th>
  876. </tr>
  877. <tr><!-- assignments -->
  878. <td width="40%"><?php echo get_lang('Student_publication') ?></td>
  879. <td><?php echo $nb_assignments ?></td>
  880. </tr>
  881. <tr><!-- messages -->
  882. <td><?php echo get_lang('Messages') ?></td>
  883. <td><?php echo $messages ?></td>
  884. </tr>
  885. <tr><!-- links -->
  886. <td><?php echo get_lang('LinksDetails') ?></td>
  887. <td><?php echo $links ?></td>
  888. </tr>
  889. <tr><!-- downloaded documents -->
  890. <td><?php echo get_lang('DocumentsDetails') ?></td>
  891. <td><?php echo $documents ?></td>
  892. </tr>
  893. <tr><!-- uploaded documents -->
  894. <td><?php echo get_lang('UploadedDocuments') ?></td>
  895. <td><?php echo $uploaded_documents ?></td>
  896. </tr>
  897. <tr><!-- Chats -->
  898. <td><?php echo get_lang('ChatLastConnection') ?></td>
  899. <td><?php echo $chat_last_connection; ?></td>
  900. </tr>
  901. </table>
  902. </td>
  903. </tr>
  904. </table>
  905. <?php
  906. } //end details
  907. }
  908. if ($export_csv) {
  909. ob_end_clean();
  910. Export :: export_table_csv($csv_content, 'reporting_student');
  911. exit;
  912. }
  913. /* FOOTER */
  914. Display :: display_footer();