courseLog.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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').' <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. while($quiz = Database::fetch_array($rs)) {
  194. $quiz_avg_score = 0;
  195. // get the scorn in exercises
  196. $sql = 'SELECT exe_result , exe_weighting
  197. FROM '.$TABLETRACK_EXERCISES.'
  198. WHERE exe_exo_id = '.$quiz['id'].'
  199. AND orig_lp_id = 0
  200. AND orig_lp_item_id = 0
  201. ORDER BY exe_date DESC';
  202. $rsAttempt = api_sql_query($sql, __FILE__, __LINE__);
  203. $nb_attempts = 0;
  204. while ($attempt = Database::fetch_array($rsAttempt)) {
  205. $nb_attempts++;
  206. $exe_weight=$attempt['exe_weighting'];
  207. if ($exe_weight>0) {
  208. $quiz_avg_score += $attempt['exe_result']/$exe_weight*100;
  209. }
  210. }
  211. if($nb_attempts>0) {
  212. $quiz_avg_score = $quiz_avg_score / $nb_attempts;
  213. }
  214. echo '<tr><td>'.$quiz['title'].'</td><td align="right">'.round($quiz_avg_score,1).' %</td></tr>';
  215. if ($export_csv) {
  216. $temp=array($quiz['title'],$quiz_avg_score);
  217. $csv_content[] = $temp;
  218. }
  219. }
  220. } else {
  221. echo '<tr><td>'.get_lang('NoExercises').'</td></tr>';
  222. if($export_csv) {
  223. $temp=array(get_lang('NoExercises'),'');
  224. $csv_content[] = $temp;
  225. }
  226. }
  227. echo '</table></div>';
  228. echo '<div class="clear"></div>';
  229. /**********************
  230. * FORUMS
  231. **********************/
  232. echo '<div class="admin_section">
  233. <h4>
  234. <img src="../img/forum.gif" align="absbottom">&nbsp;'.get_lang('Forum').' <a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a>
  235. </h4>
  236. <table class="data_table">';
  237. $count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($_course['id']);
  238. $count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($_course['id']);
  239. $count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($_course['id']);
  240. if ($export_csv) {
  241. $csv_content[] = array(get_lang('Forum'),'');
  242. $csv_content[] = array(get_lang('ForumForumsNumber'),$count_number_of_forums_by_course);
  243. $csv_content[] = array(get_lang('ForumThreadsNumber'),$count_number_of_threads_by_course);
  244. $csv_content[] = array(get_lang('ForumPostsNumber'),$count_number_of_posts_by_course);
  245. }
  246. echo '<tr><td>'.get_lang('ForumForumsNumber').'</td><td align="right">'.$count_number_of_forums_by_course.'</td></tr>';
  247. echo '<tr><td>'.get_lang('ForumThreadsNumber').'</td><td align="right">'.$count_number_of_threads_by_course.'</td></tr>';
  248. echo '<tr><td>'.get_lang('ForumPostsNumber').'</td><td align="right">'.$count_number_of_posts_by_course.'</td></tr>';
  249. echo '</table></div>';
  250. echo '<div class="clear"></div>';
  251. /**********************
  252. * CHAT
  253. **********************/
  254. echo '<div class="admin_section">
  255. <h4>
  256. <img src="../img/chat.gif" align="absbottom">&nbsp;'.get_lang('Chat').'</a>
  257. </h4>
  258. <table class="data_table">';
  259. $chat_connections_during_last_x_days_by_course = Tracking :: chat_connections_during_last_x_days_by_course($_course['id'],7);
  260. if ($export_csv) {
  261. $csv_content[] = array(get_lang('Chat'),'');
  262. $csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays'),'7'),$chat_connections_during_last_x_days_by_course);
  263. }
  264. echo '<tr><td>'.sprintf(get_lang('ChatConnectionsDuringLastXDays'),'7').'</td><td align="right">'.$chat_connections_during_last_x_days_by_course.'</td></tr>';
  265. echo '</table></div>';
  266. echo '<div class="clear"></div>';
  267. /**********************
  268. * TOOLS
  269. **********************/
  270. echo '<div class="admin_section">
  271. <h4>
  272. <img src="../img/acces_tool.gif" align="absbottom">&nbsp;'.get_lang('ToolsMostUsed').'
  273. </h4>
  274. <table class="data_table">';
  275. $sql = "SELECT access_tool, COUNT(DISTINCT access_user_id),count( access_tool ) as count_access_tool
  276. FROM $TABLETRACK_ACCESS
  277. WHERE access_tool IS NOT NULL
  278. AND access_cours_code = '$_cid'
  279. GROUP BY access_tool
  280. ORDER BY count_access_tool DESC
  281. LIMIT 0, 3";
  282. $rs = api_sql_query($sql, __FILE__, __LINE__);
  283. if ($export_csv) {
  284. $temp=array(get_lang('ToolsMostUsed'),'');
  285. $csv_content[] = $temp;
  286. }
  287. while ($row = Database::fetch_array($rs)) {
  288. echo ' <tr>
  289. <td>'.get_lang(ucfirst($row['access_tool'])).'</td>
  290. <td align="right">'.$row['count_access_tool'].' '.get_lang('Clicks').'</td>
  291. </tr>';
  292. if ($export_csv) {
  293. $temp=array(get_lang(ucfirst($row['access_tool'])),$row['count_access_tool'].' '.get_lang('Clicks'));
  294. $csv_content[] = $temp;
  295. }
  296. }
  297. echo '</table></div>';
  298. echo '<div class="clear"></div>';
  299. /***************************
  300. * DOCUMENTS
  301. ***************************/
  302. echo '<div class="admin_section">
  303. <h4>
  304. <img src="../img/documents.gif" align="absbottom">&nbsp;'.get_lang('DocumentsMostDownloaded').'
  305. </h4>
  306. <table class="data_table">';
  307. $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
  308. FROM $TABLETRACK_DOWNLOADS
  309. WHERE down_cours_id = '$_cid'
  310. GROUP BY down_doc_path
  311. ORDER BY count_down DESC
  312. LIMIT 0, 3";
  313. $rs = api_sql_query($sql, __FILE__, __LINE__);
  314. if ($export_csv) {
  315. $temp=array(get_lang('DocumentsMostDownloaded'),'');
  316. $csv_content[] = array('','');
  317. $csv_content[] = $temp;
  318. }
  319. if (Database::num_rows($rs)>0) {
  320. while($row = Database::fetch_array($rs)) {
  321. echo ' <tr>
  322. <td>'.$row['down_doc_path'].'</td>
  323. <td align="right">'.$row['count_down'].' '.get_lang('Clicks').'</td>
  324. </tr>';
  325. if ($export_csv) {
  326. $temp=array($row['down_doc_path'],$row['count_down'].' '.get_lang('Clicks'));
  327. $csv_content[] = $temp;
  328. }
  329. }
  330. } else {
  331. echo '<tr><td>'.get_lang('NoDocumentDownloaded').'</td></tr>';
  332. if ($export_csv) {
  333. $temp=array(get_lang('NoDocumentDownloaded'),'');
  334. $csv_content[] = $temp;
  335. }
  336. }
  337. echo '</table></div>';
  338. echo '<div class="clear"></div>';
  339. /***************************
  340. * LINKS
  341. ***************************/
  342. echo '<div class="admin_section">
  343. <h4>
  344. <img src="../img/link.gif" align="absbottom">&nbsp;'.get_lang('LinksMostClicked').'
  345. </h4>
  346. <table class="data_table">';
  347. $sql = "SELECT cl.title, cl.url,count(DISTINCT sl.links_user_id), count(cl.title) as count_visits
  348. FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
  349. WHERE sl.links_link_id = cl.id
  350. AND sl.links_cours_id = '$_cid'
  351. GROUP BY cl.title, cl.url
  352. ORDER BY count_visits DESC
  353. LIMIT 0, 3";
  354. $rs = api_sql_query($sql, __FILE__, __LINE__);
  355. if ($export_csv) {
  356. $temp=array(get_lang('LinksMostClicked'),'');
  357. $csv_content[] = array('','');
  358. $csv_content[] = $temp;
  359. }
  360. if (Database::num_rows($rs)>0) {
  361. while ($row = Database::fetch_array($rs)) {
  362. echo ' <tr>
  363. <td>'.$row['title'].'</td>
  364. <td align="right">'.$row['count_visits'].' '.get_lang('Clicks').'</td>
  365. </tr>';
  366. if($export_csv){
  367. $temp=array($row['title'],$row['count_visits'].' '.get_lang('Clicks'));
  368. $csv_content[] = $temp;
  369. }
  370. }
  371. } else {
  372. echo '<tr><td>'.get_lang('NoLinkVisited').'</td></tr>';
  373. if ($export_csv) {
  374. $temp=array(get_lang('NoLinkVisited'),'');
  375. $csv_content[] = $temp;
  376. }
  377. }
  378. echo '</table></div>';
  379. echo '<div class="clear"></div>';
  380. // send the csv file if asked
  381. if ($export_csv) {
  382. ob_end_clean();
  383. Export :: export_table_csv($csv_content, 'reporting_course_tracking');
  384. }
  385. } else {
  386. // else display student list with all the informations
  387. // BEGIN : form to remind inactives susers
  388. $form = new FormValidator('reminder_form','get',api_get_path(REL_CODE_PATH).'announcements/announcements.php');
  389. $renderer = $form->defaultRenderer();
  390. $renderer->setElementTemplate('<span>{label} {element}</span>&nbsp;<button class="save" type="submit">'.get_lang('SendNotification').'</button>','since');
  391. $options = array(
  392. 2 => '2 '.get_lang('Days'),
  393. 3 => '3 '.get_lang('Days'),
  394. 4 => '4 '.get_lang('Days'),
  395. 5 => '5 '.get_lang('Days'),
  396. 6 => '6 '.get_lang('Days'),
  397. 7 => '7 '.get_lang('Days'),
  398. 15 => '15 '.get_lang('Days'),
  399. 30 => '30 '.get_lang('Days')
  400. );
  401. $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);
  402. $el -> setSelected(7);
  403. $form -> addElement('hidden','action','add');
  404. $form -> addElement('hidden','remindallinactives','true');
  405. $form -> display();
  406. // END : form to remind inactives susers
  407. $tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : 0;
  408. $tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : 'DESC';
  409. if (count($a_students)>0) {
  410. $table = new SortableTable('tracking', 'count_student_in_course');
  411. $table -> set_header(0, get_lang('OfficialCode'), false, 'align="center"');
  412. $table -> set_header(1, get_lang('LastName'), true, 'align="center"');
  413. $table -> set_header(2, get_lang('FirstName'), false, 'align="center"');
  414. $table -> set_header(3, get_lang('Time'),false);
  415. $table -> set_header(4, get_lang('Progress'),false);
  416. $table -> set_header(5, get_lang('Score'),false);
  417. $table -> set_header(6, get_lang('Student_publication'),false);
  418. $table -> set_header(7, get_lang('Messages'),false);
  419. $table -> set_header(8, get_lang('FirstLogin'), false, 'align="center"');
  420. $table -> set_header(9, get_lang('LatestLogin'), false, 'align="center"');
  421. $table -> set_header(10, get_lang('Details'),false);
  422. if ($export_csv) {
  423. $csv_content[] = array ();
  424. }
  425. $all_datas = array();
  426. $course_code = $_course['id'];
  427. foreach ($a_students as $student_id => $student) {
  428. $student_datas = UserManager :: get_user_info_by_id($student_id);
  429. $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0 ;
  430. $nb_courses_student = 0;
  431. $avg_time_spent = Tracking :: get_time_spent_on_the_course($student_id, $course_code);
  432. $avg_student_score = Tracking :: get_avg_student_score($student_id, $course_code);
  433. $avg_student_progress = Tracking :: get_avg_student_progress($student_id, $course_code);
  434. $total_assignments = Tracking :: count_student_assignments($student_id, $course_code);
  435. $total_messages = Tracking :: count_student_messages($student_id, $course_code);
  436. $row = array();
  437. $row[] = $student_datas['official_code'];
  438. $row[] = $student_datas['lastname'];
  439. $row[] = $student_datas['firstname'];
  440. $row[] = api_time_to_hms($avg_time_spent);
  441. if (is_null($avg_student_score)) {$avg_student_score=0;}
  442. if (is_null($avg_student_progress)) {$avg_student_progress=0;}
  443. $row[] = $avg_student_progress.' %';
  444. $row[] = $avg_student_score.' %';
  445. $row[] = $total_assignments;
  446. $row[] = $total_messages;
  447. $row[] = Tracking :: get_first_connection_date_on_the_course($student_id, $course_code);
  448. $row[] = Tracking :: get_last_connection_date_on_the_course($student_id, $course_code);
  449. if ($export_csv) {
  450. $row[8] = strip_tags($row[8]);
  451. $csv_content[] = $row;
  452. }
  453. $row[] = '<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>';
  454. $all_datas[] = $row;
  455. }
  456. usort($all_datas, 'sort_users');
  457. $page = $table->get_pager()->getCurrentPageID();
  458. $all_datas = array_slice($all_datas, ($page-1)*$table -> per_page, $table -> per_page);
  459. if ($export_csv) {
  460. usort($csv_content, 'sort_users');
  461. }
  462. foreach ($all_datas as $row) {
  463. $table -> addRow($row,'align="right"');
  464. }
  465. $table -> setColAttributes(0,array('align'=>'left'));
  466. $table -> setColAttributes(1,array('align'=>'left'));
  467. $table -> setColAttributes(2,array('align'=>'left'));
  468. $table -> setColAttributes(7,array('align'=>'right'));
  469. $table -> setColAttributes(8,array('align'=>'center'));
  470. $table -> setColAttributes(9,array('align'=>'center'));
  471. $table -> display();
  472. } else {
  473. echo get_lang('NoUsersInCourseTracking');
  474. }
  475. // send the csv file if asked
  476. if ($export_csv) {
  477. $csv_content[] = array (
  478. get_lang('OfficialCode'),
  479. get_lang('LastName'),
  480. get_lang('FirstName'),
  481. get_lang('Time'),
  482. get_lang('Progress'),
  483. get_lang('Score'),
  484. get_lang('Student_publication'),
  485. get_lang('Messages'),
  486. get_lang('FirstLogin'),
  487. get_lang('LatestLogin')
  488. );
  489. ob_end_clean();
  490. Export :: export_table_csv($csv_content, 'reporting_student_list');
  491. }
  492. }
  493. ?>
  494. </table>
  495. <?php
  496. Display::display_footer();