courseLog.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <?php //$id: $
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. ==============================================================================
  5. * @author Thomas Depraetere
  6. * @author Hugues Peeters
  7. * @author Christophe Gesche
  8. * @author Sebastien Piraux
  9. * @author Toon Keppens (Vi-Host.net)
  10. *
  11. * @package dokeos.tracking
  12. ==============================================================================
  13. */
  14. /**
  15. * INIT SECTION
  16. */
  17. $pathopen = isset($_REQUEST['pathopen']) ? $_REQUEST['pathopen'] : null;
  18. // name of the language file that needs to be included
  19. $language_file[] = 'admin';
  20. $language_file[] = 'tracking';
  21. $language_file[] = 'scorm';
  22. require '../inc/global.inc.php';
  23. $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
  24. if (!$is_allowedToTrack) {
  25. Display :: display_header(null);
  26. api_not_allowed();
  27. Display :: display_footer();
  28. }
  29. //includes for SCORM and LP
  30. require_once '../newscorm/learnpath.class.php';
  31. require_once '../newscorm/learnpathItem.class.php';
  32. require_once '../newscorm/learnpathList.class.php';
  33. require_once '../newscorm/scorm.class.php';
  34. require_once '../newscorm/scormItem.class.php';
  35. require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
  36. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  37. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  38. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  39. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  40. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  41. if ($export_csv) {
  42. ob_start();
  43. }
  44. $csv_content = array();
  45. // charset determination
  46. if (!empty($_GET['scormcontopen'])) {
  47. $tbl_lp = Database::get_course_table('lp');
  48. $contopen = (int) $_GET['scormcontopen'];
  49. $sql = "SELECT default_encoding FROM $tbl_lp WHERE id = ".$contopen;
  50. $res = api_sql_query($sql,__FILE__,__LINE__);
  51. $row = Database::fetch_array($res);
  52. $lp_charset = $row['default_encoding'];
  53. }
  54. $htmlHeadXtra[] = "<style type='text/css'>
  55. /*<![CDATA[*/
  56. .secLine {background-color : #E6E6E6;}
  57. .content {padding-left : 15px;padding-right : 15px; }
  58. .specialLink{color : #0000FF;}
  59. /*]]>*/
  60. </style>
  61. <style media='print' type='text/css'>
  62. </style>";
  63. /*
  64. -----------------------------------------------------------
  65. Constants and variables
  66. -----------------------------------------------------------
  67. */
  68. // regroup table names for maintenance purpose
  69. $TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
  70. $TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
  71. $TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
  72. $TABLETRACK_ACCESS_2 = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  73. $TABLETRACK_EXERCISES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  74. $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  75. $TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
  76. $TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
  77. $table_user = Database::get_main_table(TABLE_MAIN_USER);
  78. $TABLEQUIZ = Database :: get_course_table(TABLE_QUIZ_TEST);
  79. //$table_scormdata = Database::get_scorm_table(TABLE_SCORM_SCO_DATA);
  80. //$table_scormmain = Database::get_scorm_table(TABLE_SCORM_MAIN);
  81. //$tbl_learnpath_main = Database::get_course_table(TABLE_LEARNPATH_MAIN);
  82. //$tbl_learnpath_item = Database::get_course_table(TABLE_LEARNPATH_ITEM);
  83. //$tbl_learnpath_chapter = Database::get_course_table(TABLE_LEARNPATH_CHAPTER);
  84. $tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
  85. $tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
  86. $tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
  87. $tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
  88. if (isset($_GET['origin']) && $_GET['origin']=='resume_session') {
  89. $interbreadcrumb[]=array('url' => '../admin/index.php','name' => get_lang('PlatformAdmin'));
  90. $interbreadcrumb[]=array('url' => '../admin/session_list.php','name' => get_lang('SessionList'));
  91. $interbreadcrumb[]=array('url' => '../admin/resume_session.php?id_session='.$_SESSION['id_session'],'name' => get_lang('SessionOverview'));
  92. }
  93. $view = (isset($_REQUEST['view'])?$_REQUEST['view']:'');
  94. $nameTools = get_lang('Tracking');
  95. Display::display_header($nameTools, 'Tracking');
  96. require api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
  97. require '../resourcelinker/resourcelinker.inc.php';
  98. $a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, (empty($_SESSION['id_session'])?null:$_SESSION['id_session']));
  99. $nbStudents = count($a_students);
  100. /**
  101. * count the number of students in this course (used for SortableTable)
  102. */
  103. function count_student_in_course() {
  104. global $nbStudents;
  105. return $nbStudents;
  106. }
  107. function sort_users($a,$b) {
  108. $a = trim(strtolower($a[$_SESSION['tracking_column']]));
  109. $b = trim(strtolower($b[$_SESSION['tracking_column']]));
  110. if ($_SESSION['tracking_direction'] == 'DESC') {
  111. return strcmp($b, $a);
  112. } else {
  113. return strcmp($a, $b);
  114. }
  115. }
  116. /*
  117. ==============================================================================
  118. MAIN CODE
  119. ==============================================================================
  120. */
  121. echo '<div class="actions">';
  122. if ($_GET['studentlist'] == 'false') {
  123. echo '<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|&nbsp;'.get_lang('CourseTracking');
  124. } else {
  125. echo get_lang('StudentsTracking').' | <a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>';
  126. }
  127. echo '&nbsp;<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>';
  128. if($_GET['studentlist'] == 'false') {
  129. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&studentlist=false"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
  130. } else {
  131. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
  132. }
  133. echo '</div>';
  134. if($_GET['studentlist'] == 'false') {
  135. echo'<br /><br />';
  136. /***************************
  137. * LEARNING PATHS
  138. ***************************/
  139. echo '<div class="admin_section">
  140. <h4>
  141. <img src="../img/scormbuilder.gif" align="absbottom">&nbsp;'.get_lang('AverageProgressInLearnpath').'
  142. </h4>
  143. <table class="data_table">';
  144. $list = new LearnpathList($student);
  145. $flat_list = $list->get_flat_list();
  146. if ($export_csv) {
  147. $temp=array(get_lang('AverageProgressInLearnpath'),'');
  148. $csv_content[] = array('','');
  149. $csv_content[] = $temp;
  150. }
  151. if (count($flat_list)>0) {
  152. foreach ($flat_list as $lp_id => $lp) {
  153. $lp_avg_progress = 0;
  154. foreach ($a_students as $student_id => $student) {
  155. // get the progress in learning pathes
  156. $lp_avg_progress += learnpath::get_db_progress($lp_id,$student_id);
  157. }
  158. if($nbStudents > 0) {
  159. $lp_avg_progress = $lp_avg_progress / $nbStudents;
  160. }
  161. echo '<tr><td>'.$lp['lp_name'].'</td><td align="right">'.round($lp_avg_progress,1).' %</td></tr>';
  162. if($export_csv) {
  163. $temp=array($lp['lp_name'],$lp_avg_progress);
  164. $csv_content[] = $temp;
  165. }
  166. }
  167. } else {
  168. echo '<tr><td>'.get_lang('NoLearningPath').'</td></tr>';
  169. if ($export_csv) {
  170. $temp=array(get_lang('NoLearningPath'),'');
  171. $csv_content[] = $temp;
  172. }
  173. }
  174. echo '</table></div>';
  175. echo '<div class="clear"></div>';
  176. /***************************
  177. * EXERCICES
  178. ***************************/
  179. echo '<div class="admin_section">
  180. <h4>
  181. <img src="../img/quiz.gif" align="absbottom">&nbsp;'.get_lang('AverageResultsToTheExercices').' &nbsp;-&nbsp;<a href="../exercice/exercice.php?'.api_get_cidreq().'&show=result">'.get_lang('SeeDetail').'</a>
  182. </h4>
  183. <table class="data_table">';
  184. $sql = "SELECT id, title
  185. FROM $TABLEQUIZ WHERE active <> -1";
  186. $rs = api_sql_query($sql, __FILE__, __LINE__);
  187. if ($export_csv) {
  188. $temp=array(get_lang('AverageProgressInLearnpath'),'');
  189. $csv_content[] = array('','');
  190. $csv_content[] = $temp;
  191. }
  192. if (Database::num_rows($rs)>0) {
  193. // gets course actual administrators
  194. $sql = "SELECT user.user_id FROM $table_user user, $TABLECOURSUSER course_user
  195. WHERE course_user.user_id=user.user_id AND course_user.course_code='".api_get_course_id()."' AND course_user.status <> '1' ";
  196. $res = api_sql_query($sql,__FILE__,__LINE__);
  197. $student_ids = array();
  198. while($row = Database::fetch_row($res)) {
  199. $student_ids[] = $row[0];
  200. }
  201. $count_students = count($student_ids);
  202. while($quiz = Database::fetch_array($rs)) {
  203. $quiz_avg_score = 0;
  204. if($count_students > 0) {
  205. foreach($student_ids as $student_id) {
  206. // get the scorn in exercises
  207. $sql = 'SELECT exe_result , exe_weighting
  208. FROM '.$TABLETRACK_EXERCISES.'
  209. WHERE exe_exo_id = '.$quiz['id'].'
  210. AND exe_user_id = '.(int)$student_id.'
  211. AND exe_cours_id = "'.api_get_course_id().'"
  212. AND orig_lp_id = 0
  213. AND orig_lp_item_id = 0
  214. ORDER BY exe_date DESC';
  215. $rsAttempt = api_sql_query($sql, __FILE__, __LINE__);
  216. $nb_attempts = 0;
  217. $avg_student_score = 0;
  218. while ($attempt = Database::fetch_array($rsAttempt)) {
  219. $nb_attempts++;
  220. $exe_weight=$attempt['exe_weighting'];
  221. if ($exe_weight>0) {
  222. $avg_student_score += round(($attempt['exe_result']/$exe_weight*100),2);
  223. }
  224. }
  225. if ($nb_attempts>0) {
  226. $avg_student_score = $avg_student_score / $nb_attempts;
  227. }
  228. $quiz_avg_score += $avg_student_score;
  229. }
  230. }
  231. echo '<tr><td>'.$quiz['title'].'</td><td align="right">'.round(($quiz_avg_score/$count_students),2).' %</td></tr>';
  232. if ($export_csv) {
  233. $temp=array($quiz['title'],$quiz_avg_score);
  234. $csv_content[] = $temp;
  235. }
  236. }
  237. } else {
  238. echo '<tr><td>'.get_lang('NoExercises').'</td></tr>';
  239. if($export_csv) {
  240. $temp=array(get_lang('NoExercises'),'');
  241. $csv_content[] = $temp;
  242. }
  243. }
  244. echo '</table></div>';
  245. echo '<div class="clear"></div>';
  246. /**********************
  247. * FORUMS
  248. **********************/
  249. echo '<div class="admin_section">
  250. <h4>
  251. <img src="../img/forum.gif" align="absbottom">&nbsp;'.get_lang('Forum').'&nbsp;-&nbsp;<a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a>
  252. </h4>
  253. <table class="data_table">';
  254. $count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($_course['id']);
  255. $count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($_course['id']);
  256. $count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($_course['id']);
  257. if ($export_csv) {
  258. $csv_content[] = array(get_lang('Forum'),'');
  259. $csv_content[] = array(get_lang('ForumForumsNumber'),$count_number_of_forums_by_course);
  260. $csv_content[] = array(get_lang('ForumThreadsNumber'),$count_number_of_threads_by_course);
  261. $csv_content[] = array(get_lang('ForumPostsNumber'),$count_number_of_posts_by_course);
  262. }
  263. echo '<tr><td>'.get_lang('ForumForumsNumber').'</td><td align="right">'.$count_number_of_forums_by_course.'</td></tr>';
  264. echo '<tr><td>'.get_lang('ForumThreadsNumber').'</td><td align="right">'.$count_number_of_threads_by_course.'</td></tr>';
  265. echo '<tr><td>'.get_lang('ForumPostsNumber').'</td><td align="right">'.$count_number_of_posts_by_course.'</td></tr>';
  266. echo '</table></div>';
  267. echo '<div class="clear"></div>';
  268. /**********************
  269. * CHAT
  270. **********************/
  271. echo '<div class="admin_section">
  272. <h4>
  273. <img src="../img/chat.gif" align="absbottom">&nbsp;'.get_lang('Chat').'</a>
  274. </h4>
  275. <table class="data_table">';
  276. $chat_connections_during_last_x_days_by_course = Tracking :: chat_connections_during_last_x_days_by_course($_course['id'],7);
  277. if ($export_csv) {
  278. $csv_content[] = array(get_lang('Chat'),'');
  279. $csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays'),'7'),$chat_connections_during_last_x_days_by_course);
  280. }
  281. echo '<tr><td>'.sprintf(get_lang('ChatConnectionsDuringLastXDays'),'7').'</td><td align="right">'.$chat_connections_during_last_x_days_by_course.'</td></tr>';
  282. echo '</table></div>';
  283. echo '<div class="clear"></div>';
  284. /**********************
  285. * TOOLS
  286. **********************/
  287. echo '<div class="admin_section">
  288. <h4>
  289. <img src="../img/acces_tool.gif" align="absbottom">&nbsp;'.get_lang('ToolsMostUsed').'
  290. </h4>
  291. <table class="data_table">';
  292. $sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool ) as count_access_tool
  293. FROM $TABLETRACK_ACCESS
  294. WHERE access_tool IS NOT NULL
  295. AND access_cours_code = '$_cid'
  296. GROUP BY access_tool
  297. ORDER BY count_access_tool DESC
  298. LIMIT 0, 3";
  299. $rs = api_sql_query($sql, __FILE__, __LINE__);
  300. if ($export_csv) {
  301. $temp=array(get_lang('ToolsMostUsed'),'');
  302. $csv_content[] = $temp;
  303. }
  304. while ($row = Database::fetch_array($rs)) {
  305. echo ' <tr>
  306. <td>'.get_lang(ucfirst($row['access_tool'])).'</td>
  307. <td align="right">'.$row['count_access_tool'].' '.get_lang('Clicks').'</td>
  308. </tr>';
  309. if ($export_csv) {
  310. $temp=array(get_lang(ucfirst($row['access_tool'])),$row['count_access_tool'].' '.get_lang('Clicks'));
  311. $csv_content[] = $temp;
  312. }
  313. }
  314. echo '</table></div>';
  315. echo '<div class="clear"></div>';
  316. /***************************
  317. * DOCUMENTS
  318. ***************************/
  319. echo '<div class="admin_section">
  320. <h4>
  321. <img src="../img/documents.gif" align="absbottom">&nbsp;'.get_lang('DocumentsMostDownloaded').'
  322. </h4>
  323. <table class="data_table">';
  324. $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
  325. FROM $TABLETRACK_DOWNLOADS
  326. WHERE down_cours_id = '$_cid'
  327. GROUP BY down_doc_path
  328. ORDER BY count_down DESC
  329. LIMIT 0, 3";
  330. $rs = api_sql_query($sql, __FILE__, __LINE__);
  331. if ($export_csv) {
  332. $temp=array(get_lang('DocumentsMostDownloaded'),'');
  333. $csv_content[] = array('','');
  334. $csv_content[] = $temp;
  335. }
  336. if (Database::num_rows($rs)>0) {
  337. while($row = Database::fetch_array($rs)) {
  338. echo ' <tr>
  339. <td>'.$row['down_doc_path'].'</td>
  340. <td align="right">'.$row['count_down'].' '.get_lang('Clicks').'</td>
  341. </tr>';
  342. if ($export_csv) {
  343. $temp=array($row['down_doc_path'],$row['count_down'].' '.get_lang('Clicks'));
  344. $csv_content[] = $temp;
  345. }
  346. }
  347. } else {
  348. echo '<tr><td>'.get_lang('NoDocumentDownloaded').'</td></tr>';
  349. if ($export_csv) {
  350. $temp=array(get_lang('NoDocumentDownloaded'),'');
  351. $csv_content[] = $temp;
  352. }
  353. }
  354. echo '</table></div>';
  355. echo '<div class="clear"></div>';
  356. /***************************
  357. * LINKS
  358. ***************************/
  359. echo '<div class="admin_section">
  360. <h4>
  361. <img src="../img/link.gif" align="absbottom">&nbsp;'.get_lang('LinksMostClicked').'
  362. </h4>
  363. <table class="data_table">';
  364. $sql = "SELECT cl.title, cl.url,count(DISTINCT sl.links_user_id), count(cl.title) as count_visits
  365. FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
  366. WHERE sl.links_link_id = cl.id
  367. AND sl.links_cours_id = '$_cid'
  368. GROUP BY cl.title, cl.url
  369. ORDER BY count_visits DESC
  370. LIMIT 0, 3";
  371. $rs = api_sql_query($sql, __FILE__, __LINE__);
  372. if ($export_csv) {
  373. $temp=array(get_lang('LinksMostClicked'),'');
  374. $csv_content[] = array('','');
  375. $csv_content[] = $temp;
  376. }
  377. if (Database::num_rows($rs)>0) {
  378. while ($row = Database::fetch_array($rs)) {
  379. echo ' <tr>
  380. <td>'.$row['title'].'</td>
  381. <td align="right">'.$row['count_visits'].' '.get_lang('Clicks').'</td>
  382. </tr>';
  383. if($export_csv){
  384. $temp=array($row['title'],$row['count_visits'].' '.get_lang('Clicks'));
  385. $csv_content[] = $temp;
  386. }
  387. }
  388. } else {
  389. echo '<tr><td>'.get_lang('NoLinkVisited').'</td></tr>';
  390. if ($export_csv) {
  391. $temp=array(get_lang('NoLinkVisited'),'');
  392. $csv_content[] = $temp;
  393. }
  394. }
  395. echo '</table></div>';
  396. echo '<div class="clear"></div>';
  397. // send the csv file if asked
  398. if ($export_csv) {
  399. ob_end_clean();
  400. Export :: export_table_csv($csv_content, 'reporting_course_tracking');
  401. }
  402. } else {
  403. // else display student list with all the informations
  404. // BEGIN : form to remind inactives susers
  405. $form = new FormValidator('reminder_form','get',api_get_path(REL_CODE_PATH).'announcements/announcements.php');
  406. $renderer = $form->defaultRenderer();
  407. $renderer->setElementTemplate('<span>{label} {element}</span>&nbsp;<button class="save" type="submit">'.get_lang('SendNotification').'</button>','since');
  408. $options = array(
  409. 2 => '2 '.get_lang('Days'),
  410. 3 => '3 '.get_lang('Days'),
  411. 4 => '4 '.get_lang('Days'),
  412. 5 => '5 '.get_lang('Days'),
  413. 6 => '6 '.get_lang('Days'),
  414. 7 => '7 '.get_lang('Days'),
  415. 15 => '15 '.get_lang('Days'),
  416. 30 => '30 '.get_lang('Days')
  417. );
  418. $el = $form -> addElement('select','since','<img width="22" align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" border="0" />'.get_lang('RemindInactivesLearnersSince'),$options);
  419. $el -> setSelected(7);
  420. $form -> addElement('hidden','action','add');
  421. $form -> addElement('hidden','remindallinactives','true');
  422. $form -> display();
  423. // END : form to remind inactives susers
  424. $tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : 0;
  425. $tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : 'DESC';
  426. if (count($a_students)>0) {
  427. $table = new SortableTable('tracking', 'count_student_in_course');
  428. $table -> set_header(0, get_lang('OfficialCode'), false, 'align="center"');
  429. $table -> set_header(1, get_lang('LastName'), true, 'align="center"');
  430. $table -> set_header(2, get_lang('FirstName'), false, 'align="center"');
  431. $table -> set_header(3, get_lang('TrainingTime'),false);
  432. $table -> set_header(4, get_lang('CourseProgress'),false);
  433. $table -> set_header(5, get_lang('Score'),false);
  434. $table -> set_header(6, get_lang('Student_publication'),false);
  435. $table -> set_header(7, get_lang('Messages'),false);
  436. $table -> set_header(8, get_lang('FirstLogin'), false, 'align="center"');
  437. $table -> set_header(9, get_lang('LatestLogin'), false, 'align="center"');
  438. $table -> set_header(10, get_lang('Details'),false);
  439. if ($export_csv) {
  440. $csv_content[] = array ();
  441. }
  442. $all_datas = array();
  443. $course_code = $_course['id'];
  444. foreach ($a_students as $student_id => $student) {
  445. $student_datas = UserManager :: get_user_info_by_id($student_id);
  446. $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0 ;
  447. $nb_courses_student = 0;
  448. $avg_time_spent = Tracking :: get_time_spent_on_the_course($student_id, $course_code);
  449. $avg_student_score = Tracking :: get_average_test_scorm_and_lp($student_id, $course_code);
  450. $avg_student_progress = Tracking :: get_avg_student_progress($student_id, $course_code);
  451. $total_assignments = Tracking :: count_student_assignments($student_id, $course_code);
  452. $total_messages = Tracking :: count_student_messages($student_id, $course_code);
  453. $row = array();
  454. $row[] = $student_datas['official_code'];
  455. $row[] = $student_datas['lastname'];
  456. $row[] = $student_datas['firstname'];
  457. $row[] = api_time_to_hms($avg_time_spent);
  458. if (is_null($avg_student_score)) {$avg_student_score=0;}
  459. if (is_null($avg_student_progress)) {$avg_student_progress=0;}
  460. $row[] = $avg_student_progress.' %';
  461. $row[] = $avg_student_score.' %';
  462. $row[] = $total_assignments;
  463. $row[] = $total_messages;
  464. $row[] = Tracking :: get_first_connection_date_on_the_course($student_id, $course_code);
  465. $row[] = Tracking :: get_last_connection_date_on_the_course($student_id, $course_code);
  466. if ($export_csv) {
  467. $row[8] = strip_tags($row[8]);
  468. $csv_content[] = $row;
  469. }
  470. $row[] = '<center><a href="../mySpace/myStudents.php?student='.$student_id.'&details=true&course='.$course_code.'&origin=tracking_course"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
  471. $all_datas[] = $row;
  472. }
  473. usort($all_datas, 'sort_users');
  474. $page = $table->get_pager()->getCurrentPageID();
  475. $all_datas = array_slice($all_datas, ($page-1)*$table -> per_page, $table -> per_page);
  476. if ($export_csv) {
  477. usort($csv_content, 'sort_users');
  478. }
  479. foreach ($all_datas as $row) {
  480. $table -> addRow($row,'align="right"');
  481. }
  482. $table -> setColAttributes(0,array('align'=>'left'));
  483. $table -> setColAttributes(1,array('align'=>'left'));
  484. $table -> setColAttributes(2,array('align'=>'left'));
  485. $table -> setColAttributes(7,array('align'=>'right'));
  486. $table -> setColAttributes(8,array('align'=>'center'));
  487. $table -> setColAttributes(9,array('align'=>'center'));
  488. $table -> display();
  489. } else {
  490. echo get_lang('NoUsersInCourseTracking');
  491. }
  492. // send the csv file if asked
  493. if ($export_csv) {
  494. $csv_content[] = array (
  495. get_lang('OfficialCode'),
  496. get_lang('LastName'),
  497. get_lang('FirstName'),
  498. get_lang('TrainingTime'),
  499. get_lang('CourseProgress'),
  500. get_lang('Score'),
  501. get_lang('Student_publication'),
  502. get_lang('Messages'),
  503. get_lang('FirstLogin'),
  504. get_lang('LatestLogin')
  505. );
  506. ob_end_clean();
  507. Export :: export_table_csv($csv_content, 'reporting_student_list');
  508. }
  509. }
  510. ?>
  511. </table>
  512. <?php
  513. Display::display_footer();