access_details.php 4.9 KB

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