lp_tracking.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file = array ('registration', 'index', 'tracking', 'exercice', 'scorm', 'learnpath');
  4. require_once '../inc/global.inc.php';
  5. // resetting the course id
  6. $cidReset = true;
  7. $from_myspace = false;
  8. $from_link = '';
  9. if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
  10. $from_link = '&from=myspace';
  11. $this_section = SECTION_TRACKING;
  12. } else {
  13. $this_section = SECTION_COURSES;
  14. }
  15. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  16. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  17. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php';
  18. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  19. $session_id = isset($_REQUEST['id_session']) && !empty($_REQUEST['id_session']) ? intval($_REQUEST['id_session']) : api_get_session_id();
  20. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  21. if ($export_csv) {
  22. ob_start();
  23. }
  24. $csv_content = array();
  25. $user_id = intval($_GET['student_id']);
  26. if (isset($_GET['course'])) {
  27. $cidReq = Security::remove_XSS($_GET['course']);
  28. }
  29. $user_infos = UserManager :: get_user_info_by_id($user_id);
  30. $name = api_get_person_name($user_infos['firstname'], $user_infos['lastname']);
  31. if (!api_is_platform_admin(true) && !CourseManager :: is_course_teacher($_user['user_id'], $cidReq) && !Tracking :: is_allowed_to_coach_student($_user['user_id'],$_GET['student_id']) && !api_is_drh() && !api_is_course_tutor()) {
  32. api_not_allowed();
  33. }
  34. $course_exits = CourseManager::course_exists($cidReq);
  35. if (!empty($course_exits)) {
  36. $course_info = api_get_course_info($cidReq);
  37. } else {
  38. api_not_allowed();
  39. }
  40. if (!empty($_GET['origin']) && $_GET['origin'] == 'user_course') {
  41. $interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['name']);
  42. $interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".$cidReq, "name" => get_lang("Users"));
  43. } else if(!empty($_GET['origin']) && $_GET['origin'] == 'tracking_course') {
  44. // $interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['name']);
  45. $interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$session_id, "name" => get_lang("Tracking"));
  46. } else {
  47. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  48. $interbreadcrumb[] = array ("url" => "student.php", "name" => get_lang("MyStudents"));
  49. $interbreadcrumb[] = array ("url" => "myStudents.php?student=".Security::remove_XSS($_GET['student_id']), "name" => get_lang("StudentDetails"));
  50. $nameTools=get_lang("DetailsStudentInCourse");
  51. }
  52. $interbreadcrumb[] = array("url" => "myStudents.php?student=".Security::remove_XSS($_GET['student_id'])."&course=".$cidReq."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
  53. $nameTools = get_lang('LearningPathDetails');
  54. Display :: display_header($nameTools);
  55. $lp_id = intval($_GET['lp_id']);
  56. $sql = 'SELECT name FROM '.Database::get_course_table(TABLE_LP_MAIN).' WHERE c_id = '.$course_info['real_id'].' AND id='.$lp_id;
  57. $rs = Database::query($sql);
  58. $lp_title = Database::result($rs, 0, 0);
  59. echo '<div class ="actions">';
  60. echo '<a href="javascript:history.back();">'.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
  61. echo '<a href="javascript: void(0);" onclick="javascript: window.print();">
  62. '.Display::return_icon('printer.png',get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
  63. echo '<a href="'.api_get_self().'?export=csv&'.Security::remove_XSS($_SERVER['QUERY_STRING']).'">
  64. '.Display::return_icon('export_csv.png',get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
  65. echo '</div>';
  66. echo '<div class="clear"></div>';
  67. $session_name = api_get_session_name($session_id);
  68. $table_title = ($session_name? Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.' ':' ').
  69. Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$course_info['name'].' '.
  70. Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).' '.$name;
  71. echo Display::page_header($table_title);
  72. echo Display::page_subheader('<h3>'.Display::return_icon('learnpath.png', get_lang('ToolLearnpath'), array(), ICON_SIZE_SMALL).' '.$lp_title.'</h3>');
  73. //Needed in newscorm/lp_stats.php
  74. $list = learnpath :: get_flat_ordered_items_list($lp_id, 0, $course_info['real_id']);
  75. $origin = 'tracking';
  76. if ($export_csv) {
  77. require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php';
  78. //Export :: export_table_csv($csv_content, 'reporting_student');
  79. } else {
  80. ob_start();
  81. require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_stats.php';
  82. $tracking_content = ob_get_contents();
  83. ob_end_clean();
  84. echo api_utf8_decode($tracking_content, $charset);
  85. }
  86. Display :: display_footer();