myStudents.php 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. <?php
  2. /*
  3. * Created on 20 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  4. */
  5. // name of the language file that needs to be included
  6. $language_file = array ('registration', 'index', 'tracking', 'exercice');
  7. $cidReset=true;
  8. include ('../inc/global.inc.php');
  9. include_once(api_get_path(LIBRARY_PATH).'tracking.lib.php');
  10. include_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  11. include_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  12. include_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  13. include_once('../newscorm/learnpath.class.php');
  14. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  15. if($export_csv)
  16. {
  17. ob_start();
  18. }
  19. $csv_content = array();
  20. $this_section = "session_my_space";
  21. $nameTools=get_lang("StudentDetails");
  22. if(isset($_GET['details']))
  23. {
  24. if(!empty($_GET['origin']) && $_GET['origin'] == 'user_course')
  25. {
  26. $course_infos = CourseManager :: get_course_information($_GET['course']);
  27. if(empty($cidReq))
  28. $interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_infos['directory'], 'name' => $course_infos['title']);
  29. $interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".$_GET['course'], "name" => get_lang("Users"));
  30. }
  31. else if(!empty($_GET['origin']) && $_GET['origin'] == 'tracking_course')
  32. {
  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. $interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$_GET['course'].'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));
  37. }
  38. else
  39. {
  40. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  41. if(isset($_GET['id_coach']) && intval($_GET['id_coach'])!=0){
  42. $interbreadcrumb[] = array ("url" => "student.php?id_coach=".$_GET['id_coach'], "name" => get_lang("CoachStudents"));
  43. $interbreadcrumb[] = array ("url" => "myStudents.php?student=".$_GET['student'].'&id_coach='.$_GET['id_coach'], "name" => get_lang("StudentDetails"));
  44. }
  45. else{
  46. $interbreadcrumb[] = array ("url" => "student.php", "name" => get_lang("MyStudents"));
  47. $interbreadcrumb[] = array ("url" => "myStudents.php?student=".$_GET['student'], "name" => get_lang("StudentDetails"));
  48. }
  49. }
  50. $nameTools=get_lang("DetailsStudentInCourse");
  51. }
  52. else
  53. {
  54. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  55. if(isset($_GET['id_coach']) && intval($_GET['id_coach'])!=0){
  56. if(isset($_GET['id_session']) && intval($_GET['id_session'])!=0){
  57. $interbreadcrumb[] = array ("url" => "student.php?id_coach=".$_GET['id_coach']."&id_session=".$_GET['id_session'], "name" => get_lang("CoachStudents"));
  58. }
  59. else{
  60. $interbreadcrumb[] = array ("url" => "student.php?id_coach=".$_GET['id_coach'], "name" => get_lang("CoachStudents"));
  61. }
  62. }
  63. else{
  64. $interbreadcrumb[] = array ("url" => "student.php", "name" => get_lang("MyStudents"));
  65. }
  66. }
  67. api_block_anonymous_users();
  68. if(empty($_SESSION['is_allowedCreateCourse']) && !api_is_coach()){
  69. api_not_allowed(true);
  70. }
  71. Display :: display_header($nameTools);
  72. /*
  73. * ======================================================================================
  74. * FUNCTIONS
  75. * ======================================================================================
  76. */
  77. function calculHours($seconds)
  78. {
  79. //How many hours ?
  80. $hours = floor($seconds / 3600);
  81. //How many minutes ?
  82. $min = floor(($seconds - ($hours * 3600)) / 60);
  83. if ($min < 10)
  84. $min = "0".$min;
  85. //How many seconds
  86. $sec = $seconds - ($hours * 3600) - ($min * 60);
  87. if ($sec < 10)
  88. $sec = "0".$sec;
  89. return $hours."h".$min."m".$sec."s" ;
  90. }
  91. function is_teacher($course_code){
  92. global $_user;
  93. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  94. $sql="SELECT 1 FROM $tbl_course_user WHERE user_id='".$_user["user_id"]."' AND course_code='".$course_code."' AND status='1'";
  95. $result=api_sql_query($sql);
  96. if(mysql_result($result)!=1){
  97. return true;
  98. }
  99. else{
  100. return false;
  101. }
  102. }
  103. /*
  104. *===============================================================================
  105. * MAIN CODE
  106. *===============================================================================
  107. */
  108. // Database Table Definitions
  109. $tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
  110. $tbl_session_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
  111. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  112. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  113. $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  114. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  115. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  116. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  117. $tbl_stats_exercices_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  118. //$tbl_course_lp_view = Database :: get_course_table('lp_view');
  119. //$tbl_course_lp_view_item = Database :: get_course_table('lp_item_view');
  120. //$tbl_course_lp_item = Database :: get_course_table('lp_item');
  121. $tbl_course_lp_view = 'lp_view';
  122. $tbl_course_lp_view_item = 'lp_item_view';
  123. $tbl_course_lp_item = 'lp_item';
  124. $tbl_course_lp = 'lp';
  125. $tbl_course_quiz = 'quiz';
  126. $course_quiz_question = 'quiz_question';
  127. $course_quiz_rel_question = 'quiz_rel_question';
  128. $course_quiz_answer = 'quiz_answer';
  129. $course_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
  130. if(isset($_GET["user_id"]) && $_GET["user_id"]!="")
  131. {
  132. $i_user_id=$_GET["user_id"];
  133. }
  134. else
  135. {
  136. $i_user_id = $_user['user_id'];
  137. }
  138. if(!empty($_GET['student']))
  139. {
  140. $student_id = intval($_GET['student']);
  141. echo '<div align="right">
  142. <a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
  143. <a href="'.api_get_self().'?'.$_SERVER['QUERY_STRING'].'&export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
  144. </div>';
  145. // is the user online ?
  146. $statistics_database = Database :: get_statistic_database();
  147. $a_usersOnline = WhoIsOnline($_GET['student'], $statistics_database, 30);
  148. foreach($a_usersOnline as $a_online)
  149. {
  150. if(in_array($_GET['student'],$a_online))
  151. {
  152. $online = get_lang('Yes');
  153. }
  154. else
  155. {
  156. $online = get_lang('No');
  157. }
  158. }
  159. // infos about user
  160. $a_infosUser = UserManager::get_user_info_by_id($_GET['student']);
  161. $a_infosUser['name'] = $a_infosUser['firstname'].' '.$a_infosUser['lastname'];
  162. $avg_student_progress = $avg_student_score = $nb_courses = 0;
  163. $sql = 'SELECT course_code FROM '.$tbl_course_user.' WHERE user_id='.$a_infosUser['user_id'];
  164. $rs = api_sql_query($sql, __FILE__, __LINE__);
  165. $a_courses = array();
  166. while($row = Database :: fetch_array($rs))
  167. {
  168. $a_courses[$row['course_code']] = $row['course_code'];
  169. }
  170. // get the list of sessions where the user is subscribed as student
  171. $sql = 'SELECT DISTINCT course_code FROM '.Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' WHERE id_user='.intval($a_infosUser['user_id']);
  172. $rs = api_sql_query($sql, __FILE__, __LINE__);
  173. while($row = Database :: fetch_array($rs))
  174. {
  175. $a_courses[$row['course_code']] = $row['course_code'];
  176. }
  177. foreach ($a_courses as $key=>$course_code)
  178. {
  179. if(!CourseManager::is_user_subscribed_in_course($a_infosUser['user_id'], $course_code, true))
  180. {
  181. unset($a_courses[$key]);
  182. }
  183. else
  184. {
  185. $nb_courses++;
  186. $avg_student_progress += Tracking :: get_avg_student_progress($a_infosUser['user_id'],$course_code);
  187. $avg_student_score += Tracking :: get_avg_student_score($a_infosUser['user_id'],$course_code);
  188. }
  189. }
  190. $avg_student_progress = round($avg_student_progress / $nb_courses,2);
  191. $avg_student_score = round($avg_student_score / $nb_courses,2);
  192. $last_connection_date = Tracking::get_last_connection_date($a_infosUser['user_id'],true);
  193. if($last_connection_date==''){
  194. $last_connection_date=get_lang('NoConnexion');
  195. }
  196. $time_spent_on_the_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($a_infosUser['user_id']));
  197. // cvs informations
  198. $csv_content[] = array(get_lang('Informations'));
  199. $csv_content[] = array(get_lang('Name'), get_lang('Email'), get_lang('Tel'));
  200. $csv_content[] = array($a_infosUser['name'], $a_infosUser['email'],$a_infosUser['phone']);
  201. $csv_content[] = array();
  202. // csv tracking
  203. $csv_content[] = array(get_lang('Tracking'));
  204. $csv_content[] = array(get_lang('LatestLogin'), get_lang('TimeSpentOnThePlatform'), get_lang('Progress'), get_lang('Score'));
  205. $csv_content[] = array($last_connection_date, $time_spent_on_the_platform , $avg_student_progress.' %',$avg_student_score.' %');
  206. ?>
  207. <a name="infosStudent"></a>
  208. <table class="data_table">
  209. <tr>
  210. <td class="border">
  211. <table width="100%" border="0" >
  212. <tr>
  213. <?php
  214. if(!empty($a_infosUser['picture_uri']))
  215. {
  216. echo ' <td class="borderRight" width="10%" valign="top">
  217. <img src="../upload/users/'.$a_infosUser['picture_uri'].'" width="100" />
  218. </td>
  219. ';
  220. }
  221. else{
  222. echo ' <td class="borderRight" width="10%" valign="top">
  223. <img src="../img/unknown.jpg" />
  224. </td>
  225. ';
  226. }
  227. ?>
  228. <td class="none" width="40%" valign="top">
  229. <table width="100%">
  230. <tr>
  231. <th>
  232. <?php echo get_lang('Informations'); ?>
  233. </th>
  234. </tr>
  235. <tr>
  236. <td class="none">
  237. <?php
  238. echo get_lang('Name').' : ';
  239. echo $a_infosUser['name'];
  240. ?>
  241. </td>
  242. </tr>
  243. <tr>
  244. <td class="none">
  245. <?php
  246. echo get_lang('Email').' : ';
  247. if(!empty($a_infosUser['email']))
  248. {
  249. echo '<a href="mailto:'.$a_infosUser['email'].'">'.$a_infosUser['email'].'</a>';
  250. }
  251. else
  252. {
  253. echo get_lang('NoEmail');
  254. }
  255. ?>
  256. </td>
  257. </tr>
  258. <tr>
  259. <td class="none">
  260. <?php
  261. echo get_lang('Tel').'. ';
  262. if(!empty($a_infosUser['phone']))
  263. {
  264. echo $a_infosUser['phone'];
  265. }
  266. else
  267. {
  268. echo get_lang('NoTel');
  269. }
  270. ?>
  271. </td>
  272. </tr>
  273. <tr>
  274. <td class="none">
  275. <?php
  276. echo get_lang('OnLine').' : ';
  277. echo $online;
  278. ?>
  279. </td>
  280. </tr>
  281. </table>
  282. </td>
  283. <td class="borderLeft" width="35%" valign="top">
  284. <table width="100%">
  285. <tr>
  286. <th>
  287. <?php echo get_lang('Tracking'); ?>
  288. </th>
  289. </tr>
  290. <tr>
  291. <td>
  292. <table>
  293. <tr>
  294. <td class="none" align="right">
  295. <?php echo get_lang('LatestLogin') ?>
  296. </td>
  297. <td class="none" align="left">
  298. <?php echo $last_connection_date ?>
  299. </td>
  300. </tr>
  301. <tr>
  302. <td class="none" align="right">
  303. <?php echo get_lang('TimeSpentOnThePlatform') ?>
  304. </td>
  305. <td class="none" align="left">
  306. <?php echo $time_spent_on_the_platform ?>
  307. </td>
  308. </tr>
  309. <tr>
  310. <td class="none" align="right">
  311. <?php echo get_lang('Progress') ?>
  312. </td>
  313. <td class="none" align="left">
  314. <?php echo $avg_student_progress.' %' ?>
  315. </td>
  316. </tr>
  317. <tr>
  318. <td class="none" align="right">
  319. <?php echo get_lang('Score') ?>
  320. </td>
  321. <td class="none" align="left">
  322. <?php echo $avg_student_score.' %' ?>
  323. </td>
  324. </tr>
  325. </table>
  326. </td>
  327. </tr>
  328. </table>
  329. </td>
  330. <?php
  331. $sendMail = Display::encrypted_mailto_link($a_infosUser['email'], ' '.get_lang('SendMail'));
  332. ?>
  333. <td class="borderLeft" width="15%" valign="top">
  334. <table width="100%">
  335. <tr>
  336. <th>
  337. <?php echo get_lang('Actions'); ?>
  338. </th>
  339. </tr>
  340. <tr>
  341. <?php
  342. if(!empty($a_infosUser['email']))
  343. {
  344. echo "<td class='none'>";
  345. echo '<img align="absbottom" src="../img/send_mail.gif">&nbsp;'.$sendMail;
  346. echo "</td>";
  347. }
  348. else
  349. {
  350. echo "<td class='noLink none'>";
  351. echo '<img align="absbottom" src="../img/send_mail.gif">&nbsp; <strong> > '.get_lang('SendMail').'</strong>';
  352. echo "</td>";
  353. }
  354. ?>
  355. </tr>
  356. </table>
  357. </td>
  358. </tr>
  359. </table>
  360. </td>
  361. </tr>
  362. </table>
  363. <table class="data_table">
  364. <tr>
  365. <td colspan="5" style="border-width: 0px;">&nbsp;</td>
  366. </tr>
  367. <?php
  368. if(!empty($_GET['details']))
  369. {
  370. $a_infosCours = CourseManager :: get_course_information($_GET['course']);
  371. $a_date_start = explode('-',$a_infosCours['date_start']);
  372. $date_start = $a_date_start[2].'/'.$a_date_start[1].'/'.$a_date_start[0];
  373. $a_date_end = explode('-',$a_infosCours['date_end']);
  374. $date_end = $a_date_end[2].'/'.$a_date_end[1].'/'.$a_date_end[0];
  375. $dateSession = get_lang('From').' '.$date_start.' '.get_lang('To').' '.$date_end;
  376. $tableTitle = $a_infosCours['title'].'&nbsp; | &nbsp;'.get_lang('Tutor').' : '.stripslashes($a_infosCours['tutor_name']);
  377. $csv_content[] = array();
  378. $csv_content[] = array(str_replace('&nbsp;','',$tableTitle));
  379. ?>
  380. <tr class="tableName">
  381. <td colspan="6">
  382. <strong><?php echo $tableTitle; ?></strong>
  383. </td>
  384. </tr>
  385. <tr> <!-- line about learnpaths -->
  386. <td>
  387. <table class="data_table">
  388. <tr>
  389. <th>
  390. <?php echo get_lang('Learnpaths'); ?>
  391. </th>
  392. <th>
  393. <?php echo get_lang('Time'); ?>
  394. </th>
  395. <th>
  396. <?php echo get_lang('Score'); ?>
  397. </th>
  398. <th>
  399. <?php echo get_lang('Progress'); ?>
  400. </th>
  401. <th>
  402. <?php echo get_lang('LastConnexion'); ?>
  403. </th>
  404. <th>
  405. <?php echo get_lang('Details'); ?>
  406. </th>
  407. </tr>
  408. <?php
  409. $a_headerLearnpath = array(get_lang('Learnpath'),get_lang('Time'),get_lang('Progress'),get_lang('LastConnexion'));
  410. $sqlLearnpath = " SELECT lp.name,lp.id
  411. FROM ".$a_infosCours['db_name'].".".$tbl_course_lp." AS lp ORDER BY lp.name ASC
  412. ";
  413. $resultLearnpath = api_sql_query($sqlLearnpath);
  414. $csv_content[] = array();
  415. $csv_content[] = array(get_lang('Learnpath'),get_lang('Time'),get_lang('Score'),get_lang('Progress'),get_lang('LastConnexion'));
  416. if(mysql_num_rows($resultLearnpath)>0)
  417. {
  418. $i = 0;
  419. while($a_learnpath = mysql_fetch_array($resultLearnpath))
  420. {
  421. $progress = learnpath :: get_db_progress($a_learnpath['id'],$student_id, '%',$a_infosCours['db_name']);
  422. // calculates time
  423. $sql = 'SELECT SUM(total_time)
  424. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
  425. INNER JOIN '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' AS view
  426. ON item_view.lp_view_id = view.id
  427. AND view.lp_id = '.$a_learnpath['id'].'
  428. AND view.user_id = '.intval($_GET['student']);
  429. $rs = api_sql_query($sql, __FILE__, __LINE__);
  430. $total_time = mysql_result($rs, 0, 0);
  431. // calculates last connection time
  432. $sql = 'SELECT MAX(start_time)
  433. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
  434. INNER JOIN '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' AS view
  435. ON item_view.lp_view_id = view.id
  436. AND view.lp_id = '.$a_learnpath['id'].'
  437. AND view.user_id = '.intval($_GET['student']);
  438. $rs = api_sql_query($sql, __FILE__, __LINE__);
  439. $start_time = mysql_result($rs, 0, 0);
  440. //QUIZZ IN LP
  441. $sql = 'SELECT id as item_id, max_score
  442. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_item.' AS lp_item
  443. WHERE lp_id='.$a_learnpath['id'].'
  444. AND item_type="quiz"';
  445. $rsItems = api_sql_query($sql, __FILE__, __LINE__);
  446. //We get the last view id of this LP
  447. $sql='SELECT max(id) as id FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' WHERE lp_id='.$a_learnpath['id'].' AND user_id="'.intval($_GET['student']).'"';
  448. $rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
  449. $lp_view_id = mysql_result($rs_last_lp_view_id,0,'id');
  450. $total_score = $total_weighting = 0;
  451. while($item = Database :: fetch_array($rsItems, 'ASSOC'))
  452. {
  453. $sql = 'SELECT score as student_score
  454. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' as lp_view_item
  455. WHERE lp_view_item.lp_item_id = '.$item['item_id'].'
  456. AND lp_view_id = "'.$lp_view_id.'"
  457. ';
  458. $rsScores = api_sql_query($sql, __FILE__, __LINE__);
  459. $total_score += mysql_result($rsScores, 0, 0);
  460. $total_weighting += $item['max_score'];
  461. }
  462. $sql = 'SELECT id, max_score
  463. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_item.' AS lp_item
  464. WHERE lp_id='.$a_learnpath['id'].'
  465. AND item_type="sco" LIMIT 1';
  466. $rs_lp_item_id_scorm = api_sql_query($sql, __FILE__, __LINE__);
  467. if(mysql_num_rows($rs_lp_item_id_scorm)>0){
  468. $lp_item_id = mysql_result($rs_lp_item_id_scorm,0,'id');
  469. $lp_item__max_score = mysql_result($rs_lp_item_id_scorm,0,'max_score');
  470. $total_weighting+=$lp_item__max_score;
  471. //We get the last view id of this LP
  472. $sql='SELECT max(id) as id FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' WHERE lp_id='.$a_learnpath['id'].' AND user_id="'.intval($_GET['student']).'"';
  473. $rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
  474. $lp_view_id = mysql_result($rs_last_lp_view_id,0,'id');
  475. $sql='SELECT SUM(score)/count(lp_item_id) as score FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' WHERE lp_view_id="'.$lp_view_id.'" GROUP BY lp_view_id';
  476. $rs_score = api_sql_query($sql, __FILE__, __LINE__);
  477. $lp_scorm_score = mysql_result($rs_score,0,'score');
  478. $total_score+=$lp_scorm_score;
  479. }
  480. $score = round($total_score / $total_weighting * 100,2);
  481. if($i%2==0){
  482. $s_css_class="row_odd";
  483. }
  484. else{
  485. $s_css_class="row_even";
  486. }
  487. $i++;
  488. $csv_content[] = array(stripslashes($a_learnpath['name']),api_time_to_hms($total_time),$score.'%',$progress,date('Y-m-d',$start_time));
  489. ?>
  490. <tr class="<?php echo $s_css_class;?>">
  491. <td>
  492. <?php echo stripslashes($a_learnpath['name']); ?>
  493. </td>
  494. <td align="right">
  495. <?php echo api_time_to_hms($total_time) ?>
  496. </td>
  497. <td align="right">
  498. <?php echo $score.'%' ?>
  499. </td>
  500. <td align="right">
  501. <?php echo $progress ?>
  502. </td>
  503. <td align="center">
  504. <?php if($start_time!='' && $start_time>0) echo format_locale_date(get_lang('DateFormatLongWithoutDay'),$start_time); else echo '-'; ?>
  505. </td>
  506. <td align="center">
  507. <?php
  508. if($progress > 0 || $score > 0)
  509. {
  510. ?>
  511. <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'] ?>">
  512. <img src="../img/2rightarrow.gif" border="0" />
  513. </a>
  514. <?php
  515. }
  516. ?>
  517. </td>
  518. </tr>
  519. <?php
  520. $dataLearnpath[$i][] = $a_learnpath['name'];
  521. $dataLearnpath[$i][] = $progress.'%';
  522. $i++;
  523. }
  524. }
  525. else
  526. {
  527. echo " <tr>
  528. <td colspan='6'>
  529. ".get_lang('NoLearnpath')."
  530. </td>
  531. </tr>
  532. ";
  533. }
  534. ?>
  535. </table>
  536. </td>
  537. </tr>
  538. <tr> <!-- line about exercises -->
  539. <td>
  540. <table class="data_table">
  541. <tr>
  542. <th>
  543. <?php echo get_lang('Exercices'); ?>
  544. </th>
  545. <th>
  546. <?php echo get_lang('Score') ?>
  547. </th>
  548. <th>
  549. <?php echo get_lang('Attempts'); ?>
  550. </th>
  551. <th>
  552. <?php echo get_lang('CorrectTest'); ?>
  553. </th>
  554. </tr>
  555. <?php
  556. $csv_content[] = array();
  557. $csv_content[] = array(get_lang('Exercices'),get_lang('Score'),get_lang('Attempts'));
  558. $a_infosCours = CourseManager :: get_course_information($_GET['course']);
  559. $sql='SELECT visibility FROM '.$a_infosCours['db_name'].'.'.TABLE_TOOL_LIST.' WHERE name="quiz"';
  560. $resultVisibilityQuizz = api_sql_query($sql);
  561. if(mysql_result($resultVisibilityQuizz,0,'visibility')==1){
  562. $sqlExercices = " SELECT quiz.title,id
  563. FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
  564. WHERE active='1' ORDER BY quiz.title ASC
  565. ";
  566. $resultExercices = api_sql_query($sqlExercices);
  567. $i = 0;
  568. if(mysql_num_rows($resultExercices)>0)
  569. {
  570. while($a_exercices = mysql_fetch_array($resultExercices))
  571. {
  572. $sqlEssais = " SELECT COUNT(ex.exe_id) as essais
  573. FROM $tbl_stats_exercices AS ex
  574. WHERE ex.exe_cours_id = '".$a_infosCours['code']."'
  575. AND ex.exe_exo_id = ".$a_exercices['id']."
  576. AND exe_user_id='".$_GET["student"]."'"
  577. ;
  578. $resultEssais = api_sql_query($sqlEssais);
  579. $a_essais = mysql_fetch_array($resultEssais);
  580. $sqlScore = "SELECT exe_id, exe_result,exe_weighting
  581. FROM $tbl_stats_exercices
  582. WHERE exe_user_id = ".$_GET['student']."
  583. AND exe_cours_id = '".$a_infosCours['code']."'
  584. AND exe_exo_id = ".$a_exercices['id']."
  585. ORDER BY exe_date DESC LIMIT 1";
  586. $resultScore = api_sql_query($sqlScore);
  587. $score = 0;
  588. while($a_score = mysql_fetch_array($resultScore))
  589. {
  590. $score = $score + $a_score['exe_result'];
  591. $weighting = $weighting + $a_score['exe_weighting'];
  592. $exe_id = $a_score['exe_id'];
  593. }
  594. $pourcentageScore = round(($score*100)/$weighting);
  595. $weighting = 0;
  596. $csv_content[] = array($a_exercices['title'], $pourcentageScore.' %', $a_essais['essais']);
  597. if($i%2==0){
  598. $s_css_class="row_odd";
  599. }
  600. else{
  601. $s_css_class="row_even";
  602. }
  603. $i++;
  604. echo "<tr class='$s_css_class'>
  605. <td>
  606. ";
  607. echo $a_exercices['title'];
  608. echo " </td>
  609. ";
  610. echo " <td align='right'>
  611. ";
  612. echo $pourcentageScore.' %';
  613. echo " </td>
  614. <td align='right'>
  615. ";
  616. echo $a_essais['essais'];
  617. echo " </td>
  618. <td align='center'>
  619. ";
  620. $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'].'" ORDER BY exe_date DESC LIMIT 1';
  621. $resultLastAttempt = api_sql_query($sql_last_attempt);
  622. $id_last_attempt=mysql_result($resultLastAttempt,0,0);
  623. if($a_essais['essais']>0)
  624. 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>';
  625. echo " </td>
  626. </tr>
  627. ";
  628. $dataExercices[$i][] = $a_exercices['title'];
  629. $dataExercices[$i][] = $pourcentageScore.'%';
  630. $dataExercices[$i][] = $a_essais['essais'];
  631. //$dataExercices[$i][] = corrections;
  632. $i++;
  633. }
  634. }
  635. else
  636. {
  637. echo " <tr>
  638. <td colspan='6'>
  639. ".get_lang('NoExercise')."
  640. </td>
  641. </tr>
  642. ";
  643. }
  644. }
  645. else
  646. {
  647. echo " <tr>
  648. <td colspan='6'>
  649. ".get_lang('NoExercise')."
  650. </td>
  651. </tr>
  652. ";
  653. }
  654. ?>
  655. </table>
  656. </td>
  657. </tr>
  658. <tr><!-- line about other tools -->
  659. <td>
  660. <table class="data_table">
  661. <?php
  662. $csv_content[] = array();
  663. $nb_assignments = Tracking :: count_student_assignments($a_infosUser['user_id'], $a_infosCours['code']);
  664. $messages = Tracking :: count_student_messages($a_infosUser['user_id'], $a_infosCours['code']);
  665. $links = Tracking :: count_student_visited_links($a_infosUser['user_id'], $a_infosCours['code']);
  666. $documents = Tracking :: count_student_downloaded_documents($a_infosUser['user_id'], $a_infosCours['code']);
  667. $csv_content[] = array(get_lang('Student_publication'), $nb_assignments);
  668. $csv_content[] = array(get_lang('Messages'), $messages);
  669. $csv_content[] = array(get_lang('LinksDetails'), $links);
  670. $csv_content[] = array(get_lang('DocumentsDetails'), $documents);
  671. ?>
  672. <tr>
  673. <th colspan="2">
  674. <?php echo get_lang('OtherTools'); ?>
  675. </th>
  676. </tr>
  677. <tr><!-- assignments -->
  678. <td width="40%">
  679. <?php echo get_lang('Student_publication') ?>
  680. </td>
  681. <td>
  682. <?php echo $nb_assignments ?>
  683. </td>
  684. </tr>
  685. <tr><!-- messages -->
  686. <td>
  687. <?php echo get_lang('Messages') ?>
  688. </td>
  689. <td>
  690. <?php echo $messages ?>
  691. </td>
  692. </tr>
  693. <tr><!-- links -->
  694. <td>
  695. <?php echo get_lang('LinksDetails') ?>
  696. </td>
  697. <td>
  698. <?php echo $links ?>
  699. </td>
  700. </tr>
  701. <tr><!-- documents -->
  702. <td>
  703. <?php echo get_lang('DocumentsDetails') ?>
  704. </td>
  705. <td>
  706. <?php echo $documents ?>
  707. </td>
  708. </tr>
  709. </table>
  710. </td>
  711. </tr>
  712. </table>
  713. <?php
  714. }
  715. else
  716. {
  717. ?>
  718. <tr>
  719. <th>
  720. <?php echo get_lang('Course'); ?>
  721. </th>
  722. <th>
  723. <?php echo get_lang('Time'); ?>
  724. </th>
  725. <th>
  726. <?php echo get_lang('Progress'); ?>
  727. </th>
  728. <th>
  729. <?php echo get_lang('Score'); ?>
  730. </th>
  731. <th>
  732. <?php echo get_lang('Details'); ?>
  733. </th>
  734. </tr>
  735. <?php
  736. if(!api_is_platform_admin()){
  737. // courses followed by user where we are coach
  738. if(!isset($_GET['id_coach'])){
  739. $a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
  740. }
  741. else{
  742. $a_courses = Tracking :: get_courses_followed_by_coach($_GET['id_coach']);
  743. }
  744. }
  745. if(count($a_courses)>0)
  746. {
  747. $csv_content[] = array();
  748. $csv_content[] = array(get_lang('Course'),get_lang('Time'),get_lang('Progress'),get_lang('Score'));
  749. foreach($a_courses as $course_code)
  750. {
  751. if(CourseManager :: is_user_subscribed_in_course($student_id,$course_code, true)){
  752. $course_infos = CourseManager :: get_course_information($course_code);
  753. $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($a_infosUser['user_id'], $course_code));
  754. $progress = Tracking :: get_avg_student_progress($a_infosUser['user_id'], $course_code).' %';
  755. $score = Tracking :: get_avg_student_score($a_infosUser['user_id'], $course_code).' %';
  756. $csv_content[] = array($course_infos['title'], $time_spent_on_course, $progress, $score);
  757. echo '
  758. <tr>
  759. <td align="right">
  760. '.$course_infos['title'].'
  761. </td>
  762. <td align="right">
  763. '.$time_spent_on_course.'
  764. </td>
  765. <td align="right">
  766. '.$progress.'
  767. </td>
  768. <td align="right">
  769. '.$score.'
  770. </td>';
  771. if(isset($_GET['id_coach']) && intval($_GET['id_coach'])!=0){
  772. echo '<td align="center" width="10">
  773. <a href="'.api_get_self().'?student='.$a_infosUser['user_id'].'&details=true&course='.$course_infos['code'].'&id_coach='.$_GET['id_coach'].'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
  774. </td>';
  775. }
  776. else{
  777. echo '<td align="center" width="10">
  778. <a href="'.api_get_self().'?student='.$a_infosUser['user_id'].'&details=true&course='.$course_infos['code'].'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
  779. </td>';
  780. }
  781. echo '</tr>';
  782. }
  783. }
  784. }
  785. else
  786. {
  787. echo "<tr>
  788. <td colspan='5'>
  789. ".get_lang('NoCourse')."
  790. </td>
  791. </tr>
  792. ";
  793. }
  794. }//end of else !empty($details)
  795. ?>
  796. </table>
  797. <br />
  798. <?php
  799. if(!empty($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course')
  800. {
  801. ?>
  802. <br /><br />
  803. <?php
  804. }
  805. if(!empty($_GET['exe_id']))
  806. {
  807. $sqlExerciceDetails = " SELECT qq.question, qq.ponderation, qq.id
  808. FROM ".$a_infosCours['db_name'].".".$course_quiz_question." as qq
  809. INNER JOIN ".$a_infosCours['db_name'].".".$course_quiz_rel_question." as qrq
  810. ON qrq.question_id = qq.id
  811. AND qrq.exercice_id = ".$_GET['exe_id']
  812. ;
  813. $resultExerciceDetails = api_sql_query($sqlExerciceDetails);
  814. $sqlExName = " SELECT quiz.title
  815. FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
  816. WHERE quiz.id = ".$_GET['exe_id']
  817. ;
  818. $resultExName = api_sql_query($sqlExName);
  819. $a_exName = mysql_fetch_array($resultExName);
  820. echo "<table class='data_table'>
  821. <tr>
  822. <th colspan='2'>
  823. ".$a_exName['title']."
  824. </th>
  825. </tr>
  826. ";
  827. while($a_exerciceDetails = mysql_fetch_array($resultExerciceDetails))
  828. {
  829. $sqlAnswer = " SELECT qa.comment, qa.answer
  830. FROM ".$a_infosCours['db_name'].".".$course_quiz_answer." as qa
  831. WHERE qa.question_id = ".$a_exerciceDetails['id']
  832. ;
  833. $resultAnswer = api_sql_query($sqlAnswer);
  834. echo "<a name='infosExe'></a>";
  835. echo"
  836. <tr>
  837. <td colspan='2'>
  838. <strong>".$a_exerciceDetails['question'].' /'.$a_exerciceDetails['ponderation']."</strong>
  839. </td>
  840. </tr>
  841. ";
  842. while($a_answer = mysql_fetch_array($resultAnswer))
  843. {
  844. echo"
  845. <tr>
  846. <td>
  847. ".$a_answer['answer']."
  848. </td>
  849. <td>
  850. ";
  851. if(!empty($a_answer['comment']))
  852. echo $a_answer['comment'];
  853. else
  854. echo get_lang('NoComment');
  855. echo "
  856. </td>
  857. </tr>
  858. ";
  859. }
  860. }
  861. echo "</table>";
  862. }
  863. $a_header = array_merge($a_headerLearnpath,$a_headerExercices,$a_headerProductions);
  864. }
  865. if($export_csv)
  866. {
  867. ob_end_clean();
  868. Export :: export_table_csv($csv_content, 'reporting_student');
  869. }
  870. /*
  871. ==============================================================================
  872. FOOTER
  873. ==============================================================================
  874. */
  875. Display::display_footer();
  876. ?>