access_details.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the tracking library for Chamilo.
  5. *
  6. * @package chamilo.reporting
  7. *
  8. * Calculates the time spent on the course
  9. * @param integer $user_id the user id
  10. * @param string $course_code the course code
  11. * @author Julio Montoya <gugli100@gmail.com>
  12. * @author Jorge Frisancho Jibaja - select between dates
  13. *
  14. */
  15. require_once __DIR__.'/../inc/global.inc.php';
  16. api_block_anonymous_users();
  17. // the section (for the tabs)
  18. $this_section = SECTION_TRACKING;
  19. /* MAIN */
  20. $user_id = intval($_REQUEST['student']);
  21. $session_id = intval($_GET['id_session']);
  22. $type = isset($_REQUEST['type']) ? Security::remove_XSS($_REQUEST['type']) : '';
  23. $course_code = isset($_REQUEST['course']) ? Security::remove_XSS($_REQUEST['course']) : '';
  24. $courseInfo = api_get_course_info($course_code);
  25. $courseId = (!empty($courseInfo['real_id']) ? $courseInfo['real_id'] : null);
  26. $quote_simple = "'";
  27. $form = new FormValidator(
  28. 'myform',
  29. 'get',
  30. api_get_self(),
  31. null,
  32. array('id' => 'myform')
  33. );
  34. $form->addElement('text', 'from', get_lang('From'), array('id' => 'date_from'));
  35. $form->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to'));
  36. $form->addElement(
  37. 'select',
  38. 'type',
  39. get_lang('Type'),
  40. array('day' => get_lang('Day'), 'month' => get_lang('Month')),
  41. array('id' => 'type')
  42. );
  43. $form->addElement('hidden', 'student', $user_id);
  44. $form->addElement('hidden', 'course', $course_code);
  45. $form->addRule('from', get_lang('ThisFieldIsRequired'), 'required');
  46. $form->addRule('to', get_lang('ThisFieldIsRequired'), 'required');
  47. $group = array(
  48. $form->createElement(
  49. 'label',
  50. null,
  51. Display::url(
  52. get_lang('Search'),
  53. 'javascript://',
  54. array('onclick' => 'loadGraph();', 'class' => 'btn btn-default')
  55. )
  56. )
  57. );
  58. $form->addGroup($group);
  59. $from = null;
  60. $to = null;
  61. $course = $course_code;
  62. if ($form->validate()) {
  63. $values = $form->getSubmitValues();
  64. $from = $values['from'];
  65. $to = $values['to'];
  66. $type = $values['type'];
  67. $course = $values['course'];
  68. }
  69. $url = api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail_by_date&course='.$course.'&student='.$user_id.'&session_id='.$session_id;
  70. $htmlHeadXtra[] = '<script src="slider.js" type="text/javascript"></script>';
  71. $htmlHeadXtra[] = '<link rel="stylesheet" href="slider.css" />';
  72. $htmlHeadXtra[] = "<script>
  73. function loadGraph() {
  74. var startDate = $('#date_from').val();
  75. var endDate = $('#date_to').val();
  76. var type = $('#type option:selected').val();
  77. $.ajax({
  78. url: '".$url."&startDate='+startDate+'&endDate='+endDate+'&type='+type,
  79. dataType: 'json',
  80. success: function(db) {
  81. if (!db.is_empty) {
  82. // Display confirmation message to the user
  83. $('#messages').html(db.result).stop().css('opacity', 1).fadeIn(30);
  84. $('#cev_cont_stats').html(db.stats);
  85. $('#graph' ).html(db.graph_result);
  86. } else {
  87. $('#messages').text('".get_lang('NoDataAvailable')."');
  88. $('#messages').addClass('warning-message');
  89. $('#cev_cont_stats').html('');
  90. $('#graph').empty();
  91. }
  92. }
  93. });
  94. }
  95. $(function() {
  96. var dates = $('#date_from, #date_to').datepicker({
  97. dateFormat: ".$quote_simple."yy-mm-dd".$quote_simple.",
  98. changeMonth: true,
  99. changeYear: true
  100. });
  101. });
  102. </script>";
  103. $htmlHeadXtra[] = '<script>
  104. $(function() {
  105. $("#cev_button").hide();
  106. $("#container-9").tabs({remote: true});
  107. });
  108. </script>';
  109. //Changes END
  110. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AccessDetails'));
  111. Display :: display_header('');
  112. $userInfo = api_get_user_info($user_id);
  113. $result_to_print = '';
  114. $sql_result = MySpace::get_connections_to_course($user_id, $courseInfo);
  115. $result_to_print = convert_to_string($sql_result);
  116. echo Display::page_header(get_lang('DetailsStudentInCourse'));
  117. echo Display::page_subheader(
  118. get_lang('User').': '.$userInfo['complete_name'].' - '.get_lang('Course').': '.$courseInfo['title'].' ('.$course_code.')'
  119. );
  120. $form->setDefaults(array('from' => $from, 'to' => $to));
  121. $form->display();
  122. ?>
  123. <br />
  124. <br />
  125. <div class="text-center" id="graph"></div>
  126. <br />
  127. <br />
  128. <div class="row">
  129. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6">
  130. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
  131. <?php echo get_lang('Statistics'); ?>
  132. </div><br />
  133. <div id="cev_cont_stats">
  134. <?php
  135. if ($result_to_print != '') {
  136. $rst = get_stats($user_id, $courseInfo, $session_id);
  137. $foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
  138. $foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
  139. $foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
  140. echo $foo_stats;
  141. } else {
  142. echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
  143. }
  144. ?>
  145. </div>
  146. <br />
  147. </div>
  148. <div class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6 col-md-6">
  149. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
  150. <?php echo get_lang('Details'); ?>
  151. </div><br />
  152. <div id="messages"></div>
  153. </div>
  154. </div>
  155. <?php
  156. Display:: display_footer();