myStudents.php 59 KB

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