access_details.php 5.3 KB

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