myStudents.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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. break;
  154. }
  155. else
  156. {
  157. $online = get_lang('No');
  158. }
  159. }
  160. // infos about user
  161. $a_infosUser = UserManager::get_user_info_by_id($_GET['student']);
  162. $a_infosUser['name'] = $a_infosUser['firstname'].' '.$a_infosUser['lastname'];
  163. $avg_student_progress = $avg_student_score = $nb_courses = 0;
  164. $sql = 'SELECT course_code FROM '.$tbl_course_user.' WHERE user_id='.$a_infosUser['user_id'];
  165. $rs = api_sql_query($sql, __FILE__, __LINE__);
  166. $a_courses = array();
  167. while($row = Database :: fetch_array($rs))
  168. {
  169. $a_courses[$row['course_code']] = $row['course_code'];
  170. }
  171. // get the list of sessions where the user is subscribed as student
  172. $sql = 'SELECT DISTINCT course_code FROM '.Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' WHERE id_user='.intval($a_infosUser['user_id']);
  173. $rs = api_sql_query($sql, __FILE__, __LINE__);
  174. while($row = Database :: fetch_array($rs))
  175. {
  176. $a_courses[$row['course_code']] = $row['course_code'];
  177. }
  178. foreach ($a_courses as $key=>$course_code)
  179. {
  180. if(!CourseManager::is_user_subscribed_in_course($a_infosUser['user_id'], $course_code, true))
  181. {
  182. unset($a_courses[$key]);
  183. }
  184. else
  185. {
  186. $nb_courses++;
  187. $avg_student_progress += Tracking :: get_avg_student_progress($a_infosUser['user_id'],$course_code);
  188. $avg_student_score += Tracking :: get_avg_student_score($a_infosUser['user_id'],$course_code);
  189. }
  190. }
  191. $avg_student_progress = round($avg_student_progress / $nb_courses,2);
  192. $avg_student_score = round($avg_student_score / $nb_courses,2);
  193. $first_connection_date = Tracking::get_first_connection_date($a_infosUser['user_id']);
  194. if($first_connection_date==''){
  195. $first_connection_date=get_lang('NoConnexion');
  196. }
  197. $last_connection_date = Tracking::get_last_connection_date($a_infosUser['user_id'],true);
  198. if($last_connection_date==''){
  199. $last_connection_date=get_lang('NoConnexion');
  200. }
  201. $time_spent_on_the_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($a_infosUser['user_id']));
  202. // cvs informations
  203. $csv_content[] = array(get_lang('Informations'));
  204. $csv_content[] = array(get_lang('Name'), get_lang('Email'), get_lang('Tel'));
  205. $csv_content[] = array($a_infosUser['name'], $a_infosUser['email'],$a_infosUser['phone']);
  206. $csv_content[] = array();
  207. // csv tracking
  208. $csv_content[] = array(get_lang('Tracking'));
  209. $csv_content[] = array(get_lang('FirstLogin'),get_lang('LatestLogin'), get_lang('TimeSpentOnThePlatform'), get_lang('Progress'), get_lang('Score'));
  210. $csv_content[] = array(strip_tags($first_connection_date),strip_tags($last_connection_date), $time_spent_on_the_platform , $avg_student_progress.' %',$avg_student_score.' %');
  211. ?>
  212. <a name="infosStudent"></a>
  213. <table class="data_table">
  214. <tr>
  215. <td class="border">
  216. <table width="100%" border="0" >
  217. <tr>
  218. <?php
  219. if(!empty($a_infosUser['picture_uri']))
  220. {
  221. echo ' <td class="borderRight" width="10%" valign="top">
  222. <img src="../upload/users/'.$a_infosUser['picture_uri'].'" width="100" />
  223. </td>
  224. ';
  225. }
  226. else{
  227. echo ' <td class="borderRight" width="10%" valign="top">
  228. <img src="../img/unknown.jpg" />
  229. </td>
  230. ';
  231. }
  232. ?>
  233. <td class="none" width="40%" valign="top">
  234. <table width="100%">
  235. <tr>
  236. <th>
  237. <?php echo get_lang('Informations'); ?>
  238. </th>
  239. </tr>
  240. <tr>
  241. <td class="none">
  242. <?php
  243. echo get_lang('Name').' : ';
  244. echo $a_infosUser['name'];
  245. ?>
  246. </td>
  247. </tr>
  248. <tr>
  249. <td class="none">
  250. <?php
  251. echo get_lang('Email').' : ';
  252. if(!empty($a_infosUser['email']))
  253. {
  254. echo '<a href="mailto:'.$a_infosUser['email'].'">'.$a_infosUser['email'].'</a>';
  255. }
  256. else
  257. {
  258. echo get_lang('NoEmail');
  259. }
  260. ?>
  261. </td>
  262. </tr>
  263. <tr>
  264. <td class="none">
  265. <?php
  266. echo get_lang('Tel').'. ';
  267. if(!empty($a_infosUser['phone']))
  268. {
  269. echo $a_infosUser['phone'];
  270. }
  271. else
  272. {
  273. echo get_lang('NoTel');
  274. }
  275. ?>
  276. </td>
  277. </tr>
  278. <tr>
  279. <td class="none">
  280. <?php
  281. echo get_lang('OnLine').' : ';
  282. echo $online;
  283. ?>
  284. </td>
  285. </tr>
  286. </table>
  287. </td>
  288. <td class="borderLeft" width="35%" valign="top">
  289. <table width="100%">
  290. <tr>
  291. <th>
  292. <?php echo get_lang('Tracking'); ?>
  293. </th>
  294. </tr>
  295. <tr>
  296. <td>
  297. <table>
  298. <tr>
  299. <td class="none" align="right">
  300. <?php echo get_lang('FirstLogin') ?>
  301. </td>
  302. <td class="none" align="left">
  303. <?php echo $first_connection_date ?>
  304. </td>
  305. </tr>
  306. <tr>
  307. <td class="none" align="right">
  308. <?php echo get_lang('LatestLogin') ?>
  309. </td>
  310. <td class="none" align="left">
  311. <?php echo $last_connection_date ?>
  312. </td>
  313. </tr>
  314. <tr>
  315. <td class="none" align="right">
  316. <?php echo get_lang('TimeSpentOnThePlatform') ?>
  317. </td>
  318. <td class="none" align="left">
  319. <?php echo $time_spent_on_the_platform ?>
  320. </td>
  321. </tr>
  322. <tr>
  323. <td class="none" align="right">
  324. <?php echo get_lang('Progress') ?>
  325. </td>
  326. <td class="none" align="left">
  327. <?php echo $avg_student_progress.' %' ?>
  328. </td>
  329. </tr>
  330. <tr>
  331. <td class="none" align="right">
  332. <?php echo get_lang('Score') ?>
  333. </td>
  334. <td class="none" align="left">
  335. <?php echo $avg_student_score.' %' ?>
  336. </td>
  337. </tr>
  338. </table>
  339. </td>
  340. </tr>
  341. </table>
  342. </td>
  343. <?php
  344. $sendMail = Display::encrypted_mailto_link($a_infosUser['email'], ' '.get_lang('SendMail'));
  345. ?>
  346. <td class="borderLeft" width="15%" valign="top">
  347. <table width="100%">
  348. <tr>
  349. <th>
  350. <?php echo get_lang('Actions'); ?>
  351. </th>
  352. </tr>
  353. <tr>
  354. <?php
  355. if(!empty($a_infosUser['email']))
  356. {
  357. echo "<td class='none'>";
  358. echo '<img align="absbottom" src="../img/send_mail.gif">&nbsp;'.$sendMail;
  359. echo "</td>";
  360. }
  361. else
  362. {
  363. echo "<td class='noLink none'>";
  364. echo '<img align="absbottom" src="../img/send_mail.gif">&nbsp; <strong> > '.get_lang('SendMail').'</strong>';
  365. echo "</td>";
  366. }
  367. ?>
  368. </tr>
  369. </table>
  370. </td>
  371. </tr>
  372. </table>
  373. </td>
  374. </tr>
  375. </table>
  376. <table class="data_table">
  377. <tr>
  378. <td colspan="5" style="border-width: 0px;">&nbsp;</td>
  379. </tr>
  380. <?php
  381. if(!empty($_GET['details']))
  382. {
  383. $a_infosCours = CourseManager :: get_course_information($_GET['course']);
  384. $a_date_start = explode('-',$a_infosCours['date_start']);
  385. $date_start = $a_date_start[2].'/'.$a_date_start[1].'/'.$a_date_start[0];
  386. $a_date_end = explode('-',$a_infosCours['date_end']);
  387. $date_end = $a_date_end[2].'/'.$a_date_end[1].'/'.$a_date_end[0];
  388. $dateSession = get_lang('From').' '.$date_start.' '.get_lang('To').' '.$date_end;
  389. $nb_login = Tracking :: count_login_per_student($a_infosUser['user_id'], $_GET['course']);
  390. $tableTitle = $a_infosCours['title'].'&nbsp;|&nbsp;'.get_lang('CountToolAccess').' : '.$nb_login.'&nbsp; | &nbsp;'.get_lang('Tutor').' : '.stripslashes($a_infosCours['tutor_name']);
  391. $csv_content[] = array();
  392. $csv_content[] = array(str_replace('&nbsp;','',$tableTitle));
  393. ?>
  394. <tr class="tableName">
  395. <td colspan="6">
  396. <strong><?php echo $tableTitle; ?></strong>
  397. </td>
  398. </tr>
  399. <tr> <!-- line about learnpaths -->
  400. <td>
  401. <table class="data_table">
  402. <tr>
  403. <th>
  404. <?php echo get_lang('Learnpaths'); ?>
  405. </th>
  406. <th>
  407. <?php echo get_lang('Time'); ?>
  408. </th>
  409. <th>
  410. <?php echo get_lang('Score'); ?>
  411. </th>
  412. <th>
  413. <?php echo get_lang('Progress'); ?>
  414. </th>
  415. <th>
  416. <?php echo get_lang('LastConnexion'); ?>
  417. </th>
  418. <th>
  419. <?php echo get_lang('Details'); ?>
  420. </th>
  421. </tr>
  422. <?php
  423. $a_headerLearnpath = array(get_lang('Learnpath'),get_lang('Time'),get_lang('Progress'),get_lang('LastConnexion'));
  424. $sqlLearnpath = " SELECT lp.name,lp.id
  425. FROM ".$a_infosCours['db_name'].".".$tbl_course_lp." AS lp ORDER BY lp.name ASC
  426. ";
  427. $resultLearnpath = api_sql_query($sqlLearnpath);
  428. $csv_content[] = array();
  429. $csv_content[] = array(get_lang('Learnpath'),get_lang('Time'),get_lang('Score'),get_lang('Progress'),get_lang('LastConnexion'));
  430. if(mysql_num_rows($resultLearnpath)>0)
  431. {
  432. $i = 0;
  433. while($a_learnpath = mysql_fetch_array($resultLearnpath))
  434. {
  435. $progress = learnpath :: get_db_progress($a_learnpath['id'],$student_id, '%',$a_infosCours['db_name']);
  436. // calculates time
  437. $sql = 'SELECT SUM(total_time)
  438. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
  439. INNER JOIN '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' AS view
  440. ON item_view.lp_view_id = view.id
  441. AND view.lp_id = '.$a_learnpath['id'].'
  442. AND view.user_id = '.intval($_GET['student']);
  443. $rs = api_sql_query($sql, __FILE__, __LINE__);
  444. $total_time = mysql_result($rs, 0, 0);
  445. // calculates last connection time
  446. $sql = 'SELECT MAX(start_time)
  447. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
  448. INNER JOIN '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' AS view
  449. ON item_view.lp_view_id = view.id
  450. AND view.lp_id = '.$a_learnpath['id'].'
  451. AND view.user_id = '.intval($_GET['student']);
  452. $rs = api_sql_query($sql, __FILE__, __LINE__);
  453. $start_time = mysql_result($rs, 0, 0);
  454. //QUIZZ IN LP
  455. $sql = 'SELECT id as item_id, max_score
  456. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_item.' AS lp_item
  457. WHERE lp_id='.$a_learnpath['id'].'
  458. AND item_type="quiz"';
  459. $rsItems = api_sql_query($sql, __FILE__, __LINE__);
  460. //We get the last view id of this LP
  461. $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']).'"';
  462. $rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
  463. $lp_view_id = mysql_result($rs_last_lp_view_id,0,'id');
  464. $total_score = $total_weighting = 0;
  465. while($item = Database :: fetch_array($rsItems, 'ASSOC'))
  466. {
  467. $sql = 'SELECT score as student_score
  468. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' as lp_view_item
  469. WHERE lp_view_item.lp_item_id = '.$item['item_id'].'
  470. AND lp_view_id = "'.$lp_view_id.'"
  471. ';
  472. $rsScores = api_sql_query($sql, __FILE__, __LINE__);
  473. $total_score += mysql_result($rsScores, 0, 0);
  474. $total_weighting += $item['max_score'];
  475. }
  476. $sql = 'SELECT id, max_score
  477. FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_item.' AS lp_item
  478. WHERE lp_id='.$a_learnpath['id'].'
  479. AND item_type="sco" LIMIT 1';
  480. $rs_lp_item_id_scorm = api_sql_query($sql, __FILE__, __LINE__);
  481. if(mysql_num_rows($rs_lp_item_id_scorm)>0){
  482. $lp_item_id = mysql_result($rs_lp_item_id_scorm,0,'id');
  483. $lp_item__max_score = mysql_result($rs_lp_item_id_scorm,0,'max_score');
  484. $total_weighting+=$lp_item__max_score;
  485. //We get the last view id of this LP
  486. $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']).'"';
  487. $rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
  488. $lp_view_id = mysql_result($rs_last_lp_view_id,0,'id');
  489. $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';
  490. $rs_score = api_sql_query($sql, __FILE__, __LINE__);
  491. $lp_scorm_score = mysql_result($rs_score,0,'score');
  492. $total_score+=$lp_scorm_score;
  493. }
  494. $score = 0;
  495. if($total_weighting != 0)
  496. {
  497. $score = round($total_score / $total_weighting * 100,2);
  498. }
  499. if($i%2==0){
  500. $s_css_class="row_odd";
  501. }
  502. else{
  503. $s_css_class="row_even";
  504. }
  505. $i++;
  506. $csv_content[] = array(stripslashes($a_learnpath['name']),api_time_to_hms($total_time),$score.'%',$progress,date('Y-m-d',$start_time));
  507. ?>
  508. <tr class="<?php echo $s_css_class;?>">
  509. <td>
  510. <?php echo stripslashes($a_learnpath['name']); ?>
  511. </td>
  512. <td align="right">
  513. <?php echo api_time_to_hms($total_time) ?>
  514. </td>
  515. <td align="right">
  516. <?php echo $total_weighting>0 ? $score.'%' : '-' ?>
  517. </td>
  518. <td align="right">
  519. <?php echo $progress ?>
  520. </td>
  521. <td align="center">
  522. <?php if($start_time!='' && $start_time>0) echo format_locale_date(get_lang('DateFormatLongWithoutDay'),$start_time); else echo '-'; ?>
  523. </td>
  524. <td align="center">
  525. <?php
  526. if($progress > 0 || $score > 0)
  527. {
  528. ?>
  529. <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'] ?>">
  530. <img src="../img/2rightarrow.gif" border="0" />
  531. </a>
  532. <?php
  533. }
  534. ?>
  535. </td>
  536. </tr>
  537. <?php
  538. $dataLearnpath[$i][] = $a_learnpath['name'];
  539. $dataLearnpath[$i][] = $progress.'%';
  540. $i++;
  541. }
  542. }
  543. else
  544. {
  545. echo " <tr>
  546. <td colspan='6'>
  547. ".get_lang('NoLearnpath')."
  548. </td>
  549. </tr>
  550. ";
  551. }
  552. ?>
  553. </table>
  554. </td>
  555. </tr>
  556. <tr> <!-- line about exercises -->
  557. <td>
  558. <table class="data_table">
  559. <tr>
  560. <th>
  561. <?php echo get_lang('Exercices'); ?>
  562. </th>
  563. <th>
  564. <?php echo get_lang('Score') ?>
  565. </th>
  566. <th>
  567. <?php echo get_lang('Attempts'); ?>
  568. </th>
  569. <th>
  570. <?php echo get_lang('CorrectTest'); ?>
  571. </th>
  572. </tr>
  573. <?php
  574. $csv_content[] = array();
  575. $csv_content[] = array(get_lang('Exercices'),get_lang('Score'),get_lang('Attempts'));
  576. $a_infosCours = CourseManager :: get_course_information($_GET['course']);
  577. $sql='SELECT visibility FROM '.$a_infosCours['db_name'].'.'.TABLE_TOOL_LIST.' WHERE name="quiz"';
  578. $resultVisibilityQuizz = api_sql_query($sql);
  579. if(mysql_result($resultVisibilityQuizz,0,'visibility')==1){
  580. $sqlExercices = " SELECT quiz.title,id
  581. FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
  582. WHERE active='1' ORDER BY quiz.title ASC
  583. ";
  584. $resultExercices = api_sql_query($sqlExercices);
  585. $i = 0;
  586. if(mysql_num_rows($resultExercices)>0)
  587. {
  588. while($a_exercices = mysql_fetch_array($resultExercices))
  589. {
  590. $sqlEssais = " SELECT COUNT(ex.exe_id) as essais
  591. FROM $tbl_stats_exercices AS ex
  592. WHERE ex.exe_cours_id = '".$a_infosCours['code']."'
  593. AND ex.exe_exo_id = ".$a_exercices['id']."
  594. AND exe_user_id='".$_GET["student"]."'"
  595. ;
  596. $resultEssais = api_sql_query($sqlEssais);
  597. $a_essais = mysql_fetch_array($resultEssais);
  598. $sqlScore = "SELECT exe_id, exe_result,exe_weighting
  599. FROM $tbl_stats_exercices
  600. WHERE exe_user_id = ".$_GET['student']."
  601. AND exe_cours_id = '".$a_infosCours['code']."'
  602. AND exe_exo_id = ".$a_exercices['id']."
  603. ORDER BY exe_date DESC LIMIT 1";
  604. $resultScore = api_sql_query($sqlScore);
  605. $score = 0;
  606. while($a_score = mysql_fetch_array($resultScore))
  607. {
  608. $score = $score + $a_score['exe_result'];
  609. $weighting = $weighting + $a_score['exe_weighting'];
  610. $exe_id = $a_score['exe_id'];
  611. }
  612. $pourcentageScore = 0;
  613. if($weighting!=0)
  614. {
  615. $pourcentageScore = round(($score*100)/$weighting);
  616. }
  617. $weighting = 0;
  618. $csv_content[] = array($a_exercices['title'], $pourcentageScore.' %', $a_essais['essais']);
  619. if($i%2==0){
  620. $s_css_class="row_odd";
  621. }
  622. else{
  623. $s_css_class="row_even";
  624. }
  625. $i++;
  626. echo "<tr class='$s_css_class'>
  627. <td>
  628. ";
  629. echo $a_exercices['title'];
  630. echo " </td>
  631. ";
  632. echo " <td align='right'>
  633. ";
  634. echo $pourcentageScore.' %';
  635. echo " </td>
  636. <td align='right'>
  637. ";
  638. echo $a_essais['essais'];
  639. echo " </td>
  640. <td align='center'>
  641. ";
  642. $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';
  643. $resultLastAttempt = api_sql_query($sql_last_attempt);
  644. if(Database::num_rows($resultLastAttempt)>0)
  645. {
  646. $id_last_attempt=mysql_result($resultLastAttempt,0,0);
  647. if($a_essais['essais']>0)
  648. 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>';
  649. }
  650. echo " </td>
  651. </tr>
  652. ";
  653. $dataExercices[$i][] = $a_exercices['title'];
  654. $dataExercices[$i][] = $pourcentageScore.'%';
  655. $dataExercices[$i][] = $a_essais['essais'];
  656. //$dataExercices[$i][] = corrections;
  657. $i++;
  658. }
  659. }
  660. else
  661. {
  662. echo " <tr>
  663. <td colspan='6'>
  664. ".get_lang('NoExercise')."
  665. </td>
  666. </tr>
  667. ";
  668. }
  669. }
  670. else
  671. {
  672. echo " <tr>
  673. <td colspan='6'>
  674. ".get_lang('NoExercise')."
  675. </td>
  676. </tr>
  677. ";
  678. }
  679. ?>
  680. </table>
  681. </td>
  682. </tr>
  683. <tr><!-- line about other tools -->
  684. <td>
  685. <table class="data_table">
  686. <?php
  687. $csv_content[] = array();
  688. $nb_assignments = Tracking :: count_student_assignments($a_infosUser['user_id'], $a_infosCours['code']);
  689. $messages = Tracking :: count_student_messages($a_infosUser['user_id'], $a_infosCours['code']);
  690. $links = Tracking :: count_student_visited_links($a_infosUser['user_id'], $a_infosCours['code']);
  691. $documents = Tracking :: count_student_downloaded_documents($a_infosUser['user_id'], $a_infosCours['code']);
  692. $csv_content[] = array(get_lang('Student_publication'), $nb_assignments);
  693. $csv_content[] = array(get_lang('Messages'), $messages);
  694. $csv_content[] = array(get_lang('LinksDetails'), $links);
  695. $csv_content[] = array(get_lang('DocumentsDetails'), $documents);
  696. ?>
  697. <tr>
  698. <th colspan="2">
  699. <?php echo get_lang('OtherTools'); ?>
  700. </th>
  701. </tr>
  702. <tr><!-- assignments -->
  703. <td width="40%">
  704. <?php echo get_lang('Student_publication') ?>
  705. </td>
  706. <td>
  707. <?php echo $nb_assignments ?>
  708. </td>
  709. </tr>
  710. <tr><!-- messages -->
  711. <td>
  712. <?php echo get_lang('Messages') ?>
  713. </td>
  714. <td>
  715. <?php echo $messages ?>
  716. </td>
  717. </tr>
  718. <tr><!-- links -->
  719. <td>
  720. <?php echo get_lang('LinksDetails') ?>
  721. </td>
  722. <td>
  723. <?php echo $links ?>
  724. </td>
  725. </tr>
  726. <tr><!-- documents -->
  727. <td>
  728. <?php echo get_lang('DocumentsDetails') ?>
  729. </td>
  730. <td>
  731. <?php echo $documents ?>
  732. </td>
  733. </tr>
  734. </table>
  735. </td>
  736. </tr>
  737. </table>
  738. <?php
  739. }
  740. else
  741. {
  742. ?>
  743. <tr>
  744. <th>
  745. <?php echo get_lang('Course'); ?>
  746. </th>
  747. <th>
  748. <?php echo get_lang('Time'); ?>
  749. </th>
  750. <th>
  751. <?php echo get_lang('Progress'); ?>
  752. </th>
  753. <th>
  754. <?php echo get_lang('Score'); ?>
  755. </th>
  756. <th>
  757. <?php echo get_lang('Details'); ?>
  758. </th>
  759. </tr>
  760. <?php
  761. if(!api_is_platform_admin()){
  762. // courses followed by user where we are coach
  763. if(!isset($_GET['id_coach'])){
  764. $a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
  765. }
  766. else{
  767. $a_courses = Tracking :: get_courses_followed_by_coach($_GET['id_coach']);
  768. }
  769. }
  770. if(count($a_courses)>0)
  771. {
  772. $csv_content[] = array();
  773. $csv_content[] = array(get_lang('Course'),get_lang('Time'),get_lang('Progress'),get_lang('Score'));
  774. foreach($a_courses as $course_code)
  775. {
  776. if(CourseManager :: is_user_subscribed_in_course($student_id,$course_code, true)){
  777. $course_infos = CourseManager :: get_course_information($course_code);
  778. $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($a_infosUser['user_id'], $course_code));
  779. $progress = Tracking :: get_avg_student_progress($a_infosUser['user_id'], $course_code).' %';
  780. $score = Tracking :: get_avg_student_score($a_infosUser['user_id'], $course_code).' %';
  781. $csv_content[] = array($course_infos['title'], $time_spent_on_course, $progress, $score);
  782. echo '
  783. <tr>
  784. <td align="right">
  785. '.$course_infos['title'].'
  786. </td>
  787. <td align="right">
  788. '.$time_spent_on_course.'
  789. </td>
  790. <td align="right">
  791. '.$progress.'
  792. </td>
  793. <td align="right">
  794. '.$score.'
  795. </td>';
  796. if(isset($_GET['id_coach']) && intval($_GET['id_coach'])!=0){
  797. echo '<td align="center" width="10">
  798. <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>
  799. </td>';
  800. }
  801. else{
  802. echo '<td align="center" width="10">
  803. <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>
  804. </td>';
  805. }
  806. echo '</tr>';
  807. }
  808. }
  809. }
  810. else
  811. {
  812. echo "<tr>
  813. <td colspan='5'>
  814. ".get_lang('NoCourse')."
  815. </td>
  816. </tr>
  817. ";
  818. }
  819. }//end of else !empty($details)
  820. ?>
  821. </table>
  822. <br />
  823. <?php
  824. if(!empty($_GET['details']) && $_GET['origin'] != 'tracking_course' && $_GET['origin'] != 'user_course')
  825. {
  826. ?>
  827. <br /><br />
  828. <?php
  829. }
  830. if(!empty($_GET['exe_id']))
  831. {
  832. $sqlExerciceDetails = " SELECT qq.question, qq.ponderation, qq.id
  833. FROM ".$a_infosCours['db_name'].".".$course_quiz_question." as qq
  834. INNER JOIN ".$a_infosCours['db_name'].".".$course_quiz_rel_question." as qrq
  835. ON qrq.question_id = qq.id
  836. AND qrq.exercice_id = ".$_GET['exe_id']
  837. ;
  838. $resultExerciceDetails = api_sql_query($sqlExerciceDetails);
  839. $sqlExName = " SELECT quiz.title
  840. FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
  841. WHERE quiz.id = ".$_GET['exe_id']
  842. ;
  843. $resultExName = api_sql_query($sqlExName);
  844. $a_exName = mysql_fetch_array($resultExName);
  845. echo "<table class='data_table'>
  846. <tr>
  847. <th colspan='2'>
  848. ".$a_exName['title']."
  849. </th>
  850. </tr>
  851. ";
  852. while($a_exerciceDetails = mysql_fetch_array($resultExerciceDetails))
  853. {
  854. $sqlAnswer = " SELECT qa.comment, qa.answer
  855. FROM ".$a_infosCours['db_name'].".".$course_quiz_answer." as qa
  856. WHERE qa.question_id = ".$a_exerciceDetails['id']
  857. ;
  858. $resultAnswer = api_sql_query($sqlAnswer);
  859. echo "<a name='infosExe'></a>";
  860. echo"
  861. <tr>
  862. <td colspan='2'>
  863. <strong>".$a_exerciceDetails['question'].' /'.$a_exerciceDetails['ponderation']."</strong>
  864. </td>
  865. </tr>
  866. ";
  867. while($a_answer = mysql_fetch_array($resultAnswer))
  868. {
  869. echo"
  870. <tr>
  871. <td>
  872. ".$a_answer['answer']."
  873. </td>
  874. <td>
  875. ";
  876. if(!empty($a_answer['comment']))
  877. echo $a_answer['comment'];
  878. else
  879. echo get_lang('NoComment');
  880. echo "
  881. </td>
  882. </tr>
  883. ";
  884. }
  885. }
  886. echo "</table>";
  887. }
  888. //YW - commented out because it doesn't seem to be used
  889. //$a_header = array_merge($a_headerLearnpath,$a_headerExercices,$a_headerProductions);
  890. }
  891. if($export_csv)
  892. {
  893. ob_end_clean();
  894. Export :: export_table_csv($csv_content, 'reporting_student');
  895. }
  896. /*
  897. ==============================================================================
  898. FOOTER
  899. ==============================================================================
  900. */
  901. Display::display_footer();
  902. ?>