myStudents.php 53 KB

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