access_details.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. $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("'.get_lang('NoDataAvailable').'");
  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. // Hide confirmation message and enable stars for "Rate this" control, after 2 sec...
  83. /*setTimeout(function(){
  84. $("#messages").fadeOut(1000, function(){ui.enable()})
  85. }, 2000);*/
  86. }, "json");
  87. $( "#cev_slider" ).empty();
  88. // Create element to use for confirmation messages
  89. $('.$quote_simple .'<div id="messages"/>'.$quote_simple .').appendTo("#cev_slider");
  90. }
  91. }
  92. });
  93. if (areBothFilled()){
  94. runEffect();
  95. }
  96. });
  97. </script>';
  98. $htmlHeadXtra[] = '<script type="text/javascript">
  99. function changeHREF(sd,ed) {
  100. var i = 0;
  101. var href = "";
  102. var href1 = "";
  103. $('.$quote_simple .'#container-9 a'.$quote_simple .').each(function() {
  104. href = $.data(this, '.$quote_simple .'href.tabs'.$quote_simple .');
  105. href1= href+"&sd="+sd+"&ed="+ed+"&range=1";
  106. $("#container-9").tabs("url", i, href1);
  107. var href1 = $.data(this, '.$quote_simple .'href.tabs'.$quote_simple .');
  108. i++
  109. })
  110. }
  111. function runEffect(){
  112. //most effect types need no options passed by default
  113. var options = {};
  114. //run the effect
  115. $("#cev_button").show('.$quote_simple .'slide'.$quote_simple .',options,500,cev_effect());
  116. }
  117. //callback function to bring a hidden box back
  118. function cev_effect(){
  119. setTimeout(function(){
  120. $("#cev_button:visible").removeAttr('.$quote_simple .'style'.$quote_simple .').hide().fadeOut();
  121. }, 1000);
  122. }
  123. function areBothFilled() {
  124. var returnValue = false;
  125. if ((document.getElementById("date_from").value != "") && (document.getElementById("date_to").value != "")){
  126. returnValue = true;
  127. }
  128. return returnValue;
  129. }
  130. </script>';
  131. $htmlHeadXtra[] = '<script type="text/javascript">
  132. $(function() {
  133. $("#cev_button").hide();
  134. $("#container-9").tabs({remote: true});
  135. });
  136. </script>';
  137. //Changes END
  138. $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('AccessDetails'));
  139. Display :: display_header('');
  140. $main_user_info = api_get_user_info($user_id);
  141. $result_to_print = '';
  142. $sql_result = MySpace::get_connections_to_course($user_id, $course_code);
  143. $result_to_print = convert_to_string($sql_result);
  144. echo Display::page_header(get_lang('DetailsStudentInCourse'));
  145. echo Display::page_subheader(get_lang('User').': '.api_get_person_name($main_user_info['firstName'], $main_user_info['lastName']).' - '.get_lang('Course').': '.$course_code);
  146. $form = new FormValidator('myform', 'post', "javascript:get(document.getElementById('myform'));", null, array('id' => 'myform'));
  147. $form->addElement('text', 'from', get_lang('From'), array('id' => 'date_from'));
  148. $form->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to'));
  149. $form->addElement('style_submit_button', 'reset', get_lang('Reset'), array('onclick' => "javascript:window.location='access_details.php?course=".$course_code."&student=".$user_id."&cidReq=".$course_code."';"));
  150. $form->display();
  151. ?>
  152. <div id="cev_results_header" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  153. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  154. <div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"><?php echo get_lang('Statistics'); ?></div><br />
  155. <div id="cev_cont_stats">
  156. <?php
  157. if ($result_to_print != "") {
  158. $rst = get_stats($user_id, $course_code);
  159. $foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
  160. $foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
  161. $foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
  162. echo $foo_stats;
  163. } else {
  164. echo Display::display_warning_message(get_lang('NoDataAvailable'));
  165. }
  166. ?>
  167. </div><br />
  168. </div><br />
  169. <div id="container-9">
  170. <ul>
  171. <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>
  172. <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>
  173. </ul>
  174. </div>
  175. <div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
  176. <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 />
  177. <div id="cev_cont_results" >
  178. <div id="cev_slider" class="slider">
  179. <?php
  180. if ($result_to_print != "") {
  181. echo $result_to_print;
  182. } else {
  183. Display::display_warning_message(get_lang('NoDataAvailable'));
  184. }
  185. ?>
  186. </div>
  187. <?php
  188. if ($result_to_print != "") {
  189. echo '<br /><div class="slider_menu">
  190. <a href="#" onclick="return sliderAction();"><img src="../img/icons/22/zoom_in.png"></a>
  191. </div>';
  192. }?>
  193. </div>
  194. </div><br />
  195. <?php
  196. Display:: display_footer();