courseLog.php 22 KB

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