access_details.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 'myspace.lib.php';
  23. // the section (for the tabs)
  24. $this_section = SECTION_TRACKING;
  25. /* MAIN */
  26. $user_id = intval($_REQUEST['student']);
  27. $session_id = intval($_GET['id_session']);
  28. $type = Security::remove_XSS($_REQUEST['type']);
  29. $course_code = Security::remove_XSS($_REQUEST['course']);
  30. $courseInfo = api_get_course_info($course_code);
  31. $courseId = $courseInfo['real_id'];
  32. $connections = MySpace::get_connections_to_course($user_id, $courseId, $session_id);
  33. $quote_simple = "'";
  34. $htmlHeadXtra[] = '<script src="slider.js" type="text/javascript"></script>';
  35. $htmlHeadXtra[] = '<link rel="stylesheet" href="slider.css" />';
  36. $htmlHeadXtra[] = '<script>
  37. $(function() {
  38. var dates = $( "#date_from, #date_to" ).datepicker({
  39. dateFormat: '.$quote_simple.'yy-mm-dd'.$quote_simple.',
  40. changeMonth: true,
  41. changeYear: true,
  42. onSelect: function( selectedDate ) {
  43. var foo = areBothFilled();
  44. var option = this.id == "date_from" ? "minDate" : "maxDate",
  45. instance = $( this ).data( "datepicker" );
  46. date = $.datepicker.parseDate(
  47. instance.settings.dateFormat ||
  48. $.datepicker._defaults.dateFormat,
  49. selectedDate, instance.settings );
  50. dates.not( this ).datepicker( "option", option, date );
  51. if (foo){
  52. var start_date = document.getElementById("date_from").value;
  53. var end_date = document.getElementById("date_to").value;
  54. changeHREF(start_date,end_date);
  55. var foo_student = '.$user_id.';
  56. var foo_course = "'.$courseId.'";
  57. var graph_type = "'.$type.'";
  58. var foo_slider_state = getSliderState();
  59. if (foo_slider_state == "open"){
  60. sliderAction();
  61. }
  62. $.post("'.api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail_by_date", {startDate: start_date, endDate: end_date, course: foo_course, student: foo_student, type: graph_type}, function(db)
  63. {
  64. if (!db.is_empty){
  65. // Display confirmation message to the user
  66. $("#messages").html(db.result).stop().css("opacity", 1).fadeIn(30);
  67. $("#cev_cont_stats").html(db.stats);
  68. $( "#ui-tabs-1" ).empty();
  69. $( "#ui-tabs-2" ).empty();
  70. $( "#ui-tabs-1" ).html(db.graph_result);
  71. $( "#ui-tabs-2" ).html(db.graph_result);
  72. }
  73. else{
  74. $("#messages").text("'.get_lang('NoDataAvailable').'");
  75. $("#messages").addClass("warning-message");
  76. $("#cev_cont_stats").html(db.stats);
  77. $( "#ui-tabs-1" ).empty();
  78. $( "#ui-tabs-1" ).html(db.graph_result);
  79. controlSliderMenu(foo_height);
  80. }
  81. var foo_height = sliderGetHeight("#messages");
  82. sliderSetHeight(".slider",foo_height);
  83. controlSliderMenu(foo_height);
  84. // Hide confirmation message and enable stars for "Rate this" control, after 2 sec...
  85. /*setTimeout(function(){
  86. $("#messages").fadeOut(1000, function(){ui.enable()})
  87. }, 2000);*/
  88. }, "json");
  89. $( "#cev_slider" ).empty();
  90. // Create element to use for confirmation messages
  91. $('.$quote_simple .'<div id="messages"/>'.$quote_simple .').appendTo("#cev_slider");
  92. }
  93. }
  94. });
  95. if (areBothFilled()){
  96. runEffect();
  97. }
  98. });
  99. </script>';
  100. $htmlHeadXtra[] = '<script>
  101. function changeHREF(sd,ed) {
  102. var i = 0;
  103. var href = "";
  104. var href1 = "";
  105. $('.$quote_simple .'#container-9 a'.$quote_simple .').each(function() {
  106. href = $.data(this, '.$quote_simple .'href.tabs'.$quote_simple .');
  107. href1= href+"&sd="+sd+"&ed="+ed+"&range=1";
  108. $("#container-9").tabs("url", i, href1);
  109. var href1 = $.data(this, '.$quote_simple .'href.tabs'.$quote_simple .');
  110. i++
  111. })
  112. }
  113. function runEffect(){
  114. //most effect types need no options passed by default
  115. var options = {};
  116. //run the effect
  117. $("#cev_button").show('.$quote_simple .'slide'.$quote_simple .',options,500,cev_effect());
  118. }
  119. //callback function to bring a hidden box back
  120. function cev_effect(){
  121. setTimeout(function(){
  122. $("#cev_button:visible").removeAttr('.$quote_simple .'style'.$quote_simple .').hide().fadeOut();
  123. }, 1000);
  124. }
  125. function areBothFilled() {
  126. var returnValue = false;
  127. if ((document.getElementById("date_from").value != "") && (document.getElementById("date_to").value != "")){
  128. returnValue = true;
  129. }
  130. return returnValue;
  131. }
  132. </script>';
  133. $htmlHeadXtra[] = '<script>
  134. $(function() {
  135. $("#cev_button").hide();
  136. $("#container-9").tabs({remote: true});
  137. });
  138. </script>';
  139. //Changes END
  140. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('AccessDetails'));
  141. Display :: display_header('');
  142. $main_user_info = api_get_user_info($user_id);
  143. $result_to_print = '';
  144. $sql_result = MySpace::get_connections_to_course($user_id, $courseId);
  145. $result_to_print = convert_to_string($sql_result);
  146. echo Display::page_header(get_lang('DetailsStudentInCourse'));
  147. echo Display::page_subheader(get_lang('User').': '.api_get_person_name($main_user_info['firstName'], $main_user_info['lastName']).' - '.get_lang('Course').': '.$course_code);
  148. $form = new FormValidator('myform', 'post', "javascript:get(document.getElementById('myform'));", null, array('id' => 'myform'));
  149. $form->addElement('text', 'from', get_lang('From'), array('id' => 'date_from'));
  150. $form->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to'));
  151. $form->addElement('style_submit_button', 'reset', get_lang('Reset'), array('onclick' => "javascript:window.location='access_details.php?course=".$courseId."&student=".$user_id."&cidReq=".$course_code."';"));
  152. $form->display();
  153. ?>
  154. <div id="cev_results_header" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  155. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  156. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"><?php echo get_lang('Statistics'); ?></div><br />
  157. <div id="cev_cont_stats">
  158. <?php
  159. if ($result_to_print != "") {
  160. $rst = get_stats($user_id, $courseId);
  161. $foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
  162. $foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
  163. $foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
  164. echo $foo_stats;
  165. } else {
  166. echo Display::display_warning_message(get_lang('NoDataAvailable'));
  167. }
  168. ?>
  169. </div><br />
  170. </div><br />
  171. <div id="container-9">
  172. <ul>
  173. <li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=day&course='.$courseId.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('Day')); ?></span></a></li>
  174. <li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=month&course='.$courseId.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('MinMonth')); ?></span></a></li>
  175. </ul>
  176. </div>
  177. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  178. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"><?php echo get_lang('DateAndTimeOfAccess'),' - ', get_lang('Duration') ?></div><br />
  179. <div id="cev_cont_results" >
  180. <div id="cev_slider" class="slider">
  181. <?php
  182. if ($result_to_print != "") {
  183. echo $result_to_print;
  184. } else {
  185. Display::display_warning_message(get_lang('NoDataAvailable'));
  186. }
  187. ?>
  188. </div>
  189. <?php
  190. if ($result_to_print != "") {
  191. echo '<br /><div class="slider_menu">
  192. <a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_in.png"></a>
  193. </div>';
  194. }?>
  195. </div>
  196. </div><br />
  197. <?php
  198. Display:: display_footer();