my_progress.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Reporting page on the user's own progress.
  5. *
  6. * @package chamilo.tracking
  7. */
  8. $cidReset = true;
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. api_block_anonymous_users();
  11. if (api_get_configuration_value('block_my_progress_page')) {
  12. api_not_allowed(true);
  13. }
  14. $this_section = SECTION_TRACKING;
  15. $nameTools = get_lang('MyProgress');
  16. $htmlHeadXtra[] = api_get_js('jquery.timelinr-0.9.54.js');
  17. $htmlHeadXtra[] = "<script>
  18. $(function() {
  19. $().timelinr({
  20. containerDiv: '#my_timeline',
  21. autoPlayPause: 2000
  22. })
  23. });
  24. </script>";
  25. $pluginCalendar = api_get_plugin_setting('learning_calendar', 'enabled') === 'true';
  26. if ($pluginCalendar) {
  27. $plugin = LearningCalendarPlugin::create();
  28. $plugin->setJavaScript($htmlHeadXtra);
  29. }
  30. $user_id = api_get_user_id();
  31. $courseUserList = CourseManager::get_courses_list_by_user_id($user_id);
  32. $dates = $issues = '';
  33. $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
  34. $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null;
  35. if (!empty($courseUserList)) {
  36. $items = MySpace::get_connections_from_course_list(
  37. $user_id,
  38. $courseUserList
  39. );
  40. $first = null;
  41. $last = null;
  42. $last_item = count($items);
  43. $count = 1;
  44. foreach ($items as $result) {
  45. $login = $result['login'];
  46. $courseId = $result['c_id'];
  47. $courseInfo = api_get_course_info_by_id($courseId);
  48. if ($count == 1) {
  49. $first = '<a href="#'.$login.'">'.get_lang('First').'</a>';
  50. }
  51. if ($count == $last_item) {
  52. $last = '<a href="#'.$login.'">'.get_lang('Last').'</a>';
  53. }
  54. $course_info = api_get_course_info_by_id($result['c_id']);
  55. $course_image = '<img src="'.$course_info['course_image_large'].'">';
  56. $dates .= '<li><a href="#'.$login.'">'.api_convert_and_format_date($login, DATE_FORMAT_SHORT).'</a></li>';
  57. $issues .= '<li id ="'.$login.'">';
  58. $issues .= '<div class="img-course">'.$course_image.'</div>';
  59. $issues .= '<div class="text-course">';
  60. $issues .= '<p>'.sprintf(
  61. get_lang('YouHaveEnteredTheCourseXInY'),
  62. '" '.$courseInfo['name'].' "',
  63. api_convert_and_format_date($login, DATE_TIME_FORMAT_LONG)
  64. ).'</p>';
  65. $issues .= '</div>';
  66. $issues .= '</li>';
  67. $count++;
  68. }
  69. }
  70. $content = Tracking::show_user_progress($user_id, $sessionId);
  71. $content .= Tracking::show_course_detail($user_id, $courseCode, $sessionId);
  72. if (!empty($dates)) {
  73. if (!empty($content)) {
  74. $content .= '';
  75. }
  76. $content .= Display::page_subheader(get_lang('Timeline'));
  77. $content .= '<div class="row">';
  78. $content .= '<div class="col-md-12">';
  79. $content .= '<div id="my_timeline">';
  80. $content .= '<ul id="dates">'.$dates.'</ul>';
  81. $content .= '<ul id="issues">'.$issues.'</ul>';
  82. $content .= '<div id="grad_left"></div>';
  83. $content .= '<div id="grad_right"></div>';
  84. $content .= '<a href="#" id="prev"></a>';
  85. $content .= '<a href="#" id="next"></a>';
  86. $content .= '</div></div>';
  87. }
  88. if (api_get_configuration_value('private_messages_about_user_visible_to_user') === true) {
  89. $allowMessages = api_get_configuration_value('private_messages_about_user');
  90. if ($allowMessages === true) {
  91. // Messages
  92. $content .= Display::page_subheader2(get_lang('Messages'));
  93. $content .= MessageManager::getMessagesAboutUserToString(api_get_user_info());
  94. }
  95. }
  96. $message = null;
  97. if (empty($content)) {
  98. $message = Display::return_message(get_lang('NoDataAvailable'), 'warning');
  99. }
  100. $show = api_get_configuration_value('allow_career_users');
  101. if ($show) {
  102. $careers = UserManager::getUserCareers($user_id);
  103. if (!empty($careers)) {
  104. $title = Display::page_subheader(get_lang('Careers'), null, 'h3', ['class' => 'section-title']);
  105. $table = new HTML_Table(['class' => 'data_table']);
  106. $table->setHeaderContents(0, 0, get_lang('Career'));
  107. $table->setHeaderContents(0, 1, get_lang('Diagram'));
  108. $row = 1;
  109. foreach ($careers as $careerData) {
  110. $table->setCellContents($row, 0, $careerData['name']);
  111. $url = api_get_path(WEB_CODE_PATH).'user/career_diagram.php?career_id='.$careerData['id'];
  112. $diagram = Display::url(get_lang('Diagram'), $url);
  113. $table->setCellContents($row, 1, $diagram);
  114. $row++;
  115. }
  116. $content = $title.$table->toHtml().$content;
  117. }
  118. }
  119. $tpl = new Template($nameTools);
  120. $tpl->assign('message', $message);
  121. $tpl->assign('content', $content);
  122. $tpl->display_one_col_template();