lp_tracking.php 4.8 KB

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