live_stats.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /* See license terms in /license.txt */
  3. require_once 'exercise.class.php';
  4. require_once 'question.class.php';
  5. require_once 'answer.class.php';
  6. $language_file = array('exercice','tracking');
  7. //require_once '../inc/global.inc.php';
  8. $this_section = SECTION_COURSES;
  9. $exercise_id = (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) ? intval($_GET['exerciseId']) : 0;
  10. // Access control
  11. api_protect_course_script(true);
  12. if (!api_is_allowed_to_edit()) {
  13. api_not_allowed();
  14. }
  15. $objExercise = new Exercise();
  16. $result = $objExercise->read($exercise_id);
  17. if (!$result) {
  18. api_not_allowed(true);
  19. }
  20. $interbreadcrumb[] = array ("url" => "exercice.php", "name" => get_lang('Exercices'));
  21. $interbreadcrumb[] = array ("url" => "admin.php?exerciseId=$exercise_id","name" => $objExercise->name);
  22. //Add the JS needed to use the jqgrid
  23. $htmlHeadXtra[] = api_get_jqgrid_js();
  24. // The header.
  25. Display::display_header(get_lang('StudentsWhoAreTakingTheExerciseRightNow'));
  26. //jqgrid will use this URL to do the selects
  27. $minutes = 60;
  28. $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
  29. //The order is important you need to check the the $column variable in the model.ajax.php file
  30. $columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
  31. //Column config
  32. $column_model = array(
  33. array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left'),
  34. array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left'),
  35. array('name'=>'start_date', 'index'=>'start_date', 'width'=>'100', 'align'=>'left'),
  36. array('name'=>'question', 'index'=>'count_questions', 'width'=>'60', 'align'=>'left', 'sortable'=>'false'),
  37. array('name'=>'score', 'index'=>'score', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
  38. );
  39. //Autowidth
  40. $extra_params['autowidth'] = 'true';
  41. //height auto
  42. $extra_params['height'] = 'auto';
  43. ?>
  44. <script>
  45. function refreshGrid() {
  46. var grid = $("#live_stats");
  47. grid.trigger("reloadGrid");
  48. t = setTimeout("refreshGrid()", 10000);
  49. }
  50. $(function() {
  51. <?php
  52. echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true);
  53. ?>
  54. refreshGrid();
  55. });
  56. </script>
  57. <?php
  58. $actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
  59. echo $actions = Display::div($actions, array('class'=> 'actions'));
  60. //echo Display::page_header($objExercise->name);
  61. //echo Display::page_header(get_lang('StudentsWhoAreTakingTheExerciseRightNow'));
  62. echo Display::grid_html('live_stats');
  63. Display::display_footer();