lp_tracking.php 4.2 KB

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