courseLog.php 24 KB

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