access_details.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. $connections = MySpace::get_connections_to_course($user_id, $courseId, $session_id);
  27. $quote_simple = "'";
  28. $form = new FormValidator(
  29. 'myform',
  30. 'get',
  31. api_get_self(),
  32. null,
  33. array('id' => 'myform')
  34. );
  35. $form->addElement('text', 'from', get_lang('From'), array('id' => 'date_from'));
  36. $form->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to'));
  37. $form->addElement(
  38. 'select',
  39. 'type',
  40. get_lang('Type'),
  41. array('day' => get_lang('Day'), 'month' => get_lang('Month')),
  42. array('id' => 'type')
  43. );
  44. $form->addElement('hidden', 'student', $user_id);
  45. $form->addElement('hidden', 'course', $course_code);
  46. $form->addRule('from', get_lang('ThisFieldIsRequired'), 'required');
  47. $form->addRule('to', get_lang('ThisFieldIsRequired'), 'required');
  48. $group = array(
  49. $form->createElement(
  50. 'label',
  51. null,
  52. Display::url(get_lang('Search'), 'javascript://', array('onclick'=> 'loadGraph();', 'class' => 'btn btn-default'))
  53. )
  54. );
  55. $form->addGroup($group);
  56. $from = null;
  57. $to = null;
  58. $course = $course_code;
  59. if ($form->validate()) {
  60. $values = $form->getSubmitValues();
  61. $from = $values['from'];
  62. $to = $values['to'];
  63. $type = $values['type'];
  64. $course = $values['course'];
  65. }
  66. $url = api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail_by_date&course='.$course.'&student='.$user_id;
  67. $htmlHeadXtra[] = '<script src="slider.js" type="text/javascript"></script>';
  68. $htmlHeadXtra[] = '<link rel="stylesheet" href="slider.css" />';
  69. $htmlHeadXtra[] = "<script>
  70. function loadGraph() {
  71. var startDate = $('#date_from').val();
  72. var endDate = $('#date_to').val();
  73. var type = $('#type option:selected').val();
  74. $.ajax({
  75. url: '".$url."&startDate='+startDate+'&endDate='+endDate+'&type='+type,
  76. dataType: 'json',
  77. success: function(db) {
  78. if (!db.is_empty) {
  79. // Display confirmation message to the user
  80. $('#messages').html(db.result).stop().css('opacity', 1).fadeIn(30);
  81. $('#cev_cont_stats').html(db.stats);
  82. $('#graph' ).html(db.graph_result);
  83. } else {
  84. $('#messages').text('".get_lang('NoDataAvailable')."');
  85. $('#messages').addClass('warning-message');
  86. $('#cev_cont_stats').html('');
  87. $('#graph').empty();
  88. }
  89. }
  90. });
  91. }
  92. $(function() {
  93. var dates = $('#date_from, #date_to').datepicker({
  94. dateFormat: ".$quote_simple."yy-mm-dd".$quote_simple.",
  95. changeMonth: true,
  96. changeYear: true
  97. });
  98. });
  99. </script>";
  100. $htmlHeadXtra[] = '<script>
  101. $(function() {
  102. $("#cev_button").hide();
  103. $("#container-9").tabs({remote: true});
  104. });
  105. </script>';
  106. //Changes END
  107. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AccessDetails'));
  108. Display :: display_header('');
  109. $userInfo = api_get_user_info($user_id);
  110. $result_to_print = '';
  111. $sql_result = MySpace::get_connections_to_course($user_id, $courseId);
  112. $result_to_print = convert_to_string($sql_result);
  113. echo Display::page_header(get_lang('DetailsStudentInCourse'));
  114. echo Display::page_subheader(
  115. get_lang('User').': '.$userInfo['complete_name'].' - '.get_lang('Course').': '.$courseInfo['title'].' ('.$course_code.')'
  116. );
  117. $form->setDefaults(array('from' => $from, 'to' => $to));
  118. $form->display();
  119. ?>
  120. <br />
  121. <br />
  122. <div class="text-center" id="graph"></div>
  123. <br />
  124. <br />
  125. <div class="row">
  126. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6">
  127. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
  128. <?php echo get_lang('Statistics'); ?>
  129. </div><br />
  130. <div id="cev_cont_stats">
  131. <?php
  132. if ($result_to_print != "") {
  133. $rst = get_stats($user_id, $courseId);
  134. $foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
  135. $foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
  136. $foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
  137. echo $foo_stats;
  138. } else {
  139. echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
  140. }
  141. ?>
  142. </div>
  143. <br />
  144. </div>
  145. <div class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6 col-md-6">
  146. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
  147. <?php echo get_lang('Details'); ?>
  148. </div><br />
  149. <div id="messages"></div>
  150. </div>
  151. </div>
  152. <?php
  153. Display:: display_footer();