myStudents.php 51 KB

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