lp_tracking.php 4.7 KB

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