access_details.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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[] = '<script src="slider.js" type="text/javascript"></script>';
  33. $htmlHeadXtra[] = '<link rel="stylesheet" href="slider.css" />';
  34. $htmlHeadXtra[] = '<script type="text/javascript">
  35. $(function() {
  36. var dates = $( "#date_from, #date_to" ).datepicker({
  37. dateFormat: '.$quote_simple.'yy-mm-dd'.$quote_simple.',
  38. changeMonth: true,
  39. changeYear: true,
  40. onSelect: function( selectedDate ) {
  41. var foo = areBothFilled();
  42. var option = this.id == "date_from" ? "minDate" : "maxDate",
  43. instance = $( this ).data( "datepicker" );
  44. date = $.datepicker.parseDate(
  45. instance.settings.dateFormat ||
  46. $.datepicker._defaults.dateFormat,
  47. selectedDate, instance.settings );
  48. dates.not( this ).datepicker( "option", option, date );
  49. if (foo){
  50. var start_date = document.getElementById("date_from").value;
  51. var end_date = document.getElementById("date_to").value;
  52. changeHREF(start_date,end_date);
  53. var foo_student = '.$user_id.';
  54. var foo_course = "'.$course_code.'";
  55. var graph_type = "'.$type.'";
  56. var foo_slider_state = getSliderState();
  57. if (foo_slider_state == "open"){
  58. sliderAction();
  59. }
  60. $.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)
  61. {
  62. if (!db.is_empty){
  63. // Display confirmation message to the user
  64. $("#messages").html(db.result).stop().css("opacity", 1).fadeIn(30);
  65. $("#cev_cont_stats").html(db.stats);
  66. $( "#ui-tabs-1" ).empty();
  67. $( "#ui-tabs-2" ).empty();
  68. $( "#ui-tabs-1" ).html(db.graph_result);
  69. $( "#ui-tabs-2" ).html(db.graph_result);
  70. }
  71. else{
  72. $("#messages").text("No existen registros para este rango");
  73. $("#messages").addClass("warning-message");
  74. $("#cev_cont_stats").html(db.stats);
  75. $( "#ui-tabs-1" ).empty();
  76. $( "#ui-tabs-1" ).html(db.graph_result);
  77. controlSliderMenu(foo_height);
  78. }
  79. var foo_height = sliderGetHeight("#messages");
  80. sliderSetHeight(".slider",foo_height);
  81. controlSliderMenu(foo_height);
  82. //$("#messages").css("height", foo_height);
  83. // Hide confirmation message and enable stars for "Rate this" control, after 2 sec...
  84. /*setTimeout(function(){
  85. $("#messages").fadeOut(1000, function(){ui.enable()})
  86. }, 2000);*/
  87. }, "json");
  88. $( "#cev_slider" ).empty();
  89. // Create element to use for confirmation messages
  90. $('.$quote_simple .'<div id="messages"/>'.$quote_simple .').appendTo("#cev_slider");
  91. }
  92. }
  93. });
  94. if (areBothFilled()){
  95. runEffect();
  96. }
  97. });
  98. </script>';
  99. $htmlHeadXtra[] = '<script type="text/javascript">
  100. function changeHREF(sd,ed) {
  101. var i = 0;
  102. var href = "";
  103. var href1 = "";
  104. $('.$quote_simple .'#container-9 a'.$quote_simple .').each(function() {
  105. href = $.data(this, '.$quote_simple .'href.tabs'.$quote_simple .');
  106. href1= href+"&sd="+sd+"&ed="+ed+"&range=1";
  107. $("#container-9").tabs("url", i, href1);
  108. var href1 = $.data(this, '.$quote_simple .'href.tabs'.$quote_simple .');
  109. i++
  110. })
  111. }
  112. function runEffect(){
  113. //most effect types need no options passed by default
  114. var options = {};
  115. //run the effect
  116. $("#cev_button").show('.$quote_simple .'slide'.$quote_simple .',options,500,cev_effect());
  117. }
  118. //callback function to bring a hidden box back
  119. function cev_effect(){
  120. setTimeout(function(){
  121. $("#cev_button:visible").removeAttr('.$quote_simple .'style'.$quote_simple .').hide().fadeOut();
  122. }, 1000);
  123. }
  124. function areBothFilled() {
  125. var returnValue = false;
  126. if ((document.getElementById("date_from").value != "") && (document.getElementById("date_to").value != "")){
  127. returnValue = true;
  128. }
  129. return returnValue;
  130. }
  131. </script>';
  132. $htmlHeadXtra[] = '<script type="text/javascript">
  133. $(function() {
  134. $("#cev_button").hide();
  135. $("#container-9").tabs({remote: true});
  136. });
  137. </script>';
  138. //Changes END
  139. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('AccessDetails'));
  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();