myStudents.php 58 KB

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