myStudents.php 25 KB

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