access_details.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the tracking library for Chamilo.
  5. *
  6. * @package chamilo.library
  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. // name of the language file that needs to be included
  16. $language_file = array ('registration', 'index', 'tracking');
  17. require_once '../inc/global.inc.php';
  18. // including additional libraries
  19. require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
  20. require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
  21. require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
  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. $connections = MySpace::get_connections_to_course($user_id, $course_code, $session_id);
  31. $quote_simple = "'";
  32. $htmlHeadXtra[] = api_get_jquery_ui_js();
  33. $htmlHeadXtra[] = '<script src="slider.js" type="text/javascript" language="javascript"></script>';
  34. $htmlHeadXtra[] = '<link rel="stylesheet" href="slider.css" />';
  35. $htmlHeadXtra[] = '<script type="text/javascript">
  36. $(function() {
  37. var dates = $( "#date_from, #date_to" ).datepicker({
  38. dateFormat: '.$quote_simple.'yy-mm-dd'.$quote_simple.',
  39. changeMonth: true,
  40. changeYear: true,
  41. onSelect: function( selectedDate ) {
  42. var foo = areBothFilled();
  43. var option = this.id == "date_from" ? "minDate" : "maxDate",
  44. instance = $( this ).data( "datepicker" );
  45. date = $.datepicker.parseDate(
  46. instance.settings.dateFormat ||
  47. $.datepicker._defaults.dateFormat,
  48. selectedDate, instance.settings );
  49. dates.not( this ).datepicker( "option", option, date );
  50. if (foo){
  51. var start_date = document.getElementById("date_from").value;
  52. var end_date = document.getElementById("date_to").value;
  53. changeHREF(start_date,end_date);
  54. var foo_student = '.$user_id.';
  55. var foo_course = "'.$course_code.'";
  56. var graph_type = "'.$type.'";
  57. var foo_slider_state = getSliderState();
  58. if (foo_slider_state == "open"){
  59. sliderAction();
  60. }
  61. $.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)
  62. {
  63. if (!db.is_empty){
  64. // Display confirmation message to the user
  65. $("#messages").html(db.result).stop().css("opacity", 1).fadeIn(30);
  66. $("#cev_cont_stats").html(db.stats);
  67. $( "#ui-tabs-1" ).empty();
  68. $( "#ui-tabs-2" ).empty();
  69. $( "#ui-tabs-1" ).html(db.graph_result);
  70. $( "#ui-tabs-2" ).html(db.graph_result);
  71. }
  72. else{
  73. $("#messages").text("No existen registros para este rango");
  74. $("#messages").addClass("warning-message");
  75. $("#cev_cont_stats").html(db.stats);
  76. $( "#ui-tabs-1" ).empty();
  77. $( "#ui-tabs-1" ).html(db.graph_result);
  78. controlSliderMenu(foo_height);
  79. }
  80. var foo_height = sliderGetHeight("#messages");
  81. sliderSetHeight(".slider",foo_height);
  82. controlSliderMenu(foo_height);
  83. //$("#messages").css("height", 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 type="text/javascript">
  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 type="text/javascript">
  134. $(function() {
  135. $("#cev_button").hide();
  136. $("#container-9").tabs({remote: true});
  137. });
  138. </script>';
  139. //Changes END
  140. Display :: display_header('');
  141. $main_user_info = api_get_user_info($user_id);
  142. $result_to_print = '';
  143. $main_date_array = array();
  144. $sql_result = MySpace::get_connections_to_course($user_id, $course_code);
  145. $result_to_print = convert_to_string($sql_result);
  146. api_display_tool_title(get_lang('DetailsStudentInCourse'));
  147. ?>
  148. <div id="cev_results_header" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  149. <div id="cev_cont" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
  150. <?php echo '<strong>'.get_lang('User').': '.api_get_person_name($main_user_info['firstName'], $main_user_info['lastName']).'</strong> <br /> <strong>'.get_lang('Course').': </strong>'.$course_code; ?></div>
  151. <br />
  152. <form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform">
  153. <div id="cev_cont_header">
  154. <p><?php echo get_lang('SelectADateRange')?></p>
  155. <label for="to"><?php echo get_lang('From')?></label>
  156. <input type="text" id="date_from" name="from"/>
  157. <label for="to"><?php echo get_lang('Until')?></label>
  158. <input type="text" id="date_to" name="to"/>
  159. </div><br /><br />
  160. </form>
  161. <input id="cev_button" type=button class="ui-state-default ui-corner-all" value="Resetear Fechas" onClick="javascript:window.location='access_details.php?course=<?php echo $course_code?>&student=<?php echo $user_id?>&cidReq=<?php echo $course_code ?>';" >
  162. </div><br />
  163. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  164. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"><?php echo get_lang('Statistics'); ?></div><br />
  165. <div id="cev_cont_stats">
  166. <?php
  167. if ($result_to_print != "") {
  168. $rst = get_stats($user_id, $course_code);
  169. $foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
  170. $foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
  171. $foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
  172. echo $foo_stats;
  173. } else {
  174. echo Display::display_warning_message(get_lang('NoDataAvailable'));
  175. }
  176. ?>
  177. </div><br />
  178. </div><br />
  179. <div id="container-9">
  180. <ul>
  181. <li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=day&course='.$course_code.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('Day')); ?></span></a></li>
  182. <li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=month&course='.$course_code.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('MinMonth')); ?></span></a></li>
  183. </ul>
  184. </div>
  185. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  186. <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 />
  187. <div id="cev_cont_results" >
  188. <div id="cev_slider" class="slider">
  189. <?php
  190. if ($result_to_print != "") {
  191. echo $result_to_print;
  192. } else {
  193. Display::display_warning_message(get_lang('NoDataAvailable'));
  194. }
  195. ?>
  196. </div>
  197. <?php
  198. if ($result_to_print != "") {
  199. echo ('<br /><div class="slider_menu">
  200. <a href="#" onclick="return sliderAction();">'.get_lang('More').'</a>
  201. </div><br />');
  202. }?>
  203. </div>
  204. </div><br />
  205. <?php
  206. Display:: display_footer();