myStudents.php 57 KB

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