myStudents.php 52 KB

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