myStudents.php 37 KB

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