myStudents.php 39 KB

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