myStudents.php 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. <?php
  2. //$Id: myStudents.php 21874 2009-07-08 08:45:18Z herodoto $
  3. /* For licensing terms, see /dokeos_license.txt */
  4. /**
  5. * Implements the tracking of students in the Reporting pages
  6. * @package dokeos.mySpace
  7. */
  8. // name of the language file that needs to be included
  9. $language_file = array('registration', 'index', 'tracking', 'exercice', 'admin');
  10. require '../inc/global.inc.php';
  11. require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  13. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  14. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  15. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  16. require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
  17. require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
  18. $htmlHeadXtra[] = '<script type="text/javascript">
  19. function show_image(image,width,height) {
  20. width = parseInt(width) + 20;
  21. height = parseInt(height) + 20;
  22. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
  23. }
  24. </script>';
  25. $export_csv = isset ($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  26. if ($export_csv) {
  27. ob_start();
  28. }
  29. $csv_content = array ();
  30. $from_myspace = false;
  31. if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
  32. $from_myspace = true;
  33. $this_section = "session_my_space";
  34. } else {
  35. $this_section = SECTION_COURSES;
  36. }
  37. $nameTools = get_lang("StudentDetails");
  38. //$nameTools = SECTION_PLATFORM_ADMIN;
  39. $cidReset = true;
  40. $get_course_code = Security :: remove_XSS($_GET['course']);
  41. if (isset ($_GET['details'])) {
  42. if (!empty ($_GET['origin']) && $_GET['origin'] == 'user_course') {
  43. $course_info = CourseManager :: get_course_information($get_course_code);
  44. if (empty ($cidReq)) {
  45. $interbreadcrumb[] = array (
  46. "url" => api_get_path(WEB_COURSE_PATH) . $course_info['directory'],
  47. 'name' => $course_info['title']
  48. );
  49. }
  50. $interbreadcrumb[] = array (
  51. "url" => "../user/user.php?cidReq=" . $get_course_code,
  52. "name" => get_lang("Users")
  53. );
  54. } else
  55. if (!empty ($_GET['origin']) && $_GET['origin'] == 'tracking_course') {
  56. $course_info = CourseManager :: get_course_information($get_course_code);
  57. if (empty ($cidReq)) {
  58. //$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['title']);
  59. }
  60. $interbreadcrumb[] = array (
  61. "url" => "../tracking/courseLog.php?cidReq=" . $get_course_code . '&studentlist=true&id_session=' . (empty ($_SESSION['id_session']) ? '' : $_SESSION['id_session']),
  62. "name" => get_lang("Tracking")
  63. );
  64. } else
  65. if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  66. $interbreadcrumb[] = array (
  67. 'url' => '../admin/index.php',
  68. "name" => get_lang('PlatformAdmin')
  69. );
  70. $interbreadcrumb[] = array (
  71. 'url' => "../admin/session_list.php",
  72. "name" => get_lang('SessionList')
  73. );
  74. $interbreadcrumb[] = array (
  75. 'url' => "../admin/resume_session.php?id_session=" . Security :: remove_XSS($_GET['id_session']),
  76. "name" => get_lang('SessionOverview')
  77. );
  78. } else {
  79. $interbreadcrumb[] = array (
  80. "url" => "index.php",
  81. "name" => get_lang('MySpace')
  82. );
  83. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  84. $interbreadcrumb[] = array (
  85. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  86. "name" => get_lang("CoachStudents")
  87. );
  88. $interbreadcrumb[] = array (
  89. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']) . '&id_coach=' . Security :: remove_XSS($_GET['id_coach']),
  90. "name" => get_lang("StudentDetails")
  91. );
  92. } else {
  93. $interbreadcrumb[] = array (
  94. "url" => "student.php",
  95. "name" => get_lang("MyStudents")
  96. );
  97. $interbreadcrumb[] = array (
  98. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
  99. "name" => get_lang("StudentDetails")
  100. );
  101. }
  102. }
  103. $nameTools = get_lang("DetailsStudentInCourse");
  104. } else {
  105. if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  106. $interbreadcrumb[] = array (
  107. 'url' => '../admin/index.php',
  108. "name" => get_lang('PlatformAdmin')
  109. );
  110. $interbreadcrumb[] = array (
  111. 'url' => "../admin/session_list.php",
  112. "name" => get_lang('SessionList')
  113. );
  114. $interbreadcrumb[] = array (
  115. 'url' => "../admin/resume_session.php?id_session=" . Security :: remove_XSS($_GET['id_session']),
  116. "name" => get_lang('SessionOverview')
  117. );
  118. } else {
  119. $interbreadcrumb[] = array (
  120. "url" => "index.php",
  121. "name" => get_lang('MySpace')
  122. );
  123. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  124. if (isset ($_GET['id_session']) && intval($_GET['id_session']) != 0) {
  125. $interbreadcrumb[] = array (
  126. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']) . "&id_session=" . $_GET['id_session'],
  127. "name" => get_lang("CoachStudents")
  128. );
  129. } else {
  130. $interbreadcrumb[] = array (
  131. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  132. "name" => get_lang("CoachStudents")
  133. );
  134. }
  135. } else {
  136. $interbreadcrumb[] = array (
  137. "url" => "student.php",
  138. "name" => get_lang("MyStudents")
  139. );
  140. }
  141. }
  142. }
  143. api_block_anonymous_users();
  144. if (!api_is_allowed_to_edit() && !api_is_coach() && $_user['status'] != DRH && $_user['status'] != SESSIONADMIN && !api_is_platform_admin(true)) {
  145. api_not_allowed(true);
  146. }
  147. Display :: display_header($nameTools);
  148. /*
  149. * ======================================================================================
  150. * FUNCTIONS
  151. * ======================================================================================
  152. */
  153. function is_teacher($course_code) {
  154. global $_user;
  155. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  156. $sql = "SELECT 1 FROM $tbl_course_user WHERE user_id='" . $_user["user_id"] . "' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." AND course_code='" . Database :: escape_string($course_code) . "' AND status='1'";
  157. $result = Database::query($sql);
  158. if (Database :: result($result) != 1) {
  159. return true;
  160. } else {
  161. return false;
  162. }
  163. }
  164. /*
  165. *===============================================================================
  166. * MAIN CODE
  167. *===============================================================================
  168. */
  169. // Database Table Definitions
  170. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  171. $tbl_session_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
  172. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  173. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  174. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  175. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  176. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  177. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  178. $tbl_stats_exercices_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  179. //$tbl_course_lp_view = Database :: get_course_table(TABLE_LP_VIEW);
  180. //$tbl_course_lp_view_item = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
  181. //$tbl_course_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
  182. $tbl_course_lp_view = 'lp_view';
  183. $tbl_course_lp_view_item = 'lp_item_view';
  184. $tbl_course_lp_item = 'lp_item';
  185. $tbl_course_lp = 'lp';
  186. $tbl_course_quiz = 'quiz';
  187. $course_quiz_question = 'quiz_question';
  188. $course_quiz_rel_question = 'quiz_rel_question';
  189. $course_quiz_answer = 'quiz_answer';
  190. $course_student_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
  191. if (isset ($_GET["user_id"]) && $_GET["user_id"] != "") {
  192. $user_id = intval($_GET['user_id']);
  193. } else {
  194. $user_id = $_user['user_id'];
  195. }
  196. if (!empty ($_GET['student'])) {
  197. $student_id = intval($_GET['student']);
  198. // infos about user
  199. $info_user = UserManager :: get_user_info_by_id($student_id);
  200. if ($_user['status'] == DRH && $info_user['hr_dept_id'] != $_user['user_id']) {
  201. api_not_allowed();
  202. }
  203. $info_user['name'] = api_get_person_name($info_user['firstname'], $info_user['lastname']);
  204. // Actions bar
  205. echo '<div class="actions">';
  206. echo '<a href="javascript: void(0);" onclick="javascript: window.print();"><img src="../img/printmgr.gif">&nbsp;' . get_lang('Print') . '</a>';
  207. echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv"><img src="../img/excel.gif">&nbsp;' . get_lang('ExportAsCSV') . '</a>';
  208. if (!empty ($info_user['email'])) {
  209. $send_mail = Display :: return_icon('send_mail.gif', get_lang('SendMail')) . ' ' . Display :: encrypted_mailto_link($info_user['email'], get_lang('SendMail'));
  210. } else {
  211. $send_mail = Display :: return_icon('send_mail.gif', get_lang('SendMail')) . ' ' . get_lang('SendMail');
  212. }
  213. echo $send_mail;
  214. if (!empty ($_GET['student']) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL
  215. echo '<a href="access_details.php?student=' . Security :: remove_XSS($_GET['student']) . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq=' . Security :: remove_XSS($_GET['course']) . '">' . Display :: return_icon('statistics.gif', get_lang('AccessDetails')) . ' ' . get_lang('AccessDetails') . '</a>';
  216. }
  217. echo '</div>';
  218. // is the user online ?
  219. $student_online = Security :: remove_XSS($_GET['student']);
  220. $users_online = WhoIsOnline(30);
  221. foreach ($users_online as $online) {
  222. if (in_array($_GET['student'], $online)) {
  223. $online = get_lang('Yes');
  224. break;
  225. } else {
  226. $online = get_lang('No');
  227. }
  228. }
  229. $avg_student_progress = $avg_student_score = $nb_courses = 0;
  230. $sql = 'SELECT course_code FROM ' . $tbl_course_user . ' WHERE relation_type<>'.COURSE_RELATION_TYPE_RRHH.' AND user_id=' . Database :: escape_string($info_user['user_id']);
  231. $rs = Database::query($sql);
  232. $courses = array ();
  233. while ($row = Database :: fetch_array($rs)) {
  234. $courses[$row['course_code']] = $row['course_code'];
  235. }
  236. // get the list of sessions where the user is subscribed as student
  237. $sql = 'SELECT DISTINCT course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($info_user['user_id']);
  238. $rs = Database::query($sql);
  239. while ($row = Database :: fetch_array($rs)) {
  240. $courses[$row['course_code']] = $row['course_code'];
  241. }
  242. $course_id = Security :: remove_XSS($_GET['course']);
  243. if (!CourseManager :: is_user_subscribed_in_course($info_user['user_id'], $course_id, true)) {
  244. unset ($courses[$key]);
  245. } else {
  246. $nb_courses++;
  247. $avg_student_progress = Tracking :: get_avg_student_progress($info_user['user_id'], $course_id);
  248. //the score inside the Reporting table
  249. $avg_student_score = Tracking :: get_average_test_scorm_and_lp($info_user['user_id'], $course_id);
  250. }
  251. $avg_student_progress = round($avg_student_progress, 2);
  252. $avg_student_score = round($avg_student_score, 2);
  253. $first_connection_date = Tracking :: get_first_connection_date($info_user['user_id']);
  254. if ($first_connection_date == '') {
  255. $first_connection_date = get_lang('NoConnexion');
  256. }
  257. $last_connection_date = Tracking :: get_last_connection_date($info_user['user_id'], true);
  258. if ($last_connection_date == '') {
  259. $last_connection_date = get_lang('NoConnexion');
  260. }
  261. $time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_id));
  262. // cvs informations
  263. $csv_content[] = array (
  264. get_lang('Informations', '')
  265. );
  266. $csv_content[] = array (
  267. get_lang('Name', ''),
  268. get_lang('Email', ''),
  269. get_lang('Tel', '')
  270. );
  271. $csv_content[] = array (
  272. $info_user['name'],
  273. $info_user['email'],
  274. $info_user['phone']
  275. );
  276. $csv_content[] = array ();
  277. // csv tracking
  278. $csv_content[] = array (
  279. get_lang('Tracking', '')
  280. );
  281. $csv_content[] = array (
  282. get_lang('FirstLogin', ''),
  283. get_lang('LatestLogin', ''),
  284. get_lang('TimeSpentInTheCourse', ''),
  285. get_lang('Progress', ''),
  286. get_lang('Score', '')
  287. );
  288. $csv_content[] = array (
  289. strip_tags($first_connection_date),
  290. strip_tags($last_connection_date),
  291. $time_spent_on_the_course,
  292. $avg_student_progress . '%',
  293. $avg_student_score . '%'
  294. );
  295. ?>
  296. <a name="infosStudent"></a>
  297. <table width="100%" border="0" >
  298. <tr>
  299. <?php
  300. $image_array = UserManager :: get_user_picture_path_by_id($info_user['user_id'], 'web', false, true);
  301. echo '<td class="borderRight" width="10%" valign="top">';
  302. // get the path,width and height from original picture
  303. $image_file = $image_array['dir'] . $image_array['file'];
  304. $big_image = $image_array['dir'] . 'big_' . $image_array['file'];
  305. $big_image_size = api_getimagesize($big_image);
  306. $big_image_width = $big_image_size[0];
  307. $big_image_height = $big_image_size[1];
  308. $url_big_image = $big_image . '?rnd=' . time();
  309. $img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' .
  310. 'alt="' . api_get_person_name($info_user['lastname'], $info_user['firstname']) . '" ' .
  311. 'style="float:' . ($text_dir == 'rtl' ? 'left' : 'right') . '; padding:5px;" ';
  312. if ($image_array['file'] == 'unknown.jpg') {
  313. echo '<img ' . $img_attributes . ' />';
  314. } else {
  315. echo '<input type="image" ' . $img_attributes . ' onclick="javascript: return show_image(\'' . $url_big_image . '\',\'' . $big_image_width . '\',\'' . $big_image_height . '\');"/>';
  316. }
  317. echo '</td>';
  318. ?>
  319. <td width="40%" valign="top">
  320. <table width="100%" class="data_table">
  321. <tr>
  322. <th>
  323. <?php echo get_lang('Information'); ?>
  324. </th>
  325. </tr>
  326. <tr>
  327. <td>
  328. <?php
  329. echo get_lang('Name') . ' : ';
  330. echo $info_user['name'];
  331. ?>
  332. </td>
  333. </tr>
  334. <tr>
  335. <td>
  336. <?php
  337. echo get_lang('Email') . ' : ';
  338. if (!empty ($info_user['email'])) {
  339. echo '<a href="mailto:' . $info_user['email'] . '">' . $info_user['email'] . '</a>';
  340. } else {
  341. echo get_lang('NoEmail');
  342. }
  343. ?>
  344. </td>
  345. </tr>
  346. <tr>
  347. <td>
  348. <?php
  349. echo get_lang('Tel') . ' : ';
  350. if (!empty ($info_user['phone'])) {
  351. echo $info_user['phone'];
  352. } else {
  353. echo get_lang('NoTel');
  354. }
  355. ?>
  356. </td>
  357. </tr>
  358. <tr>
  359. <td>
  360. <?php
  361. echo get_lang('OfficialCode') . ' : ';
  362. if (!empty ($info_user['official_code'])) {
  363. echo $info_user['official_code'];
  364. } else {
  365. echo get_lang('NoOfficialCode');
  366. }
  367. ?>
  368. </td>
  369. </tr>
  370. <tr>
  371. <td>
  372. <?php
  373. echo get_lang('OnLine') . ' : ';
  374. echo $online;
  375. ?>
  376. </td>
  377. </tr>
  378. </table>
  379. </td>
  380. <td class="borderLeft" width="35%" valign="top">
  381. <table width="100%" class="data_table">
  382. <tr>
  383. <th colspan="2">
  384. <?php echo get_lang('Tracking'); ?>
  385. </th>
  386. </tr>
  387. <tr>
  388. <td align="right">
  389. <?php echo get_lang('FirstLogin') ?>
  390. </td>
  391. <td align="left">
  392. <?php echo $first_connection_date ?>
  393. </td>
  394. </tr>
  395. <tr>
  396. <td align="right">
  397. <?php echo get_lang('LatestLogin') ?>
  398. </td>
  399. <td align="left">
  400. <?php echo $last_connection_date ?>
  401. </td>
  402. </tr>
  403. <tr>
  404. <td align="right">
  405. <?php echo get_lang('TimeSpentInTheCourse') ?>
  406. </td>
  407. <td align="left">
  408. <?php echo $time_spent_on_the_course ?>
  409. </td>
  410. </tr>
  411. <tr>
  412. <td align="right">
  413. <?php
  414. echo get_lang('Progress');
  415. Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array (
  416. 'align' => 'absmiddle',
  417. 'hspace' => '3px'
  418. ));
  419. ?>
  420. </td>
  421. <td align="left">
  422. <?php echo $avg_student_progress.'%' ?>
  423. </td>
  424. </tr>
  425. <tr>
  426. <td align="right">
  427. <?php
  428. echo get_lang('Score');
  429. Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array (
  430. 'align' => 'absmiddle',
  431. 'hspace' => '3px'
  432. ));
  433. ?>
  434. </td>
  435. <td align="left">
  436. <?php echo $avg_student_score.'%' ?>
  437. </td>
  438. </tr>
  439. </table>
  440. </td>
  441. </tr>
  442. </table>
  443. <table class="data_table">
  444. <tr>
  445. <td colspan="5" style="border-width: 0px;">&nbsp;</td>
  446. </tr>
  447. <?php
  448. if (!empty ($_GET['details'])) {
  449. $course_code_info = Security :: remove_XSS($_GET['course']);
  450. $info_course = CourseManager :: get_course_information($course_code_info);
  451. //get coach and session_name if there is one and if session_mode is activated
  452. if (api_get_setting('use_session_mode') == 'true') {
  453. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  454. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  455. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  456. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  457. $sql = 'SELECT id_session
  458. FROM ' . $tbl_session_course_user . ' session_course_user
  459. WHERE session_course_user.id_user = ' . intval($info_user['user_id']) . '
  460. AND session_course_user.course_code = "' . Database :: escape_string($course_code_info) . '"
  461. ORDER BY id_session DESC';
  462. $rs = Database::query($sql);
  463. $num_row = Database :: num_rows($rs);
  464. if ($num_row > 0) {
  465. $le_session_id = intval(Database :: result($rs, 0, 0));
  466. if ($le_session_id > 0) {
  467. // get session name and coach of the session
  468. $sql = 'SELECT name, id_coach FROM ' . $tbl_session . '
  469. WHERE id=' . $le_session_id;
  470. $rs = Database::query($sql);
  471. $session_name = Database :: result($rs, 0, 'name');
  472. $session_coach_id = intval(Database :: result($rs, 0, 'id_coach'));
  473. // get coach of the course in the session
  474. $sql = 'SELECT id_user FROM ' . $tbl_session_course_user . '
  475. WHERE id_session=' . $le_session_id . '
  476. AND course_code = "' . Database :: escape_string($_GET['course']) . '" AND status=2';
  477. /*
  478. $sql = 'SELECT id_coach FROM ' . $tbl_session_course . '
  479. WHERE id_session=' . $le_session_id . '
  480. AND course_code = "' . Database :: escape_string($_GET['course']) . '"';
  481. */
  482. $rs = Database::query($sql);
  483. //$session_course_coach_id = intval(Database :: result($rs, 0, 0));
  484. $course_coachs = array();
  485. while ($row_coachs = Database::fetch_array($rs)) {
  486. $course_coachs[] = $row_coachs['id_user'];
  487. }
  488. if (!empty($course_coachs)) {
  489. $info_tutor_name = array();
  490. foreach ($course_coachs as $course_coach) {
  491. $coach_infos = UserManager :: get_user_info_by_id($course_coach);
  492. $info_tutor_name[] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
  493. }
  494. $info_course['tutor_name'] = implode(",",$info_tutor_name);
  495. }
  496. /*if ($session_course_coach_id != 0) {
  497. $coach_infos = UserManager :: get_user_info_by_id($session_course_coach_id);
  498. $info_course['tutor_name'] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
  499. }*/
  500. elseif ($session_coach_id != 0) {
  501. $coach_infos = UserManager :: get_user_info_by_id($session_coach_id);
  502. $info_course['tutor_name'] = api_get_person_name($coach_infos['firstname'], $coach_infos['lastname']);
  503. }
  504. }
  505. }
  506. } // end if(api_get_setting('use_session_mode')=='true')
  507. $date_start = '';
  508. if (!empty ($info_course['date_start'])) {
  509. $date_start = explode('-', $info_course['date_start']);
  510. $date_start = $date_start[2] . '/' . $date_start[1] . '/' . $date_start[0];
  511. }
  512. $date_end = '';
  513. if (!empty ($info_course['date_end'])) {
  514. $date_end = explode('-', $info_course['date_end']);
  515. $date_end = $date_end[2] . '/' . $date_end[1] . '/' . $date_end[0];
  516. }
  517. $dateSession = get_lang('From') . ' ' . $date_start . ' ' . get_lang('To') . ' ' . $date_end;
  518. $nb_login = Tracking :: count_login_per_student($info_user['user_id'], $_GET['course']);
  519. $table_title = $info_course['title'] . '&nbsp;|&nbsp;' . get_lang('CountToolAccess') . ' : ' . $nb_login . '&nbsp; | &nbsp;' . get_lang('Tutor') . ' : ' . stripslashes($info_course['tutor_name']) . ((!empty ($session_name)) ? ' | ' . get_lang('Session') . ' : ' . $session_name : '');
  520. $csv_content[] = array ();
  521. $csv_content[] = array (str_replace('&nbsp;', '', $table_title));
  522. ?>
  523. <tr>
  524. <td colspan="6">
  525. <strong><?php echo $table_title; ?></strong>
  526. </td>
  527. </tr>
  528. </table>
  529. <!-- line about learnpaths -->
  530. <table class="data_table">
  531. <tr>
  532. <th>
  533. <?php echo get_lang('Learnpaths');?>
  534. </th>
  535. <th>
  536. <?php
  537. echo get_lang('Time');
  538. Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array (
  539. 'align' => 'absmiddle',
  540. 'hspace' => '3px'
  541. ));
  542. ?>
  543. </th>
  544. <th>
  545. <?php
  546. echo get_lang('Score');
  547. Display :: display_icon('info3.gif', get_lang('LPTestScore'), array (
  548. 'align' => 'absmiddle',
  549. 'hspace' => '3px'
  550. ));
  551. ?>
  552. </th>
  553. <th>
  554. <?php
  555. echo get_lang('Progress');
  556. Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array (
  557. 'align' => 'absmiddle',
  558. 'hspace' => '3px'
  559. ));
  560. ?>
  561. </th>
  562. <th>
  563. <?php
  564. echo get_lang('LastConnexion');
  565. Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array (
  566. 'align' => 'absmiddle',
  567. 'hspace' => '3px'
  568. ));
  569. ?>
  570. </th>
  571. <th>
  572. <?php echo get_lang('Details');?>
  573. </th>
  574. </tr>
  575. <?php
  576. $headerLearnpath = array (
  577. get_lang('Learnpath'),
  578. get_lang('Time'),
  579. get_lang('Progress'),
  580. get_lang('LastConnexion')
  581. );
  582. $t_lp = Database :: get_course_table(TABLE_LP_MAIN, $info_course['db_name']);
  583. $t_lpi = Database :: get_course_table(TABLE_LP_ITEM, $info_course['db_name']);
  584. $t_lpv = Database :: get_course_table(TABLE_LP_VIEW, $info_course['db_name']);
  585. $t_lpiv = Database :: get_course_table(TABLE_LP_ITEM_VIEW, $info_course['db_name']);
  586. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  587. $tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  588. $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION, $info_course['db_name']);
  589. $sql_learnpath = " SELECT lp.name,lp.id
  590. FROM $t_lp AS lp ORDER BY lp.name ASC";
  591. $result_learnpath = Database::query($sql_learnpath);
  592. $csv_content[] = array ();
  593. $csv_content[] = array (
  594. get_lang('Learnpath', ''),
  595. get_lang('Time', ''),
  596. get_lang('Score', ''),
  597. get_lang('Progress', ''),
  598. get_lang('LastConnexion', '')
  599. );
  600. if (Database :: num_rows($result_learnpath) > 0) {
  601. $i = 0;
  602. while ($learnpath = Database :: fetch_array($result_learnpath)) {
  603. $any_result = false;
  604. $progress = learnpath :: get_db_progress($learnpath['id'], $student_id, '%', $info_course['db_name'], true);
  605. if ($progress === null) {
  606. $progress = '0%';
  607. } else {
  608. $any_result = true;
  609. }
  610. // calculates time
  611. $sql = 'SELECT SUM(total_time)
  612. FROM ' . $t_lpiv . ' AS item_view
  613. INNER JOIN ' . $t_lpv . ' AS view
  614. ON item_view.lp_view_id = view.id
  615. AND view.lp_id = ' . $learnpath['id'] . '
  616. AND view.user_id = ' . intval($_GET['student']);
  617. $rs = Database::query($sql);
  618. $total_time = 0;
  619. if (Database :: num_rows($rs) > 0) {
  620. $total_time = Database :: result($rs, 0, 0);
  621. if ($total_time > 0)
  622. $any_result = true;
  623. }
  624. // calculates last connection time
  625. $sql = 'SELECT MAX(start_time)
  626. FROM ' . $t_lpiv . ' AS item_view
  627. INNER JOIN ' . $t_lpv . ' AS view
  628. ON item_view.lp_view_id = view.id
  629. AND view.lp_id = ' . $learnpath['id'] . '
  630. AND view.user_id = ' . intval($_GET['student']);
  631. $rs = Database::query($sql);
  632. $start_time = null;
  633. if (Database :: num_rows($rs) > 0) {
  634. $start_time = Database :: result($rs, 0, 0);
  635. if ($start_time > 0)
  636. $any_result = true;
  637. }
  638. //QUIZZ IN LP
  639. $score = Tracking :: get_avg_student_score(intval($_GET['student']), Database :: escape_string($_GET['course']), array (
  640. $learnpath['id']
  641. ));
  642. if (empty ($score)) {
  643. //$score = 0;
  644. }
  645. if ($i % 2 == 0) {
  646. $css_class = "row_odd";
  647. } else {
  648. $css_class = "row_even";
  649. }
  650. $i++;
  651. $csv_content[] = array (
  652. api_html_entity_decode(stripslashes($learnpath['name']), ENT_QUOTES, $charset),
  653. api_time_to_hms($total_time),
  654. $score . '%',
  655. $progress,
  656. date('Y-m-d', $start_time)
  657. );
  658. ?>
  659. <tr class="<?php echo $css_class;?>">
  660. <td>
  661. <?php echo stripslashes($learnpath['name']); ?>
  662. </td>
  663. <td align="center">
  664. <?php echo api_time_to_hms($total_time) ?>
  665. </td>
  666. <td align="center">
  667. <?php
  668. if (!is_null($score)) {
  669. echo $score . '%';
  670. } else {
  671. if ('0' == $progress {
  672. 0 }) {
  673. echo '/';
  674. } else {
  675. echo '0%';
  676. }
  677. $score = 0;
  678. }
  679. ?>
  680. </td>
  681. <td align="center">
  682. <?php echo $progress ?>
  683. </td>
  684. <td align="center">
  685. <?php
  686. if ($start_time != '' && $start_time > 0) {
  687. echo format_locale_date(get_lang('DateFormatLongWithoutDay'), $start_time);
  688. } else {
  689. echo '-';
  690. }
  691. ?>
  692. </td>
  693. <td align="center">
  694. <?php
  695. if ($any_result === true) {
  696. $from = '';
  697. if ($from_myspace) {
  698. $from ='&from=myspace';
  699. }
  700. ?>
  701. <a href="lp_tracking.php?course=<?php echo Security::remove_XSS($_GET['course']).$from; ?>&origin=<?php echo Security::remove_XSS($_GET['origin']) ?>&lp_id=<?php echo $learnpath['id']?>&student_id=<?php echo $info_user['user_id'] ?>">
  702. <img src="../img/2rightarrow.gif" border="0" />
  703. </a>
  704. <?php
  705. }
  706. ?>
  707. </td>
  708. </tr>
  709. <?php
  710. $data_learnpath[$i][] = $learnpath['name'];
  711. $data_learnpath[$i][] = $progress . '%';
  712. $i++;
  713. }
  714. } else {
  715. echo " <tr>
  716. <td colspan='6'>
  717. " . get_lang('NoLearnpath') . "
  718. </td>
  719. </tr>
  720. ";
  721. }
  722. ?>
  723. </table>
  724. <!-- line about exercises -->
  725. <table class="data_table">
  726. <tr>
  727. <th>
  728. <?php echo get_lang('Exercices'); ?>
  729. </th>
  730. <th>
  731. <?php echo get_lang('Score').Display :: return_icon('info3.gif', get_lang('LastScoreTest'), array('align' => 'absmiddle', 'hspace' => '3px')) ?>
  732. </th>
  733. <th>
  734. <?php echo get_lang('Attempts'); ?>
  735. </th>
  736. <th>
  737. <?php echo get_lang('CorrectTest'); ?>
  738. </th>
  739. </tr>
  740. <?php
  741. $csv_content[] = array ();
  742. $csv_content[] = array (
  743. get_lang('Exercices'),
  744. get_lang('Score'),
  745. get_lang('Attempts')
  746. );
  747. $info_course = CourseManager :: get_course_information(Security :: remove_XSS($_GET['course']));
  748. $t_tool = Database :: get_course_table(TABLE_TOOL_LIST, $info_course['db_name']);
  749. $sql = 'SELECT visibility FROM ' . $t_tool . ' WHERE name="quiz"';
  750. $result_visibility_quizz = Database::query($sql);
  751. $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST, $info_course['db_name']);
  752. if (Database :: result($result_visibility_quizz, 0, 'visibility') == 1) {
  753. $sql_exercices = "SELECT quiz.title,id
  754. FROM " . $t_quiz . " AS quiz
  755. WHERE active='1' ORDER BY quiz.title ASC
  756. ";
  757. $result_exercices = Database::query($sql_exercices);
  758. $i = 0;
  759. $is_student = Security :: remove_XSS($_GET['student']);
  760. if (Database :: num_rows($result_exercices) > 0) {
  761. while ($exercices = Database :: fetch_array($result_exercices)) {
  762. $sql_essais = "SELECT COUNT(ex.exe_id) as essais
  763. FROM $tbl_stats_exercices AS ex
  764. WHERE ex.exe_cours_id = '" . $info_course['code'] . "'
  765. AND ex.exe_exo_id = " . $exercices['id'] . "
  766. AND orig_lp_id = 0
  767. AND orig_lp_item_id = 0
  768. AND exe_user_id='" . Database :: escape_string($is_student) . "'";
  769. $result_essais = Database::query($sql_essais);
  770. $essais = Database :: fetch_array($result_essais);
  771. $sql_score = "SELECT exe_id, exe_result,exe_weighting
  772. FROM $tbl_stats_exercices
  773. WHERE exe_user_id = " . Database :: escape_string($is_student) . "
  774. AND exe_cours_id = '" . $info_course['code'] . "'
  775. AND exe_exo_id = " . $exercices['id'] . "
  776. AND orig_lp_id = 0
  777. AND orig_lp_item_id = 0
  778. ORDER BY exe_date DESC LIMIT 1";
  779. $result_score = Database::query($sql_score);
  780. $score = 0;
  781. while ($scores = Database :: fetch_array($result_score)) {
  782. $score = $score + $scores['exe_result'];
  783. $weighting = $weighting + $scores['exe_weighting'];
  784. $exe_id = $scores['exe_id'];
  785. }
  786. $score_percentage = 0;
  787. if ($weighting != 0) {
  788. //i.e 10.50
  789. $score_percentage = round(($score * 100) / $weighting, 2);
  790. } else {
  791. $score_percentage = null;
  792. }
  793. $weighting = 0;
  794. $csv_content[] = array (
  795. $exercices['title'],
  796. $score_percentage . '%',
  797. $essais['essais']
  798. );
  799. if ($i % 2 == 0) {
  800. $css_class = "row_odd";
  801. } else {
  802. $css_class = "row_even";
  803. }
  804. $i++;
  805. echo '<tr class="' . $css_class . '">
  806. <td>
  807. ';
  808. echo $exercices['title'];
  809. echo " </td>
  810. ";
  811. echo " <td align='center'>
  812. ";
  813. if ($essais['essais'] > 0) {
  814. echo $score_percentage . '%';
  815. } else {
  816. echo '/';
  817. $score_percentage = 0;
  818. }
  819. echo " </td>
  820. <td align='center'>
  821. ";
  822. echo $essais['essais'];
  823. echo " </td>
  824. <td align='center'>
  825. ";
  826. $sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $exercices['id'] . '" AND exe_user_id="' . Security :: remove_XSS($_GET['student']) . '" AND exe_cours_id="' . $info_course['code'] . '" AND orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY exe_date DESC LIMIT 1';
  827. $result_last_attempt = Database::query($sql_last_attempt);
  828. if (Database :: num_rows($result_last_attempt) > 0) {
  829. $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
  830. if ($essais['essais'] > 0)
  831. echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq=' . $info_course['code'] . '&student=' . Security :: remove_XSS($_GET['student']) . '&origin=' . (empty ($_GET['origin']) ? 'tracking' : Security :: remove_XSS($_GET['origin'])) . '"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
  832. }
  833. echo " </td>
  834. </tr>
  835. ";
  836. $data_exercices[$i][] = $exercices['title'];
  837. $data_exercices[$i][] = $score_percentage . '%';
  838. $data_exercices[$i][] = $essais['essais'];
  839. //$data_exercices[$i][] = corrections;
  840. $i++;
  841. }
  842. } else {
  843. echo " <tr>
  844. <td colspan='6'>
  845. " . get_lang('NoExercise') . "
  846. </td>
  847. </tr>
  848. ";
  849. }
  850. } else {
  851. echo " <tr>
  852. <td colspan='6'>
  853. " . get_lang('NoExercise') . "
  854. </td>
  855. </tr>
  856. ";
  857. }
  858. ?>
  859. </table>
  860. <!-- line about other tools -->
  861. <table class="data_table">
  862. <tr>
  863. <td>
  864. <?php
  865. $csv_content[] = array ();
  866. $nb_assignments = Tracking :: count_student_assignments($info_user['user_id'], $info_course['code']);
  867. $messages = Tracking :: count_student_messages($info_user['user_id'], $info_course['code']);
  868. $links = Tracking :: count_student_visited_links($info_user['user_id'], $info_course['code']);
  869. $documents = Tracking :: count_student_downloaded_documents($info_user['user_id'], $info_course['code']);
  870. $chat_last_connection = Tracking :: chat_last_connection($info_user['user_id'], $info_course['code']);
  871. $csv_content[] = array (
  872. get_lang('Student_publication'),
  873. $nb_assignments
  874. );
  875. $csv_content[] = array (
  876. get_lang('Messages'),
  877. $messages
  878. );
  879. $csv_content[] = array (
  880. get_lang('LinksDetails'),
  881. $links
  882. );
  883. $csv_content[] = array (
  884. get_lang('DocumentsDetails'),
  885. $documents
  886. );
  887. $csv_content[] = array (
  888. get_lang('ChatLastConnection'),
  889. $chat_last_connection
  890. );
  891. ?>
  892. <tr>
  893. <th colspan="2">
  894. <?php echo get_lang('OtherTools'); ?>
  895. </th>
  896. </tr>
  897. <tr><!-- assignments -->
  898. <td width="40%">
  899. <?php echo get_lang('Student_publication') ?>
  900. </td>
  901. <td>
  902. <?php echo $nb_assignments ?>
  903. </td>
  904. </tr>
  905. <tr><!-- messages -->
  906. <td>
  907. <?php echo get_lang('Messages') ?>
  908. </td>
  909. <td>
  910. <?php echo $messages ?>
  911. </td>
  912. </tr>
  913. <tr><!-- links -->
  914. <td>
  915. <?php echo get_lang('LinksDetails') ?>
  916. </td>
  917. <td>
  918. <?php echo $links ?>
  919. </td>
  920. </tr>
  921. <tr><!-- documents -->
  922. <td>
  923. <?php echo get_lang('DocumentsDetails') ?>
  924. </td>
  925. <td>
  926. <?php echo $documents ?>
  927. </td>
  928. </tr>
  929. <tr><!-- Chats -->
  930. <td>
  931. <?php echo get_lang('ChatLastConnection') ?>
  932. </td>
  933. <td>
  934. <?php echo $chat_last_connection; ?>
  935. </td>
  936. </tr>
  937. </table>
  938. </td>
  939. </tr>
  940. </table>
  941. <?php
  942. } else {
  943. ?>
  944. <tr>
  945. <th>
  946. <?php echo get_lang('Course'); ?>
  947. </th>
  948. <th>
  949. <?php echo get_lang('Time'); ?>
  950. </th>
  951. <th>
  952. <?php echo get_lang('AttendanceFaults'); ?>
  953. </th>
  954. <th>
  955. <?php echo get_lang('Progress'); ?>
  956. </th>
  957. <th>
  958. <?php echo get_lang('Score'); ?>
  959. </th>
  960. <th>
  961. <?php echo get_lang('Details'); ?>
  962. </th>
  963. </tr>
  964. <?php
  965. if (!api_is_platform_admin(true) && $_user['status'] != DRH) {
  966. // courses followed by user where we are coach
  967. if (!isset ($_GET['id_coach'])) {
  968. $courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
  969. } else {
  970. $courses = Tracking :: get_courses_followed_by_coach(Security :: remove_XSS($_GET['id_coach']));
  971. }
  972. }
  973. if (count($courses) > 0) {
  974. $csv_content[] = array ();
  975. $csv_content[] = array (
  976. get_lang('Course', ''),
  977. get_lang('Time', ''),
  978. get_lang('AttendanceFaults', ''),
  979. get_lang('Progress', ''),
  980. get_lang('Score', '')
  981. );
  982. $attendance = new Attendance();
  983. foreach ($courses as $course_code) {
  984. if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
  985. $course_info = CourseManager :: get_course_information($course_code);
  986. $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($info_user['user_id'], $course_code));
  987. // get average of faults in attendances by student
  988. $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code);
  989. if (!empty($results_faults_avg)) {
  990. $attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  991. } else {
  992. $attendances_faults_avg = '0%';
  993. }
  994. $progress = Tracking :: get_avg_student_progress($info_user['user_id'], $course_code);
  995. $score = Tracking :: get_avg_student_score($info_user['user_id'], $course_code);
  996. $progress = empty($progress) ? '0%' : $progress.'%';
  997. $score = empty($score) ? '0%' : $score.'%';
  998. $csv_content[] = array (
  999. $course_info['title'],
  1000. $time_spent_on_course,
  1001. $progress,
  1002. $score
  1003. );
  1004. echo '
  1005. <tr>
  1006. <td align="right">
  1007. ' . $course_info['title'] . '
  1008. </td>
  1009. <td align="right">
  1010. ' . $time_spent_on_course . '
  1011. </td>
  1012. <td align="right">
  1013. '. $attendances_faults_avg . '
  1014. </td>
  1015. <td align="right">
  1016. ' . $progress . '
  1017. </td>
  1018. <td align="right">
  1019. ' . $score . '
  1020. </td>';
  1021. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  1022. echo '<td align="center" width="10">
  1023. <a href="' . api_get_self() . '?student=' . $info_user['user_id'] . '&details=true&course=' . $course_info['code'] . '&id_coach=' . Security :: remove_XSS($_GET['id_coach']) . '&origin=' . Security :: remove_XSS($_GET['origin']) . '&id_session=' . Security :: remove_XSS($_GET['id_session']) . '#infosStudent"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>
  1024. </td>';
  1025. } else {
  1026. echo '<td align="center" width="10">
  1027. <a href="' . api_get_self() . '?student=' . $info_user['user_id'] . '&details=true&course=' . $course_info['code'] . '&origin=' . Security :: remove_XSS($_GET['origin']) . '&id_session=' . Security :: remove_XSS($_GET['id_session']) . '#infosStudent"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>
  1028. </td>';
  1029. }
  1030. echo '</tr>';
  1031. }
  1032. }
  1033. } else {
  1034. echo "<tr>
  1035. <td colspan='5'>
  1036. " . get_lang('NoCourse') . "
  1037. </td>
  1038. </tr>
  1039. ";
  1040. }
  1041. } //end of else !empty($details)
  1042. ?>
  1043. </table>
  1044. <br />
  1045. <?php
  1046. if (!empty ($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course') {
  1047. ?>
  1048. <br /><br />
  1049. <?php
  1050. }
  1051. if (!empty ($_GET['exe_id'])) {
  1052. $t_q = Database :: get_course_table(TABLE_QUIZ_TEST, $info_course['db_name']);
  1053. $t_qq = Database :: get_course_table(TABLE_QUIZ_QUESTION, $info_course['db_name']);
  1054. $t_qa = Database :: get_course_table(TABLE_QUIZ_ANSWER, $info_course['db_name']);
  1055. $t_qtq = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION, $info_course['db_name']);
  1056. $sql_exercice_details = "SELECT qq.question, qq.ponderation, qq.id
  1057. FROM " . $t_qq . " as qq
  1058. INNER JOIN " . $t_qtq . " as qrq
  1059. ON qrq.question_id = qq.id
  1060. AND qrq.exercice_id = " . intval($_GET['exe_id']);
  1061. $result_exercice_details = Database::query($sql_exercice_details);
  1062. $sql_ex_name = "SELECT quiz.title
  1063. FROM " . $t_q . " AS quiz
  1064. WHERE quiz.id = " . intval($_GET['exe_id']);
  1065. ;
  1066. $resultExName = Database::query($sql_ex_name);
  1067. $exName = Database :: fetch_array($resultExName);
  1068. echo "<table class='data_table'>
  1069. <tr>
  1070. <th colspan='2'>
  1071. " . $exName['title'] . "
  1072. </th>
  1073. </tr>
  1074. ";
  1075. while ($exerciceDetails = Database :: fetch_array($result_exercice_details)) {
  1076. $sqlAnswer = " SELECT qa.comment, qa.answer
  1077. FROM " . $t_qa . " as qa
  1078. WHERE qa.question_id = " . $exerciceDetails['id'];
  1079. $resultAnswer = Database::query($sqlAnswer);
  1080. echo "<a name='infosExe'></a>";
  1081. echo "
  1082. <tr>
  1083. <td colspan='2'>
  1084. <strong>" . $exerciceDetails['question'] . ' /' . $exerciceDetails['ponderation'] . "</strong>
  1085. </td>
  1086. </tr>
  1087. ";
  1088. while ($answer = Database :: fetch_array($resultAnswer)) {
  1089. echo "
  1090. <tr>
  1091. <td>
  1092. " . $answer['answer'] . "
  1093. </td>
  1094. <td>
  1095. ";
  1096. if (!empty ($answer['comment']))
  1097. echo $answer['comment'];
  1098. else
  1099. echo get_lang('NoComment');
  1100. echo "
  1101. </td>
  1102. </tr>
  1103. ";
  1104. }
  1105. }
  1106. echo "</table>";
  1107. }
  1108. //YW - commented out because it doesn't seem to be used
  1109. //$header = array_merge($headerLearnpath,$headerExercices,$headerProductions);
  1110. }
  1111. if ($export_csv) {
  1112. ob_end_clean();
  1113. Export :: export_table_csv($csv_content, 'reporting_student');
  1114. exit;
  1115. }
  1116. /*
  1117. ==============================================================================
  1118. FOOTER
  1119. ==============================================================================
  1120. */
  1121. Display :: display_footer();