myStudents.php 51 KB

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