myStudents.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Implements the tracking of students in the Reporting pages
  5. * @package chamilo.mySpace
  6. */
  7. // name of the language file that needs to be included
  8. $language_file = array('registration', 'index', 'tracking', 'exercice', 'admin', 'gradebook', 'survey');
  9. require_once '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  11. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  12. require_once api_get_path(SYS_CODE_PATH).'mySpace/myspace.lib.php';
  13. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
  14. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
  15. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
  16. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
  17. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
  18. require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
  19. require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php';
  20. api_block_anonymous_users();
  21. if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) {
  22. // Check if the user is tutor of the course
  23. $user_course_status = CourseManager::get_tutor_in_course_status(api_get_user_id(), api_get_course_id());
  24. if ($user_course_status != 1) {
  25. api_not_allowed(true);
  26. }
  27. }
  28. $htmlHeadXtra[] = '<script>
  29. function show_image(image,width,height) {
  30. width = parseInt(width) + 20;
  31. height = parseInt(height) + 20;
  32. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
  33. }
  34. </script>';
  35. $export_csv = isset ($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  36. if ($export_csv) {
  37. ob_start();
  38. }
  39. $csv_content = array();
  40. $from_myspace = false;
  41. if (isset ($_GET['from']) && $_GET['from'] == 'myspace') {
  42. $from_myspace = true;
  43. $this_section = SECTION_TRACKING;
  44. } else {
  45. $this_section = SECTION_COURSES;
  46. }
  47. $nameTools = get_lang('StudentDetails');
  48. $get_course_code = Security :: remove_XSS($_GET['course']);
  49. if (isset($_GET['details'])) {
  50. if (!empty ($_GET['origin']) && $_GET['origin'] == 'user_course') {
  51. $course_info = CourseManager :: get_course_information($get_course_code);
  52. if (empty ($cidReq)) {
  53. $interbreadcrumb[] = array (
  54. "url" => api_get_path(WEB_COURSE_PATH) . $course_info['directory'],
  55. 'name' => $course_info['title']
  56. );
  57. }
  58. $interbreadcrumb[] = array (
  59. "url" => "../user/user.php?cidReq=" . $get_course_code,
  60. "name" => get_lang("Users")
  61. );
  62. } else
  63. if (!empty ($_GET['origin']) && $_GET['origin'] == 'tracking_course') {
  64. $course_info = CourseManager :: get_course_information($get_course_code);
  65. if (empty ($cidReq)) {
  66. //$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['title']);
  67. }
  68. $interbreadcrumb[] = array (
  69. "url" => "../tracking/courseLog.php?cidReq=" . $get_course_code . '&studentlist=true&id_session=' . (empty ($_SESSION['id_session']) ? '' : $_SESSION['id_session']),
  70. "name" => get_lang("Tracking")
  71. );
  72. } else
  73. if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  74. $interbreadcrumb[] = array (
  75. 'url' => '../admin/index.php',
  76. "name" => get_lang('PlatformAdmin')
  77. );
  78. $interbreadcrumb[] = array (
  79. 'url' => "../admin/session_list.php",
  80. "name" => get_lang('SessionList')
  81. );
  82. $interbreadcrumb[] = array (
  83. 'url' => "../admin/resume_session.php?id_session=" . Security :: remove_XSS($_GET['id_session']),
  84. "name" => get_lang('SessionOverview')
  85. );
  86. } else {
  87. $interbreadcrumb[] = array (
  88. "url" => "index.php",
  89. "name" => get_lang('MySpace')
  90. );
  91. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  92. $interbreadcrumb[] = array (
  93. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  94. "name" => get_lang("CoachStudents")
  95. );
  96. $interbreadcrumb[] = array (
  97. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']) . '&id_coach=' . Security :: remove_XSS($_GET['id_coach']),
  98. "name" => get_lang("StudentDetails")
  99. );
  100. } else {
  101. $interbreadcrumb[] = array (
  102. "url" => "student.php",
  103. "name" => get_lang("MyStudents")
  104. );
  105. $interbreadcrumb[] = array (
  106. "url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
  107. "name" => get_lang("StudentDetails")
  108. );
  109. }
  110. }
  111. $nameTools = get_lang("DetailsStudentInCourse");
  112. } else {
  113. if (!empty ($_GET['origin']) && $_GET['origin'] == 'resume_session') {
  114. $interbreadcrumb[] = array (
  115. 'url' => '../admin/index.php',
  116. "name" => get_lang('PlatformAdmin')
  117. );
  118. $interbreadcrumb[] = array (
  119. 'url' => "../admin/session_list.php",
  120. "name" => get_lang('SessionList')
  121. );
  122. $interbreadcrumb[] = array (
  123. 'url' => "../admin/resume_session.php?id_session=" . Security :: remove_XSS($_GET['id_session']),
  124. "name" => get_lang('SessionOverview')
  125. );
  126. } else {
  127. $interbreadcrumb[] = array (
  128. "url" => "index.php",
  129. "name" => get_lang('MySpace')
  130. );
  131. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  132. if (isset ($_GET['id_session']) && intval($_GET['id_session']) != 0) {
  133. $interbreadcrumb[] = array (
  134. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']) . "&id_session=" . $_GET['id_session'],
  135. "name" => get_lang("CoachStudents")
  136. );
  137. } else {
  138. $interbreadcrumb[] = array (
  139. "url" => "student.php?id_coach=" . Security :: remove_XSS($_GET['id_coach']),
  140. "name" => get_lang("CoachStudents")
  141. );
  142. }
  143. } else {
  144. $interbreadcrumb[] = array (
  145. "url" => "student.php",
  146. "name" => get_lang("MyStudents")
  147. );
  148. }
  149. }
  150. }
  151. // Database Table Definitions
  152. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  153. $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  154. if (isset($_GET['user_id']) && $_GET['user_id'] != "") {
  155. $user_id = intval($_GET['user_id']);
  156. } else {
  157. $user_id = api_get_user_id();
  158. }
  159. $session_id = intval($_GET['id_session']);
  160. if (empty($session_id)) {
  161. $session_id = api_get_session_id();
  162. }
  163. $student_id = intval($_GET['student']);
  164. // Action behaviour
  165. $check= Security::check_token('get');
  166. if ($check) {
  167. switch ($_GET['action']) {
  168. case 'reset_lp' :
  169. $course = isset($_GET['course']) ? $_GET['course']:"";
  170. $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']):"";
  171. if (api_is_allowed_to_edit() && !empty($course) && !empty($lp_id) && !empty($student_id)) {
  172. $course_info = api_get_course_info($course);
  173. delete_student_lp_events($student_id, $lp_id, $course_info, $session_id);
  174. //@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334
  175. $message = Display::return_message(get_lang('LPWasReset'),'success');
  176. }
  177. break;
  178. default:
  179. break;
  180. }
  181. Security::clear_token();
  182. }
  183. // infos about user
  184. $user_info = api_get_user_info($student_id);
  185. $courses_in_session = array();
  186. //See #4676
  187. $drh_can_access_all_courses = false;
  188. if (api_is_drh()) {
  189. $drh_can_access_all_courses = true;
  190. }
  191. $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
  192. $courses_in_session_by_coach = array();
  193. $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
  194. //RRHH or session admin
  195. if (api_is_session_admin() || api_is_drh()) {
  196. $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
  197. $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
  198. if (!empty($session_by_session_admin)) {
  199. foreach ($session_by_session_admin as $session_coached_by_user) {
  200. $courses_followed_by_coach = Tracking :: get_courses_list_from_session($session_coached_by_user['id']);
  201. $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
  202. }
  203. }
  204. }
  205. // Teacher or admin
  206. if (!empty($sessions_coached_by_user)) {
  207. foreach ($sessions_coached_by_user as $session_coached_by_user) {
  208. $sid = intval($session_coached_by_user['id']);
  209. $courses_followed_by_coach = Tracking :: get_courses_followed_by_coach(api_get_user_id(), $sid);
  210. $courses_in_session_by_coach[$sid] = $courses_followed_by_coach;
  211. }
  212. }
  213. $sql = "SELECT course_code FROM $tbl_course_user WHERE relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND user_id = ".intval($user_info['user_id']);
  214. $rs = Database::query($sql);
  215. while ($row = Database :: fetch_array($rs)) {
  216. if ($drh_can_access_all_courses) {
  217. $courses_in_session[0][] = $row['course_code'];
  218. } else {
  219. if (isset($courses[$row['course_code']])) {
  220. $courses_in_session[0][] = $row['course_code'];
  221. }
  222. }
  223. }
  224. // Get the list of sessions where the user is subscribed as student
  225. $sql = 'SELECT id_session, course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($user_info['user_id']);
  226. $rs = Database::query($sql);
  227. $tmp_sessions = array();
  228. while ($row = Database :: fetch_array($rs)) {
  229. $tmp_sessions[] = $row['id_session'];
  230. if ($drh_can_access_all_courses) {
  231. if (in_array($row['id_session'], $tmp_sessions)) {
  232. $courses_in_session[$row['id_session']][] = $row['course_code'];
  233. }
  234. } else {
  235. if (isset($courses_in_session_by_coach[$row['id_session']])) {
  236. if (in_array($row['id_session'], $tmp_sessions)) {
  237. $courses_in_session[$row['id_session']][] = $row['course_code'];
  238. }
  239. }
  240. }
  241. }
  242. /*if (empty($courses_in_session)) {
  243. Display :: display_header($nameTools);
  244. echo '<div class="actions">';
  245. echo '<a href="javascript: window.back();" ">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  246. echo '</div>';
  247. Display::display_warning_message(get_lang('NoDataAvailable'));
  248. Display::display_footer();
  249. exit;
  250. }*/
  251. if (!empty($student_id)) {
  252. if (api_is_drh() && !UserManager::is_user_followed_by_drh($student_id, api_get_user_id())) {
  253. api_not_allowed();
  254. }
  255. }
  256. Display :: display_header($nameTools);
  257. if (isset($message)) {
  258. echo $message;
  259. }
  260. if (!empty($student_id)) {
  261. // Actions bar
  262. echo '<div class="actions">';
  263. echo '<a href="javascript: window.back();" ">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  264. echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
  265. echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
  266. if (!empty ($user_info['email'])) {
  267. $send_mail = '<a href="mailto:'.$user_info['email'].'">'.Display :: return_icon('mail_send.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM).'</a>';
  268. } else {
  269. $send_mail = Display :: return_icon('mail_send_na.png', get_lang('SendMail'),'',ICON_SIZE_MEDIUM);
  270. }
  271. echo $send_mail;
  272. if (!empty($student_id) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL
  273. echo '<a href="access_details.php?student=' . $student_id . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq='.Security::remove_XSS($_GET['course']).'&amp;id_session='.$session_id.'">' . Display :: return_icon('statistics.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>';
  274. }
  275. echo '</div>';
  276. // is the user online ?
  277. if (user_is_online($_GET['student'])) {
  278. $online = get_lang('Yes');
  279. } else {
  280. $online = get_lang('No');
  281. }
  282. // get average of score and average of progress by student
  283. $avg_student_progress = $avg_student_score = 0;
  284. $course_code = Security :: remove_XSS($_GET['course']);
  285. if (!CourseManager :: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
  286. unset($courses[$key]);
  287. } else {
  288. $avg_student_progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, array(), $session_id);
  289. //the score inside the Reporting table
  290. $avg_student_score = Tracking::get_avg_student_score($user_info['user_id'], $course_code, array(), $session_id);
  291. //var_dump($avg_student_score);
  292. }
  293. $avg_student_progress = round($avg_student_progress, 2);
  294. // time spent on the course
  295. $time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
  296. // get information about connections on the platform by student
  297. $first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']);
  298. if ($first_connection_date == '') {
  299. $first_connection_date = get_lang('NoConnexion');
  300. }
  301. $last_connection_date = Tracking :: get_last_connection_date($user_info['user_id'], true);
  302. if ($last_connection_date == '') {
  303. $last_connection_date = get_lang('NoConnexion');
  304. }
  305. // cvs informations
  306. $csv_content[] = array (
  307. get_lang('Informations', '')
  308. );
  309. $csv_content[] = array (
  310. get_lang('Name', ''),
  311. get_lang('Email', ''),
  312. get_lang('Tel', '')
  313. );
  314. $csv_content[] = array (
  315. $user_info['complete_name'],
  316. $user_info['email'],
  317. $user_info['phone']
  318. );
  319. $csv_content[] = array ();
  320. // csv tracking
  321. $csv_content[] = array (
  322. get_lang('Tracking', '')
  323. );
  324. $csv_content[] = array (
  325. get_lang('FirstLogin', ''),
  326. get_lang('LatestLogin', ''),
  327. get_lang('TimeSpentInTheCourse', ''),
  328. get_lang('Progress', ''),
  329. get_lang('Score', '')
  330. );
  331. $csv_content[] = array (
  332. strip_tags($first_connection_date),
  333. strip_tags($last_connection_date),
  334. $time_spent_on_the_course,
  335. $avg_student_progress . '%',
  336. $avg_student_score
  337. );
  338. //Show title
  339. $info_course = CourseManager :: get_course_information($course_code);
  340. $coachs_name = '';
  341. $session_name = '';
  342. $nb_login = Tracking :: count_login_per_student($user_info['user_id'], $_GET['course']);
  343. //get coach and session_name if there is one and if session_mode is activated
  344. if ($session_id > 0) {
  345. $session_info = api_get_session_info($session_id);
  346. $course_coachs = api_get_coachs_from_course($session_id, $course_code);
  347. $nb_login = '';
  348. if (!empty($course_coachs)) {
  349. $info_tutor_name = array();
  350. foreach ($course_coachs as $course_coach) {
  351. $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
  352. }
  353. $info_course['tutor_name'] = implode(",",$info_tutor_name);
  354. } elseif ($session_coach_id != 0) {
  355. $session_coach_id = intval($session_info['id_coach']);
  356. $coach_info = UserManager::get_user_info_by_id($session_coach_id);
  357. $info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
  358. }
  359. $coachs_name = $info_course['tutor_name'];
  360. $session_name = $session_info['name'];
  361. } // end
  362. $info_course = CourseManager :: get_course_information($get_course_code);
  363. $table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).$user_info['complete_name'];
  364. echo Display::page_subheader($table_title);
  365. echo '<table width="100%" border="0">';
  366. echo '<tr>';
  367. $image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true);
  368. echo '<td class="borderRight" width="10%" valign="top">';
  369. // get the path,width and height from original picture
  370. $image_file = $image_array['dir'] . $image_array['file'];
  371. $big_image = $image_array['dir'] . 'big_' . $image_array['file'];
  372. $big_image_size = api_getimagesize($big_image);
  373. $big_image_width = $big_image_size['width'];
  374. $big_image_height = $big_image_size['height'];
  375. $url_big_image = $big_image . '?rnd=' . time();
  376. $img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' .
  377. 'alt="' . $user_info['complete_name']. '" ' .
  378. 'style="float:' . ($text_dir == 'rtl' ? 'right' : 'left') . '; padding:5px;" ';
  379. if ($image_array['file'] == 'unknown.jpg') {
  380. echo '<img ' . $img_attributes . ' />';
  381. } else {
  382. echo '<input type="image" ' . $img_attributes . ' onclick="javascript: return show_image(\'' . $url_big_image . '\',\'' . $big_image_width . '\',\'' . $big_image_height . '\');"/>';
  383. }
  384. echo '</td>';
  385. ?>
  386. <td width="40%" valign="top">
  387. <table width="100%" class="data_table">
  388. <tr>
  389. <th><?php echo get_lang('Information'); ?></th>
  390. </tr>
  391. <tr>
  392. <td><?php echo get_lang('Name') . ' : '.$user_info['complete_name']; ?></td>
  393. </tr>
  394. <tr>
  395. <td><?php echo get_lang('Email') . ' : ';
  396. if (!empty ($user_info['email'])) {
  397. echo '<a href="mailto:' . $user_info['email'] . '">' . $user_info['email'] . '</a>';
  398. } else {
  399. echo get_lang('NoEmail');
  400. } ?>
  401. </td>
  402. </tr>
  403. <tr>
  404. <td> <?php echo get_lang('Tel') . ' : ';
  405. if (!empty ($user_info['phone'])) {
  406. echo $user_info['phone'];
  407. } else {
  408. echo get_lang('NoTel');
  409. }
  410. ?>
  411. </td>
  412. </tr>
  413. <tr>
  414. <td> <?php echo get_lang('OfficialCode') . ' : ';
  415. if (!empty ($user_info['official_code'])) {
  416. echo $user_info['official_code'];
  417. } else {
  418. echo get_lang('NoOfficialCode');
  419. }
  420. ?>
  421. </td>
  422. </tr>
  423. <tr>
  424. <td><?php echo get_lang('OnLine') . ' : '.$online; ?> </td>
  425. </tr>
  426. <?php
  427. // Display timezone if the user selected one and if the admin allows the use of user's timezone
  428. $timezone = null;
  429. $timezone_user = UserManager::get_extra_user_data_by_field($user_info['user_id'],'timezone');
  430. $use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
  431. if ($timezone_user['timezone'] != null && $use_users_timezone == 'true') {
  432. $timezone = $timezone_user['timezone'];
  433. }
  434. if ($timezone !== null) {
  435. ?>
  436. <tr>
  437. <td> <?php echo get_lang('Timezone') . ' : '.$timezone; ?> </td>
  438. </tr>
  439. <?php
  440. }
  441. ?>
  442. </table>
  443. </td>
  444. <td class="borderLeft" width="35%" valign="top">
  445. <table width="100%" class="data_table">
  446. <tr>
  447. <th colspan="2"><?php echo get_lang('Tracking'); ?></th>
  448. </tr>
  449. <tr><td align="right"><?php echo get_lang('FirstLogin') ?></td>
  450. <td align="left"><?php echo $first_connection_date ?></td>
  451. </tr>
  452. <tr>
  453. <td align="right"><?php echo get_lang('LatestLogin') ?></td>
  454. <td align="left"><?php echo $last_connection_date ?></td>
  455. </tr>
  456. <?php if (isset($_GET['details']) && $_GET['details'] == 'true') {?>
  457. <tr>
  458. <td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
  459. <td align="left"><?php echo $time_spent_on_the_course ?></td>
  460. </tr>
  461. <tr>
  462. <td align="right"><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px'));?></td>
  463. <td align="left"><?php echo $avg_student_progress.'%' ?></td>
  464. </tr>
  465. <tr>
  466. <td align="right"><?php echo get_lang('Score').' '; Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?>
  467. </td>
  468. <td align="left"><?php if (is_numeric($avg_student_score)) { echo $avg_student_score.'%';} else { echo $avg_student_score ;} ?></td>
  469. </tr>
  470. <?php
  471. if (!empty($nb_login)) {
  472. echo '<tr><td align="right">'.get_lang('CountToolAccess').'</td>';
  473. echo '<td align="left">'.$nb_login.'</td>';
  474. echo '</tr>';
  475. }
  476. } ?>
  477. </table>
  478. </td>
  479. </tr>
  480. </table>
  481. <?php
  482. $table_title = '';
  483. if (!empty($session_id)) {
  484. $session_name = api_get_session_name($session_id);
  485. $table_title = ($session_name? Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.' ':'');
  486. }
  487. if (!empty($info_course['title'])) {
  488. $table_title .= ($info_course ? Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$info_course['title'].' ':'');
  489. }
  490. echo Display::page_subheader($table_title);
  491. if (empty($_GET['details'])) {
  492. $csv_content[] = array ();
  493. $csv_content[] = array (
  494. get_lang('Session', ''),
  495. get_lang('Course', ''),
  496. get_lang('Time', ''),
  497. get_lang('Progress', ''),
  498. get_lang('Score', ''),
  499. get_lang('AttendancesFaults', ''),
  500. get_lang('Evaluations')
  501. );
  502. $attendance = new Attendance();
  503. foreach ($courses_in_session as $key => $courses) {
  504. $session_id = $key;
  505. $session_info = api_get_session_info($session_id);
  506. $session_name = $session_info['name'];
  507. $date_start = '';
  508. if (!empty($session_info['date_start']) && $session_info['date_start'] != '0000-00-00') {
  509. $date_start = api_format_date($session_info['date_start'], DATE_FORMAT_SHORT);
  510. }
  511. $date_end = '';
  512. if (!empty($session_info['date_end']) && $session_info['date_end'] != '0000-00-00') {
  513. $date_end = api_format_date($session_info['date_end'], DATE_FORMAT_SHORT);
  514. }
  515. if (!empty($date_start) && !empty($date_end)) {
  516. $date_session = get_lang('From') . ' ' . $date_start . ' ' . get_lang('Until') . ' ' . $date_end;
  517. }
  518. $title = '';
  519. if (empty($session_id)) {
  520. $title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
  521. } else {
  522. $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':'');
  523. }
  524. // Courses
  525. echo '<h3>'.$title.'</h3>';
  526. echo '<table class="data_table">';
  527. echo '<tr>
  528. <th>'.get_lang('Course').'</th>
  529. <th>'.get_lang('Time').'</th>
  530. <th>'.get_lang('Progress').'</th>
  531. <th>'.get_lang('Score').'</th>
  532. <th>'.get_lang('AttendancesFaults').'</th>
  533. <th>'.get_lang('Evaluations').'</th>
  534. <th>'.get_lang('Details').'</th>
  535. </tr>';
  536. if (!empty($courses)) {
  537. foreach ($courses as $course_code) {
  538. if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
  539. $course_info = CourseManager :: get_course_information($course_code);
  540. $time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
  541. // get average of faults in attendances by student
  542. $results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $session_id);
  543. if (!empty($results_faults_avg['total'])) {
  544. if (api_is_drh()) {
  545. $attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  546. } else {
  547. $attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
  548. }
  549. } else {
  550. $attendances_faults_avg = '0/0 (0%)';
  551. }
  552. // get evaluatios by student
  553. $cats = Category::load(null, null, $course_code, null, null, $session_id);
  554. $scoretotal = array();
  555. if (isset($cats) && isset($cats[0])) {
  556. if (!empty($session_id)) {
  557. $scoretotal= $cats[0]->calc_score($student_id, $course_code, $session_id);
  558. } else {
  559. $scoretotal= $cats[0]->calc_score($student_id, $course_code);
  560. }
  561. }
  562. $scoretotal_display = '0/0 (0%)';
  563. if (!empty($scoretotal)) {
  564. $scoretotal_display = round($scoretotal[0],1).'/'.round($scoretotal[1],1).' ('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
  565. }
  566. $progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, null, $session_id);
  567. $score = Tracking :: get_avg_student_score($user_info['user_id'], $course_code, null, $session_id);
  568. $progress = empty($progress) ? '0%' : $progress.'%';
  569. $score = empty($score) ? '0%' : $score.'%';
  570. $csv_content[] = array (
  571. $session_name,
  572. $course_info['title'],
  573. $time_spent_on_course,
  574. $progress,
  575. $score,
  576. $attendances_faults_avg,
  577. $scoretotal_display
  578. );
  579. echo '<tr>
  580. <td >'.$course_info['title'].'</td>
  581. <td >'.$time_spent_on_course .'</td>
  582. <td >'.$progress.'</td>
  583. <td >'.$score.'</td>
  584. <td >'.$attendances_faults_avg.'</td>
  585. <td >'.$scoretotal_display.'</td>';
  586. if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
  587. echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
  588. } else {
  589. echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
  590. }
  591. echo '</tr>';
  592. }
  593. }
  594. } else {
  595. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  596. }
  597. echo '</table>';
  598. }
  599. } else {
  600. $csv_content[] = array ();
  601. $csv_content[] = array (str_replace('&nbsp;', '', $table_title));
  602. $t_lp = Database :: get_course_table(TABLE_LP_MAIN);
  603. // csv export headers
  604. $csv_content[] = array ();
  605. $csv_content[] = array (
  606. get_lang('Learnpath', ''),
  607. get_lang('Time', ''),
  608. get_lang('AverageScore', ''),
  609. get_lang('LatestScore', ''),
  610. get_lang('Progress', ''),
  611. get_lang('LastConnexion', '')
  612. );
  613. if (empty($session_id)) {
  614. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE session_id = 0 AND c_id = {$info_course['real_id']} ORDER BY lp.display_order";
  615. } else {
  616. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE c_id = {$info_course['real_id']} ORDER BY lp.display_order";
  617. }
  618. $rs_lp = Database::query($sql_lp);
  619. $token = Security::get_token();
  620. if (Database :: num_rows($rs_lp) > 0) {
  621. ?>
  622. <!-- LPs-->
  623. <table class="data_table">
  624. <tr>
  625. <th><?php echo get_lang('Learnpaths');?></th>
  626. <th><?php echo get_lang('Time').' '; Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  627. <th><?php echo get_lang('AverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInAllAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  628. <th><?php echo get_lang('LatestAttemptAverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
  629. <th><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
  630. <th><?php echo get_lang('LastConnexion').' '; Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
  631. <?php
  632. echo '<th>'.get_lang('Details').'</th>';
  633. if (api_is_allowed_to_edit()) {
  634. echo '<th>'.get_lang('ResetLP').'</th>';
  635. }
  636. ?>
  637. </tr>
  638. <?php
  639. $i = 0;
  640. while ($learnpath = Database :: fetch_array($rs_lp)) {
  641. $lp_id = intval($learnpath['id']);
  642. $lp_name = $learnpath['name'];
  643. $any_result = false;
  644. // Get progress in lp
  645. $progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
  646. if ($progress === null) {
  647. $progress = '0%';
  648. } else {
  649. $any_result = true;
  650. }
  651. // Get time in lp
  652. $total_time = Tracking::get_time_spent_in_lp($student_id, $course_code, array($lp_id),$session_id);
  653. if (!empty($total_time)) $any_result = true;
  654. // Get last connection time in lp
  655. $start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id);
  656. if (!empty($start_time)) {
  657. $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
  658. } else {
  659. $start_time = '-';
  660. }
  661. if (!empty($total_time)) $any_result = true;
  662. // Quizz in lp
  663. $score = Tracking::get_avg_student_score($student_id, $course_code, array($lp_id),$session_id);
  664. // Latest exercise results in a LP
  665. $score_latest = Tracking :: get_avg_student_score($student_id, $course_code, array($lp_id),$session_id, false, true);
  666. if ($i % 2 == 0) $css_class = "row_even";
  667. else $css_class = "row_odd";
  668. $i++;
  669. // csv export content
  670. $csv_content[] = array (
  671. api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
  672. api_time_to_hms($total_time),
  673. $score . '%',
  674. $score_latest . '%',
  675. $progress.'%',
  676. $start_time
  677. );
  678. echo '<tr class="'.$css_class.'">';
  679. echo Display::tag('td', stripslashes($lp_name));
  680. echo Display::tag('td', api_time_to_hms($total_time));
  681. if (!is_null($score)) {
  682. if (is_numeric($score)) {
  683. $score = $score.'%';
  684. }
  685. }
  686. echo Display::tag('td', $score);
  687. if (!is_null($score_latest)) {
  688. if (is_numeric($score_latest)) {
  689. $score_latest = $score_latest.'%';
  690. }
  691. }
  692. echo Display::tag('td', $score_latest);
  693. if (is_numeric($progress)) {
  694. $progress = $progress.'%';
  695. } else {
  696. $progress = '-';
  697. }
  698. echo Display::tag('td', $progress);
  699. //Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
  700. //which implies several other changes not a priority right now
  701. echo Display::tag('td', $start_time);
  702. if ($any_result === true) {
  703. $from = '';
  704. if ($from_myspace) {
  705. $from ='&from=myspace';
  706. }
  707. $link = Display::url('<img src="../img/2rightarrow.gif" border="0" />','lp_tracking.php?course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id);
  708. echo Display::tag('td', $link);
  709. }
  710. if (api_is_allowed_to_edit()) {
  711. echo '<td>';
  712. if ($any_result === true) {
  713. echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
  714. echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
  715. echo '</a>';
  716. }
  717. echo '</td>';
  718. echo '</tr>';
  719. }
  720. $data_learnpath[$i][] = $lp_name;
  721. $data_learnpath[$i][] = $progress . '%';
  722. }
  723. } else {
  724. //echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
  725. }
  726. ?>
  727. </table>
  728. <!-- line about exercises -->
  729. <table class="data_table">
  730. <tr>
  731. <th><?php echo get_lang('Exercices'); ?></th>
  732. <th><?php echo get_lang('AverageScore').' '.Display :: return_icon('info3.gif', get_lang('AverageScore'), array('align' => 'absmiddle', 'hspace' => '3px')) ?></th>
  733. <th><?php echo get_lang('Attempts'); ?></th>
  734. <th><?php echo get_lang('LatestAttempt'); ?></th>
  735. <th><?php echo get_lang('AllAttempts'); ?></th>
  736. </tr>
  737. <?php
  738. $csv_content[] = array ();
  739. $csv_content[] = array (
  740. get_lang('Exercices'),
  741. get_lang('Score'),
  742. get_lang('Attempts')
  743. );
  744. $t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
  745. $sql_exercices = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
  746. WHERE quiz.c_id = ".$info_course['real_id']." AND
  747. active='1' AND
  748. (quiz.session_id = $session_id OR quiz.session_id = 0)
  749. ORDER BY quiz.title ASC ";
  750. $result_exercices = Database::query($sql_exercices);
  751. $i = 0;
  752. if (Database :: num_rows($result_exercices) > 0) {
  753. while ($exercices = Database :: fetch_array($result_exercices)) {
  754. $exercise_id = intval($exercices['id']);
  755. $count_attempts = Tracking::count_student_exercise_attempts($student_id, $course_code, $exercise_id, 0, 0, $session_id);
  756. $score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id, $session_id);
  757. $csv_content[] = array (
  758. $exercices['title'],
  759. $score_percentage . '%',
  760. $count_attempts
  761. );
  762. if ($i % 2) $css_class = 'row_odd';
  763. else $css_class = 'row_even';
  764. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  765. echo '<td>';
  766. if ($count_attempts > 0) {
  767. echo $score_percentage . '%';
  768. } else {
  769. echo '-';
  770. $score_percentage = 0;
  771. }
  772. echo '</td>';
  773. echo '<td>'.$count_attempts.'</td>';
  774. echo '<td>';
  775. $sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
  776. WHERE exe_exo_id ="'.$exercise_id.'" AND
  777. exe_user_id ="'.$student_id.'" AND
  778. exe_cours_id ="'.$course_code.'" AND
  779. session_id ="'.$session_id.'" AND
  780. status = "" AND
  781. orig_lp_id = 0 AND
  782. orig_lp_item_id = 0
  783. ORDER BY exe_date DESC LIMIT 1';
  784. $result_last_attempt = Database::query($sql_last_attempt);
  785. if (Database :: num_rows($result_last_attempt) > 0) {
  786. $id_last_attempt = Database :: result($result_last_attempt, 0, 0);
  787. if ($count_attempts > 0)
  788. echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$session_id.'&student='.$student_id.'&origin='.(empty($_GET['origin'])?'tracking':Security::remove_XSS($_GET['origin'])).'"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
  789. }
  790. echo '</td>';
  791. echo '<td>';
  792. $all_attempt_url = "../exercice/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$session_id";
  793. echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url );
  794. echo '</td></tr>';
  795. $data_exercices[$i][] = $exercices['title'];
  796. $data_exercices[$i][] = $score_percentage . '%';
  797. $data_exercices[$i][] = $count_attempts;
  798. $i++;
  799. }
  800. } else {
  801. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  802. }
  803. echo '</table>';
  804. //@when using sessions we do not show the survey list
  805. if (empty($session_id)) {
  806. $survey_list = survey_manager::get_surveys($course_code, $session_id);
  807. $survey_data = array();
  808. foreach($survey_list as $survey) {
  809. $user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $info_course['real_id']);
  810. $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
  811. if (in_array($student_id, $user_list)) {
  812. $survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
  813. }
  814. $data = array('title' => $survey['title'], 'done' => $survey_done);
  815. $survey_data[] = $data;
  816. }
  817. if (!empty($survey_list)) {
  818. $table = new HTML_Table(array('class' => 'data_table'));
  819. $header_names = array(get_lang('Survey'), get_lang('Answered'));
  820. $row = 0;
  821. $column = 0;
  822. foreach ($header_names as $item) {
  823. $table->setHeaderContents($row, $column, $item);
  824. $column++;
  825. }
  826. $row = 1;
  827. if (!empty($survey_data)) {
  828. foreach ($survey_data as $data) {
  829. $column = 0;
  830. $table->setCellContents($row, $column, $data);
  831. //$table->setRowAttributes($row, 'style="text-align:center"');
  832. $class = 'class="row_odd"';
  833. if($row % 2) {
  834. $class = 'class="row_even"';
  835. }
  836. $table->setRowAttributes($row, $class, true);
  837. $column++;
  838. $row++;
  839. }
  840. }
  841. echo $table->toHtml();
  842. }
  843. }
  844. // line about other tools
  845. echo '<table class="data_table">';
  846. $csv_content[] = array ();
  847. $nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $session_id);
  848. $messages = Tracking::count_student_messages($student_id, $course_code, $session_id);
  849. $links = Tracking::count_student_visited_links($student_id, $course_code, $session_id);
  850. $chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
  851. $documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
  852. $uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id);
  853. $csv_content[] = array (
  854. get_lang('Student_publication'),
  855. $nb_assignments
  856. );
  857. $csv_content[] = array (
  858. get_lang('Messages'),
  859. $messages
  860. );
  861. $csv_content[] = array (
  862. get_lang('LinksDetails'),
  863. $links
  864. );
  865. $csv_content[] = array (
  866. get_lang('DocumentsDetails'),
  867. $documents
  868. );
  869. $csv_content[] = array (
  870. get_lang('UploadedDocuments'),
  871. $uploaded_documents
  872. );
  873. $csv_content[] = array (
  874. get_lang('ChatLastConnection'),
  875. $chat_last_connection
  876. );
  877. ?>
  878. <tr>
  879. <th colspan="2"><?php echo get_lang('OtherTools'); ?></th>
  880. </tr>
  881. <tr><!-- assignments -->
  882. <td width="40%"><?php echo get_lang('Student_publication') ?></td>
  883. <td><?php echo $nb_assignments ?></td>
  884. </tr>
  885. <tr><!-- messages -->
  886. <td><?php echo get_lang('Messages') ?></td>
  887. <td><?php echo $messages ?></td>
  888. </tr>
  889. <tr><!-- links -->
  890. <td><?php echo get_lang('LinksDetails') ?></td>
  891. <td><?php echo $links ?></td>
  892. </tr>
  893. <tr><!-- downloaded documents -->
  894. <td><?php echo get_lang('DocumentsDetails') ?></td>
  895. <td><?php echo $documents ?></td>
  896. </tr>
  897. <tr><!-- uploaded documents -->
  898. <td><?php echo get_lang('UploadedDocuments') ?></td>
  899. <td><?php echo $uploaded_documents ?></td>
  900. </tr>
  901. <tr><!-- Chats -->
  902. <td><?php echo get_lang('ChatLastConnection') ?></td>
  903. <td><?php echo $chat_last_connection; ?></td>
  904. </tr>
  905. </table>
  906. </td>
  907. </tr>
  908. </table>
  909. <?php
  910. } //end details
  911. }
  912. if ($export_csv) {
  913. ob_end_clean();
  914. Export :: export_table_csv($csv_content, 'reporting_student');
  915. exit;
  916. }
  917. /* FOOTER */
  918. Display :: display_footer();