myStudents.php 29 KB

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