access_details.php 5.0 KB

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