myStudents.php 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526
  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(
  348. 'skill-badges.png',
  349. get_lang('AssignSkill'),
  350. null,
  351. ICON_SIZE_MEDIUM
  352. ),
  353. api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $student_id])
  354. );
  355. }
  356. $permissions = StudentFollowUpPlugin::getPermissions(
  357. $student_id,
  358. api_get_user_id()
  359. );
  360. $isAllow = $permissions['is_allow'];
  361. if ($isAllow) {
  362. echo Display::url(
  363. Display::return_icon(
  364. 'blog.png',
  365. get_lang('Blog'),
  366. null,
  367. ICON_SIZE_MEDIUM
  368. ),
  369. api_get_path(WEB_PLUGIN_PATH).'studentfollowup/posts.php?student_id='.$student_id
  370. );
  371. }
  372. echo '</div>';
  373. // is the user online ?
  374. if (user_is_online($student_id)) {
  375. $online = get_lang('Yes');
  376. } else {
  377. $online = get_lang('No');
  378. }
  379. // get average of score and average of progress by student
  380. $avg_student_progress = $avg_student_score = 0;
  381. if (CourseManager::is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
  382. $avg_student_progress = Tracking::get_avg_student_progress(
  383. $user_info['user_id'],
  384. $course_code,
  385. array(),
  386. $sessionId
  387. );
  388. // the score inside the Reporting table
  389. $avg_student_score = Tracking::get_avg_student_score(
  390. $user_info['user_id'],
  391. $course_code,
  392. array(),
  393. $sessionId
  394. );
  395. }
  396. $avg_student_progress = round($avg_student_progress, 2);
  397. $time_spent_on_the_course = 0;
  398. if (!empty($courseInfo)) {
  399. $time_spent_on_the_course = api_time_to_hms(
  400. Tracking:: get_time_spent_on_the_course(
  401. $user_info['user_id'],
  402. $courseInfo['real_id'],
  403. $sessionId
  404. )
  405. );
  406. }
  407. // get information about connections on the platform by student
  408. $first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']);
  409. if ($first_connection_date == '') {
  410. $first_connection_date = get_lang('NoConnexion');
  411. }
  412. $last_connection_date = Tracking :: get_last_connection_date($user_info['user_id'], true);
  413. if ($last_connection_date == '') {
  414. $last_connection_date = get_lang('NoConnexion');
  415. }
  416. // cvs information
  417. $csv_content[] = array(
  418. get_lang('Information')
  419. );
  420. $csv_content[] = array(
  421. get_lang('Name'),
  422. get_lang('Email'),
  423. get_lang('Tel')
  424. );
  425. $csv_content[] = array(
  426. $user_info['complete_name'],
  427. $user_info['email'],
  428. $user_info['phone']
  429. );
  430. $csv_content[] = array();
  431. // csv tracking
  432. $csv_content[] = array(
  433. get_lang('Tracking')
  434. );
  435. $csv_content[] = array(
  436. get_lang('FirstLoginInPlatform'),
  437. get_lang('LatestLoginInPlatform'),
  438. get_lang('TimeSpentInTheCourse'),
  439. get_lang('Progress'),
  440. get_lang('Score')
  441. );
  442. $csv_content[] = array(
  443. strip_tags($first_connection_date),
  444. strip_tags($last_connection_date),
  445. $time_spent_on_the_course,
  446. $avg_student_progress.'%',
  447. $avg_student_score
  448. );
  449. $coachs_name = '';
  450. $session_name = '';
  451. $table_title = Display::return_icon(
  452. 'user.png',
  453. get_lang('User'),
  454. array(),
  455. ICON_SIZE_SMALL
  456. ).$user_info['complete_name'];
  457. echo Display::page_subheader($table_title);
  458. $userPicture = UserManager::getUserPicture($user_info['user_id']);
  459. $userGroupManager = new UserGroup();
  460. $userGroups = $userGroupManager->getNameListByUser(
  461. $user_info['user_id'],
  462. UserGroup::NORMAL_CLASS
  463. );
  464. ?>
  465. <img src="<?php echo $userPicture ?>">
  466. <div class="row">
  467. <div class="col-sm-6">
  468. <table class="table table-striped table-hover">
  469. <thead>
  470. <tr>
  471. <th><?php echo get_lang('Information'); ?></th>
  472. </tr>
  473. </thead>
  474. <tbody>
  475. <tr>
  476. <td><?php echo get_lang('Name').' : '.$user_info['complete_name']; ?></td>
  477. </tr>
  478. <tr>
  479. <td>
  480. <?php
  481. echo get_lang('Email').' : ';
  482. if (!empty($user_info['email'])) {
  483. echo '<a href="mailto:'.$user_info['email'].'">'.$user_info['email'].'</a>';
  484. } else {
  485. echo get_lang('NoEmail');
  486. } ?>
  487. </td>
  488. </tr>
  489. <tr>
  490. <td> <?php echo get_lang('Tel').' : ';
  491. if (!empty($user_info['phone'])) {
  492. echo $user_info['phone'];
  493. } else {
  494. echo get_lang('NoTel');
  495. }
  496. ?>
  497. </td>
  498. </tr>
  499. <tr>
  500. <td>
  501. <?php
  502. echo get_lang('OfficialCode').' : ';
  503. if (!empty($user_info['official_code'])) {
  504. echo $user_info['official_code'];
  505. } else {
  506. echo get_lang('NoOfficialCode');
  507. }
  508. ?>
  509. </td>
  510. </tr>
  511. <tr>
  512. <td><?php echo get_lang('OnLine').' : '.$online; ?> </td>
  513. </tr>
  514. <?php
  515. if (!empty($course_code)) {
  516. ?>
  517. <tr>
  518. <td>
  519. <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>
  520. </td>
  521. </tr>
  522. <?php
  523. }
  524. // Display timezone if the user selected one and if the admin allows the use of user's timezone
  525. $timezone = null;
  526. $timezone_user = UserManager::get_extra_user_data_by_field(
  527. $user_info['user_id'],
  528. 'timezone'
  529. );
  530. $use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
  531. if ($timezone_user['timezone'] != null && $use_users_timezone == 'true') {
  532. $timezone = $timezone_user['timezone'];
  533. }
  534. if ($timezone !== null) {
  535. ?>
  536. <tr>
  537. <td> <?php echo get_lang('Timezone').' : '.$timezone; ?> </td>
  538. </tr>
  539. <?php
  540. }
  541. ?>
  542. </tbody>
  543. </table>
  544. </div>
  545. <div class="col-sm-6">
  546. <table class="table table-striped table-hover">
  547. <thead>
  548. <tr>
  549. <th colspan="2" class="text-center"><?php echo get_lang('Tracking'); ?></th>
  550. </tr>
  551. </thead>
  552. <tbody>
  553. <tr><td align="right"><?php echo get_lang('FirstLoginInPlatform') ?></td>
  554. <td align="left"><?php echo $first_connection_date ?></td>
  555. </tr>
  556. <tr>
  557. <td align="right"><?php echo get_lang('LatestLoginInPlatform') ?></td>
  558. <td align="left"><?php echo $last_connection_date ?></td>
  559. </tr>
  560. <?php if (isset($_GET['details']) && $_GET['details'] == 'true') { ?>
  561. <tr>
  562. <td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
  563. <td align="left"><?php echo $time_spent_on_the_course ?></td>
  564. </tr>
  565. <tr>
  566. <td align="right">
  567. <?php
  568. echo get_lang('Progress').' ';
  569. Display:: display_icon(
  570. 'info3.gif',
  571. get_lang('ScormAndLPProgressTotalAverage'),
  572. array('align' => 'absmiddle', 'hspace' => '3px')
  573. );
  574. ?>
  575. </td>
  576. <td align="left"><?php echo $avg_student_progress.'%' ?></td>
  577. </tr>
  578. <tr>
  579. <td align="right">
  580. <?php
  581. echo get_lang('Score').' ';
  582. Display:: display_icon(
  583. 'info3.gif',
  584. get_lang('ScormAndLPTestTotalAverage'),
  585. array('align' => 'absmiddle', 'hspace' => '3px')
  586. );
  587. ?>
  588. </td>
  589. <td align="left"><?php
  590. if (is_numeric($avg_student_score)) {
  591. echo $avg_student_score.'%';
  592. } else {
  593. echo $avg_student_score;
  594. }
  595. ?>
  596. </td>
  597. </tr>
  598. <?php
  599. }
  600. if (api_get_setting('allow_terms_conditions') === 'true') {
  601. $isBoss = UserManager::userIsBossOfStudent(api_get_user_id(), $student_id);
  602. if ($isBoss || api_is_platform_admin()) {
  603. $extraFieldValue = new ExtraFieldValue('user');
  604. $value = $extraFieldValue->get_values_by_handler_and_field_variable($student_id, 'legal_accept');
  605. $icon = Display::return_icon('accept_na.png');
  606. if (isset($value['value'])) {
  607. list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']);
  608. $icon = Display::return_icon('accept.png').' '.api_get_local_time($legalTime);
  609. $icon .= ' '.Display::url(
  610. get_lang('DeleteLegal'),
  611. api_get_self().'?action=delete_legal&student='.$student_id.'&course='.$course_code,
  612. ['class' => 'btn btn-danger btn-xs']
  613. );
  614. } else {
  615. $icon .= ' '.Display::url(
  616. get_lang('SendLegal'),
  617. api_get_self().'?action=send_legal&student='.$student_id.'&course='.$course_code,
  618. ['class' => 'btn btn-primary btn-xs']
  619. );
  620. }
  621. echo '<tr>
  622. <td align="right">';
  623. echo get_lang('LegalAccepted').' </td> <td align="left">'.$icon;
  624. echo '</td></tr>';
  625. }
  626. }
  627. ?>
  628. </tbody>
  629. </table>
  630. <?php if (!empty($userGroups)) { ?>
  631. <table class="table table-striped table-hover">
  632. <thead>
  633. <tr>
  634. <th><?php echo get_lang('Classes') ?></th>
  635. </tr>
  636. </thead>
  637. <tbody>
  638. <?php foreach ($userGroups as $class) { ?>
  639. <tr>
  640. <td><?php echo $class ?></td>
  641. </tr>
  642. <?php } ?>
  643. </tbody>
  644. </table>
  645. <?php } ?>
  646. </div>
  647. </div>
  648. <?php
  649. if (empty($_GET['details'])) {
  650. $csv_content[] = array();
  651. $csv_content[] = array(
  652. get_lang('Session'),
  653. get_lang('Course'),
  654. get_lang('Time'),
  655. get_lang('Progress'),
  656. get_lang('Score'),
  657. get_lang('AttendancesFaults'),
  658. get_lang('Evaluations')
  659. );
  660. $attendance = new Attendance();
  661. foreach ($courses_in_session as $sId => $courses) {
  662. $session_name = '';
  663. $access_start_date = '';
  664. $access_end_date = '';
  665. $date_session = '';
  666. $title = Display::return_icon(
  667. 'course.png',
  668. get_lang('Courses'),
  669. array(),
  670. ICON_SIZE_SMALL
  671. ).' '.get_lang('Courses');
  672. $session_info = api_get_session_info($sId);
  673. if ($session_info) {
  674. $session_name = $session_info['name'];
  675. if (!empty($session_info['access_start_date'])) {
  676. $access_start_date = api_format_date($session_info['access_start_date'], DATE_FORMAT_SHORT);
  677. }
  678. if (!empty($session_info['access_end_date'])) {
  679. $access_end_date = api_format_date($session_info['access_end_date'], DATE_FORMAT_SHORT);
  680. }
  681. if (!empty($access_start_date) && !empty($access_end_date)) {
  682. $date_session = get_lang('From').' '.$access_start_date.' '.get_lang('Until').' '.$access_end_date;
  683. }
  684. $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session ? ' ('.$date_session.')' : '');
  685. }
  686. // Courses
  687. echo '<h3>'.$title.'</h3>';
  688. echo '<div class="table-responsive">';
  689. echo '<table class="table table-striped table-hover courses-tracking">';
  690. echo '<thead>';
  691. echo '<tr>
  692. <th>'.get_lang('Course').'</th>
  693. <th>'.get_lang('Time').'</th>
  694. <th>'.get_lang('Progress').'</th>
  695. <th>'.get_lang('Score').'</th>
  696. <th>'.get_lang('AttendancesFaults').'</th>
  697. <th>'.get_lang('Evaluations').'</th>
  698. <th>'.get_lang('Details').'</th>
  699. </tr>';
  700. echo '</thead>';
  701. echo '<tbody>';
  702. if (!empty($courses)) {
  703. foreach ($courses as $courseId) {
  704. $courseInfoItem = api_get_course_info_by_id($courseId);
  705. $courseId = $courseInfoItem['real_id'];
  706. $courseCodeItem = $courseInfoItem['code'];
  707. $isSubscribed = CourseManager:: is_user_subscribed_in_course(
  708. $student_id,
  709. $courseCodeItem,
  710. true
  711. );
  712. if ($isSubscribed) {
  713. $time_spent_on_course = api_time_to_hms(
  714. Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sId)
  715. );
  716. // get average of faults in attendances by student
  717. $results_faults_avg = $attendance->get_faults_average_by_course(
  718. $student_id,
  719. $courseCodeItem,
  720. $sId
  721. );
  722. if (!empty($results_faults_avg['total'])) {
  723. if (api_is_drh()) {
  724. $attendances_faults_avg =
  725. '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id='.$student_id.'">'.
  726. $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  727. } else {
  728. $attendances_faults_avg =
  729. $results_faults_avg['faults'].'/'.
  730. $results_faults_avg['total'].
  731. ' ('.$results_faults_avg['porcent'].'%)'
  732. ;
  733. }
  734. } else {
  735. $attendances_faults_avg = '0/0 (0%)';
  736. }
  737. // Get evaluations by student
  738. $cats = Category::load(
  739. null,
  740. null,
  741. $courseCodeItem,
  742. null,
  743. null,
  744. $sId
  745. );
  746. $scoretotal = array();
  747. if (isset($cats) && isset($cats[0])) {
  748. if (!empty($sId)) {
  749. $scoretotal = $cats[0]->calc_score($student_id, null, $courseCodeItem, $sId);
  750. } else {
  751. $scoretotal = $cats[0]->calc_score($student_id, null, $courseCodeItem);
  752. }
  753. }
  754. $scoretotal_display = '0/0 (0%)';
  755. if (!empty($scoretotal) && !empty($scoretotal[1])) {
  756. $scoretotal_display =
  757. round($scoretotal[0], 1).'/'.
  758. round($scoretotal[1], 1).
  759. ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
  760. }
  761. $progress = Tracking::get_avg_student_progress(
  762. $user_info['user_id'],
  763. $courseCodeItem,
  764. null,
  765. $sId
  766. );
  767. $score = Tracking:: get_avg_student_score(
  768. $user_info['user_id'],
  769. $courseCodeItem,
  770. null,
  771. $sId
  772. );
  773. $progress = empty($progress) ? '0%' : $progress.'%';
  774. $score = empty($score) ? '0%' : $score.'%';
  775. $csv_content[] = array(
  776. $session_name,
  777. $courseInfoItem['title'],
  778. $time_spent_on_course,
  779. $progress,
  780. $score,
  781. $attendances_faults_avg,
  782. $scoretotal_display
  783. );
  784. echo '<tr>
  785. <td ><a href="' .$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
  786. $courseInfoItem['title'].'</a></td>
  787. <td >'.$time_spent_on_course.'</td>
  788. <td >'.$progress.'</td>
  789. <td >'.$score.'</td>
  790. <td >'.$attendances_faults_avg.'</td>
  791. <td >'.$scoretotal_display.'</td>';
  792. if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  793. 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">
  794. '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  795. } else {
  796. 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">
  797. '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  798. }
  799. echo '</tr>';
  800. }
  801. }
  802. } else {
  803. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  804. }
  805. echo '</tbody>';
  806. echo '</table>';
  807. echo '</div>';
  808. }
  809. } else {
  810. $trackingColumns = api_get_configuration_value('tracking_columns');
  811. $columnHeaders = [
  812. 'lp' => get_lang('LearningPath'),
  813. 'time' => get_lang('Time').
  814. Display::return_icon(
  815. 'info3.gif',
  816. get_lang('TotalTimeByCourse'),
  817. array('align' => 'absmiddle', 'hspace' => '3px')
  818. ),
  819. 'best_score' => get_lang('BestScore'),
  820. 'latest_attempt_avg_score' => get_lang('LatestAttemptAverageScore').
  821. Display::return_icon(
  822. 'info3.gif',
  823. get_lang('AverageIsCalculatedBasedInTheLatestAttempts'),
  824. array('align' => 'absmiddle', 'hspace' => '3px')
  825. ),
  826. 'progress'=> get_lang('Progress').
  827. Display::return_icon(
  828. 'info3.gif',
  829. get_lang('LPProgressScore'),
  830. array('align' => 'absmiddle', 'hspace' => '3px')
  831. ),
  832. 'last_connection' => get_lang('LastConnexion').
  833. Display::return_icon(
  834. 'info3.gif',
  835. get_lang('LastTimeTheCourseWasUsed'),
  836. array('align' => 'absmiddle', 'hspace' => '3px')
  837. )
  838. ];
  839. if ($user_info['status'] != INVITEE) {
  840. $csv_content[] = array();
  841. $csv_content[] = array(str_replace('&nbsp;', '', $table_title));
  842. $trackingColumns = api_get_configuration_value('tracking_columns');
  843. if (isset($trackingColumns['my_students_lp'])) {
  844. foreach ($columnHeaders as $key => $value) {
  845. if (!isset($trackingColumns['my_progress_lp'][$key]) ||
  846. $trackingColumns['my_students_lp'][$key] == false
  847. ) {
  848. unset($columnHeaders[$key]);
  849. }
  850. }
  851. }
  852. $headers = '';
  853. $columnHeadersToExport = [];
  854. // csv export headers
  855. foreach ($columnHeaders as $key => $columnName) {
  856. $columnHeadersToExport[] = strip_tags($columnName);
  857. $headers .= Display::tag(
  858. 'th',
  859. $columnName
  860. );
  861. }
  862. $csv_content[] = $columnHeadersToExport;
  863. $columnHeadersKeys = array_keys($columnHeaders);
  864. // @todo use LearnpathList class
  865. if (empty($sessionId)) {
  866. $dql = '
  867. SELECT lp FROM ChamiloCourseBundle:CLp lp
  868. WHERE
  869. (lp.sessionId = 0 OR lp.sessionId IS NULL) AND
  870. lp.cId = :course
  871. ORDER BY lp.displayOrder ASC
  872. ';
  873. $query = $em->createQuery($dql);
  874. $query->setParameters([
  875. 'course' => $courseInfo['real_id']
  876. ]);
  877. } else {
  878. $dql = '
  879. SELECT lp FROM ChamiloCourseBundle:CLp lp
  880. WHERE
  881. (lp.sessionId = :session OR lp.sessionId = 0 OR lp.sessionId IS NULL) AND
  882. lp.cId = :course
  883. ORDER BY lp.displayOrder ASC
  884. ';
  885. $query = $em->createQuery($dql);
  886. $query->setParameters([
  887. 'session' => $sessionId,
  888. 'course' => $courseInfo['real_id']
  889. ]);
  890. }
  891. $lps = $query->getResult();
  892. if (count($lps) > 0) {
  893. echo '<div class="table-responsive">';
  894. echo '<table class="table table-striped table-hover"><thead><tr>';
  895. echo $headers;
  896. echo '<th>'.get_lang('Details').'</th>';
  897. if (api_is_allowed_to_edit()) {
  898. echo '<th>'.get_lang('ResetLP').'</th>';
  899. }
  900. echo '</tr></thead><tbody>';
  901. $i = 0;
  902. /** @var CLp $learnpath */
  903. foreach ($lps as $learnpath) {
  904. $lp_id = $learnpath->getId();
  905. $lp_name = $learnpath->getName();
  906. $any_result = false;
  907. // Get progress in lp
  908. $progress = Tracking::get_avg_student_progress(
  909. $student_id,
  910. $course_code,
  911. array($lp_id),
  912. $sessionId
  913. );
  914. if ($progress === null) {
  915. $progress = '0%';
  916. } else {
  917. $any_result = true;
  918. }
  919. // Get time in lp
  920. $total_time = Tracking::get_time_spent_in_lp(
  921. $student_id,
  922. $course_code,
  923. array($lp_id),
  924. $sessionId
  925. );
  926. if (!empty($total_time)) {
  927. $any_result = true;
  928. }
  929. // Get last connection time in lp
  930. $start_time = Tracking::get_last_connection_time_in_lp(
  931. $student_id,
  932. $course_code,
  933. $lp_id,
  934. $sessionId
  935. );
  936. if (!empty($start_time)) {
  937. $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
  938. } else {
  939. $start_time = '-';
  940. }
  941. if (!empty($total_time)) {
  942. $any_result = true;
  943. }
  944. // Quiz in lp
  945. $score = Tracking::get_avg_student_score(
  946. $student_id,
  947. $course_code,
  948. array($lp_id),
  949. $sessionId
  950. );
  951. // Latest exercise results in a LP
  952. $score_latest = Tracking:: get_avg_student_score(
  953. $student_id,
  954. $course_code,
  955. array($lp_id),
  956. $sessionId,
  957. false,
  958. true
  959. );
  960. $bestScore = Tracking::get_avg_student_score(
  961. $student_id,
  962. $course_code,
  963. array($lp_id),
  964. $sessionId,
  965. false,
  966. false,
  967. true
  968. );
  969. if (empty($bestScore)) {
  970. $bestScore = '';
  971. } else {
  972. $bestScore = $bestScore.'%';
  973. }
  974. if ($i % 2 == 0) {
  975. $css_class = "row_even";
  976. } else {
  977. $css_class = "row_odd";
  978. }
  979. $i++;
  980. if (isset($score_latest) && !is_null($score_latest)) {
  981. if (is_numeric($score_latest)) {
  982. $score_latest = $score_latest.'%';
  983. }
  984. }
  985. if (is_numeric($progress)) {
  986. $progress = $progress.'%';
  987. } else {
  988. $progress = '-';
  989. }
  990. echo '<tr class="'.$css_class.'">';
  991. $contentToExport = [];
  992. if (in_array('lp', $columnHeadersKeys)) {
  993. $contentToExport[] = api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset);
  994. echo Display::tag('td', stripslashes($lp_name));
  995. }
  996. if (in_array('time', $columnHeadersKeys)) {
  997. $contentToExport[] = api_time_to_hms($total_time);
  998. echo Display::tag('td', api_time_to_hms($total_time));
  999. }
  1000. if (in_array('best_score', $columnHeadersKeys)) {
  1001. $contentToExport[] = $bestScore;
  1002. echo Display::tag('td', $bestScore);
  1003. }
  1004. if (in_array('latest_attempt_avg_score', $columnHeadersKeys)) {
  1005. $contentToExport[] = $score_latest;
  1006. echo Display::tag('td', $score_latest);
  1007. }
  1008. if (in_array('progress', $columnHeadersKeys)) {
  1009. $contentToExport[] = $progress;
  1010. echo Display::tag('td', $progress);
  1011. }
  1012. if (in_array('last_connection', $columnHeadersKeys)) {
  1013. //Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
  1014. //which implies several other changes not a priority right now
  1015. $contentToExport[] = $start_time;
  1016. echo Display::tag('td', $start_time);
  1017. }
  1018. $csv_content[] = $contentToExport;
  1019. if ($any_result === true) {
  1020. $from = '';
  1021. if ($from_myspace) {
  1022. $from = '&from=myspace';
  1023. }
  1024. $link = Display::url(
  1025. Display::return_icon('2rightarrow.png', get_lang('Details')),
  1026. '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
  1027. );
  1028. echo Display::tag('td', $link);
  1029. }
  1030. if (api_is_allowed_to_edit()) {
  1031. echo '<td>';
  1032. if ($any_result === true) {
  1033. $url = '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;
  1034. echo Display::url(
  1035. Display::return_icon(
  1036. 'clean.png',
  1037. get_lang('Clean'),
  1038. '',
  1039. ICON_SIZE_SMALL
  1040. ),
  1041. $url,
  1042. ['onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDelete')))."')) return false;"]
  1043. );
  1044. }
  1045. echo '</td>';
  1046. echo '</tr>';
  1047. }
  1048. }
  1049. ?>
  1050. </tbody>
  1051. </table>
  1052. </div>
  1053. <?php
  1054. }
  1055. } ?>
  1056. <!-- line about exercises -->
  1057. <?php if ($user_info['status'] != INVITEE) { ?>
  1058. <div class="table-responsive">
  1059. <table class="table table-striped table-hover">
  1060. <thead>
  1061. <tr>
  1062. <th><?php echo get_lang('Exercises'); ?></th>
  1063. <th><?php echo get_lang('LearningPath'); ?></th>
  1064. <th><?php echo get_lang('AvgCourseScore').' '.Display::return_icon('info3.gif', get_lang('AverageScore'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
  1065. <th><?php echo get_lang('Attempts'); ?></th>
  1066. <th><?php echo get_lang('LatestAttempt'); ?></th>
  1067. <th><?php echo get_lang('AllAttempts'); ?></th>
  1068. </tr>
  1069. </thead>
  1070. <tbody>
  1071. <?php
  1072. $csv_content[] = array();
  1073. $csv_content[] = array(
  1074. get_lang('Exercises'),
  1075. get_lang('LearningPath'),
  1076. get_lang('AvgCourseScore'),
  1077. get_lang('Attempts')
  1078. );
  1079. $t_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
  1080. $sessionCondition = api_get_session_condition(
  1081. $sessionId,
  1082. true,
  1083. true,
  1084. 'quiz.session_id'
  1085. );
  1086. $sql = "SELECT quiz.title, id FROM ".$t_quiz." AS quiz
  1087. WHERE
  1088. quiz.c_id = ".$courseInfo['real_id']." AND
  1089. active IN (0, 1)
  1090. $sessionCondition
  1091. ORDER BY quiz.title ASC ";
  1092. $result_exercices = Database::query($sql);
  1093. $i = 0;
  1094. if (Database :: num_rows($result_exercices) > 0) {
  1095. while ($exercices = Database :: fetch_array($result_exercices)) {
  1096. $exercise_id = intval($exercices['id']);
  1097. $count_attempts = Tracking::count_student_exercise_attempts(
  1098. $student_id,
  1099. $courseInfo['real_id'],
  1100. $exercise_id,
  1101. 0,
  1102. 0,
  1103. $sessionId,
  1104. 2
  1105. );
  1106. $score_percentage = Tracking::get_avg_student_exercise_score(
  1107. $student_id,
  1108. $course_code,
  1109. $exercise_id,
  1110. $sessionId,
  1111. 1,
  1112. 0
  1113. );
  1114. if (!isset($score_percentage) && $count_attempts > 0) {
  1115. $scores_lp = Tracking::get_avg_student_exercise_score(
  1116. $student_id,
  1117. $course_code,
  1118. $exercise_id,
  1119. $sessionId,
  1120. 2,
  1121. 1
  1122. );
  1123. $score_percentage = $scores_lp[0];
  1124. $lp_name = $scores_lp[1];
  1125. } else {
  1126. $lp_name = '-';
  1127. }
  1128. $lp_name = !empty($lp_name) ? $lp_name : get_lang('NoLearnpath');
  1129. if ($i % 2) {
  1130. $css_class = 'row_odd';
  1131. } else {
  1132. $css_class = 'row_even';
  1133. }
  1134. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  1135. echo '<td>';
  1136. if (!empty($lp_name)) {
  1137. echo $lp_name;
  1138. } else {
  1139. echo '-';
  1140. }
  1141. echo '</td>';
  1142. echo '<td>';
  1143. if ($count_attempts > 0) {
  1144. echo $score_percentage.'%';
  1145. } else {
  1146. echo '-';
  1147. $score_percentage = 0;
  1148. }
  1149. echo '</td>';
  1150. echo '<td>'.$count_attempts.'</td>';
  1151. echo '<td>';
  1152. $sql = 'SELECT exe_id FROM '.$tbl_stats_exercices.'
  1153. WHERE
  1154. exe_exo_id = "'.$exercise_id.'" AND
  1155. exe_user_id ="'.$student_id.'" AND
  1156. c_id = '.$courseInfo['real_id'].' AND
  1157. session_id = "'.$sessionId.'" AND
  1158. status = ""
  1159. ORDER BY exe_date DESC
  1160. LIMIT 1';
  1161. $result_last_attempt = Database::query($sql);
  1162. if (Database :: num_rows($result_last_attempt) > 0) {
  1163. $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
  1164. if ($count_attempts > 0) {
  1165. 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).'">
  1166. '.Display::return_icon('quiz.png').'
  1167. </a>';
  1168. }
  1169. }
  1170. echo '</td>';
  1171. echo '<td>';
  1172. if ($count_attempts > 0) {
  1173. $all_attempt_url = "../exercise/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$sessionId";
  1174. echo Display::url(
  1175. Display::return_icon(
  1176. 'test_results.png',
  1177. get_lang('AllAttempts'),
  1178. array(),
  1179. ICON_SIZE_SMALL
  1180. ),
  1181. $all_attempt_url
  1182. );
  1183. }
  1184. echo '</td>';
  1185. echo '</tr>';
  1186. $data_exercices[$i][] = $exercices['title'];
  1187. $data_exercices[$i][] = $score_percentage.'%';
  1188. $data_exercices[$i][] = $count_attempts;
  1189. $csv_content[] = array(
  1190. $exercices['title'],
  1191. $lp_name,
  1192. $score_percentage,
  1193. $count_attempts
  1194. );
  1195. $i++;
  1196. }
  1197. } else {
  1198. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  1199. }
  1200. ?>
  1201. </tbody>
  1202. </table>
  1203. </div>
  1204. <?php
  1205. }
  1206. // @when using sessions we do not show the survey list
  1207. if (empty($sessionId)) {
  1208. $survey_list = SurveyManager::get_surveys($course_code, $sessionId);
  1209. $survey_data = array();
  1210. foreach ($survey_list as $survey) {
  1211. $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $courseInfo['real_id']);
  1212. $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
  1213. if (in_array($student_id, $user_list)) {
  1214. $survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
  1215. }
  1216. $data = array('title' => $survey['title'], 'done' => $survey_done);
  1217. $survey_data[] = $data;
  1218. }
  1219. if (!empty($survey_list)) {
  1220. $table = new HTML_Table(array('class' => 'data_table'));
  1221. $header_names = array(get_lang('Survey'), get_lang('Answered'));
  1222. $row = 0;
  1223. $column = 0;
  1224. foreach ($header_names as $item) {
  1225. $table->setHeaderContents($row, $column, $item);
  1226. $column++;
  1227. }
  1228. $row = 1;
  1229. if (!empty($survey_data)) {
  1230. foreach ($survey_data as $data) {
  1231. $column = 0;
  1232. $table->setCellContents($row, $column, $data);
  1233. $class = 'class="row_odd"';
  1234. if ($row % 2) {
  1235. $class = 'class="row_even"';
  1236. }
  1237. $table->setRowAttributes($row, $class, true);
  1238. $column++;
  1239. $row++;
  1240. }
  1241. }
  1242. echo $table->toHtml();
  1243. }
  1244. }
  1245. require_once '../work/work.lib.php';
  1246. $userWorks = getWorkPerUser($student_id, $courseInfo['real_id'], $sessionId);
  1247. echo '
  1248. <div class="table-responsive">
  1249. <table class="table table-striped table-hover">
  1250. <thead>
  1251. <tr>
  1252. <th>' . get_lang('Tasks').'</th>
  1253. <th class="text-center">' . get_lang('DocumentNumber').'</th>
  1254. <th class="text-center">' . get_lang('Note').'</th>
  1255. <th class="text-center">' . get_lang('HandedOut').'</th>
  1256. <th class="text-center">' . get_lang('HandOutDateLimit').'</th>
  1257. <th class="text-center">' . get_lang('ConsideredWorkingTime').'</th>
  1258. </tr>
  1259. </thead>
  1260. <tbody>
  1261. ';
  1262. $workingTime = api_get_configuration_value('considered_working_time');
  1263. foreach ($userWorks as $work) {
  1264. $work = $work['work'];
  1265. foreach ($work->user_results as $key => $results) {
  1266. echo '<tr>';
  1267. echo '<td>'.$work->title.'</td>';
  1268. $documentNumber = $key + 1;
  1269. 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>';
  1270. $qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
  1271. echo '<td class="text-center">'.$qualification.'</td>';
  1272. echo '<td class="text-center">'.$results['formatted_date'].'</td>';
  1273. $assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']);
  1274. echo '<td class="text-center">';
  1275. if (!empty($assignment['expires_on'])) {
  1276. echo api_convert_and_format_date($assignment['expires_on']);
  1277. }
  1278. echo '</td>';
  1279. $fieldValue = new ExtraFieldValue('work');
  1280. $resultExtra = $fieldValue->getAllValuesForAnItem(
  1281. $work->iid,
  1282. true
  1283. );
  1284. foreach ($resultExtra as $field) {
  1285. $field = $field['value'];
  1286. if ($workingTime == $field->getField()->getVariable()) {
  1287. echo '<td class="text-center">'.$field->getValue().'</td>';
  1288. }
  1289. }
  1290. echo '</tr>';
  1291. }
  1292. }
  1293. echo '</tbody>
  1294. </table>
  1295. </div>
  1296. ';
  1297. // line about other tools
  1298. ?>
  1299. <div class="table-responsive">
  1300. <table class="table table-striped table-hover">
  1301. <thead>
  1302. <tr>
  1303. <th colspan="2"><?php echo get_lang('OtherTools'); ?></th>
  1304. </tr>
  1305. </thead>
  1306. <tbody>
  1307. <?php
  1308. $csv_content[] = array();
  1309. $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $sessionId);
  1310. $messages = Tracking::count_student_messages($student_id, $course_code, $sessionId);
  1311. $links = Tracking::count_student_visited_links($student_id, $courseInfo['real_id'], $sessionId);
  1312. $chat_last_connection = Tracking::chat_last_connection($student_id, $courseInfo['real_id'], $sessionId);
  1313. $documents = Tracking::count_student_downloaded_documents($student_id, $courseInfo['real_id'], $sessionId);
  1314. $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $sessionId);
  1315. $csv_content[] = array(
  1316. get_lang('OtherTools')
  1317. );
  1318. $csv_content[] = array(
  1319. get_lang('Student_publication'),
  1320. $nb_assignments
  1321. );
  1322. $csv_content[] = array(
  1323. get_lang('Messages'),
  1324. $messages
  1325. );
  1326. $csv_content[] = array(
  1327. get_lang('LinksDetails'),
  1328. $links
  1329. );
  1330. $csv_content[] = array(
  1331. get_lang('DocumentsDetails'),
  1332. $documents
  1333. );
  1334. $csv_content[] = array(
  1335. get_lang('UploadedDocuments'),
  1336. $uploaded_documents
  1337. );
  1338. $csv_content[] = array(
  1339. get_lang('ChatLastConnection'),
  1340. $chat_last_connection
  1341. );
  1342. ?>
  1343. <tr><!-- assignments -->
  1344. <td width="40%"><?php echo get_lang('Student_publication') ?></td>
  1345. <td><?php echo $nb_assignments ?></td>
  1346. </tr>
  1347. <tr><!-- messages -->
  1348. <td><?php echo get_lang('Forum').' - '.get_lang('NumberOfPostsForThisUser') ?></td>
  1349. <td><?php echo $messages ?></td>
  1350. </tr>
  1351. <tr><!-- links -->
  1352. <td><?php echo get_lang('LinksDetails') ?></td>
  1353. <td><?php echo $links ?></td>
  1354. </tr>
  1355. <tr><!-- downloaded documents -->
  1356. <td><?php echo get_lang('DocumentsDetails') ?></td>
  1357. <td><?php echo $documents ?></td>
  1358. </tr>
  1359. <tr><!-- uploaded documents -->
  1360. <td><?php echo get_lang('UploadedDocuments') ?></td>
  1361. <td><?php echo $uploaded_documents ?></td>
  1362. </tr>
  1363. <tr><!-- Chats -->
  1364. <td><?php echo get_lang('ChatLastConnection') ?></td>
  1365. <td><?php echo $chat_last_connection; ?></td>
  1366. </tr>
  1367. </tbody>
  1368. </table>
  1369. </div>
  1370. <?php
  1371. } //end details
  1372. echo Tracking::displayUserSkills(
  1373. $user_info['user_id'],
  1374. $courseInfo ? $courseInfo['real_id'] : 0,
  1375. $sessionId
  1376. );
  1377. }
  1378. if ($export) {
  1379. ob_end_clean();
  1380. switch ($export) {
  1381. case 'csv':
  1382. Export::arrayToCsv($csv_content, 'reporting_student');
  1383. break;
  1384. case 'xls':
  1385. Export::arrayToXls($csv_content, 'reporting_student');
  1386. break;
  1387. }
  1388. exit;
  1389. }
  1390. Display :: display_footer();