lp_tracking.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Learning paths reporting.
  5. *
  6. * @package chamilo.reporting
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. // resetting the course id
  10. $cidReset = true;
  11. $from_myspace = false;
  12. $from_link = '';
  13. if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
  14. $from_link = '&from=myspace';
  15. $this_section = SECTION_TRACKING;
  16. } else {
  17. $this_section = SECTION_COURSES;
  18. }
  19. $session_id = isset($_REQUEST['id_session']) && !empty($_REQUEST['id_session'])
  20. ? intval($_REQUEST['id_session'])
  21. : api_get_session_id();
  22. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  23. $user_id = isset($_GET['student_id']) ? intval($_GET['student_id']) : api_get_user_id();
  24. $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : api_get_course_id();
  25. $origin = api_get_origin();
  26. $lp_id = intval($_GET['lp_id']);
  27. $csv_content = [];
  28. $course_info = api_get_course_info($courseCode);
  29. if (empty($course_info) || empty($lp_id)) {
  30. api_not_allowed(api_get_origin() !== 'learnpath');
  31. }
  32. $userInfo = api_get_user_info($user_id);
  33. $name = $userInfo['complete_name'];
  34. $isBoss = UserManager::userIsBossOfStudent(api_get_user_id(), $user_id);
  35. if (!api_is_platform_admin(true) &&
  36. !CourseManager::is_course_teacher(api_get_user_id(), $courseCode) &&
  37. !$isBoss &&
  38. !Tracking::is_allowed_to_coach_student(api_get_user_id(), $user_id) &&
  39. !api_is_drh() &&
  40. !api_is_course_tutor()
  41. ) {
  42. api_not_allowed(
  43. api_get_origin() !== 'learnpath'
  44. );
  45. }
  46. if ($origin == 'user_course') {
  47. $interbreadcrumb[] = [
  48. 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'],
  49. 'name' => $course_info['name'],
  50. ];
  51. $interbreadcrumb[] = [
  52. 'url' => "../user/user.php?cidReq=$courseCode",
  53. 'name' => get_lang("Users"),
  54. ];
  55. } elseif ($origin == 'tracking_course') {
  56. $interbreadcrumb[] = [
  57. 'url' => "../tracking/courseLog.php?cidReq=$courseCode&id_session=$session_id",
  58. 'name' => get_lang("Tracking"),
  59. ];
  60. } else {
  61. $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
  62. $interbreadcrumb[] = ['url' => 'student.php', 'name' => get_lang("MyStudents")];
  63. $interbreadcrumb[] = ['url' => "myStudents.php?student=$user_id", 'name' => get_lang("StudentDetails")];
  64. $nameTools = get_lang("DetailsStudentInCourse");
  65. }
  66. $interbreadcrumb[] = [
  67. 'url' => "myStudents.php?student=$user_id&course=$courseCode&details=true&origin=$origin",
  68. 'name' => get_lang("DetailsStudentInCourse"),
  69. ];
  70. $nameTools = get_lang('LearningPathDetails');
  71. $sql = 'SELECT name FROM '.Database::get_course_table(TABLE_LP_MAIN).'
  72. WHERE c_id = '.$course_info['real_id'].' AND id='.$lp_id;
  73. $rs = Database::query($sql);
  74. $lp_title = Database::result($rs, 0, 0);
  75. $origin = 'tracking';
  76. $output = require_once api_get_path(SYS_CODE_PATH).'lp/lp_stats.php';
  77. $actions = [];
  78. $actions[] = Display::url(
  79. Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM),
  80. 'javascript:history.back();'
  81. );
  82. $actions[] = Display::url(
  83. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM),
  84. 'javascript:window.print();'
  85. );
  86. $actions[] = Display::url(
  87. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM),
  88. api_get_self().'?export=csv&'.Security::remove_XSS($_SERVER['QUERY_STRING'])
  89. );
  90. Display::display_header($nameTools);
  91. echo Display::toolbarAction(
  92. 'actions',
  93. [implode(PHP_EOL, $actions)]
  94. );
  95. $table_title = $session_id
  96. ? Display::return_icon('session.png', get_lang('Session')).PHP_EOL.api_get_session_name($session_id).PHP_EOL
  97. : PHP_EOL;
  98. $table_title .= Display::return_icon('course.png', get_lang('Course')).PHP_EOL.$course_info['name'].PHP_EOL
  99. .Display::return_icon('user.png', get_lang('User')).' '.$name;
  100. echo Display::page_header($table_title);
  101. echo Display::page_subheader(
  102. Display::return_icon('learnpath.png', get_lang('ToolLearnpath')).PHP_EOL.$lp_title
  103. );
  104. echo $output;
  105. Display::display_footer();