Improved live stats - now showing remaining time

skala
Yannick Warnier 13 years ago
parent 845166729a
commit 55138ec1e4
  1. 10
      main/exercice/live_stats.php
  2. 15
      main/inc/ajax/exercise.ajax.php

@ -4,7 +4,7 @@
require_once 'exercise.class.php';
require_once 'question.class.php';
require_once 'answer.class.php';
$language_file = 'exercice';
$language_file = array('exercice','tracking');
require_once '../inc/global.inc.php';
require_once 'exercise.lib.php';
$this_section = SECTION_COURSES;
@ -39,15 +39,15 @@ $minutes = 60;
$url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Date'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
//Column config
$column_model = array(
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left'),
array('name'=>'start_date', 'index'=>'start_date', 'width'=>'100', 'align'=>'left'),
array('name'=>'question', 'index'=>'count_questions', 'width'=>'100', 'align'=>'left', 'sortable'=>'false'),
array('name'=>'score', 'index'=>'score', 'width'=>'100', 'align'=>'left','sortable'=>'false'),
array('name'=>'question', 'index'=>'count_questions', 'width'=>'60', 'align'=>'left', 'sortable'=>'false'),
array('name'=>'score', 'index'=>'score', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
);
//Autowidth
$extra_params['autowidth'] = 'true';
@ -87,4 +87,4 @@ echo $actions = Display::div($actions, array('class'=> 'actions'));
//echo Display::page_header(get_lang('StudentsWhoAreTakingTheExerciseRightNow'));
echo Display::grid_html('live_stats');
Display::display_footer();
Display::display_footer();

@ -88,7 +88,10 @@ switch ($action) {
while ($row = Database::fetch_array($result,'ASSOC')){
$results[] = $row;
}
$oExe = new exercise();
$oExe->read($exercise_id);
$response = new stdClass();
$response->page = $page;
$response->total = $total_pages;
@ -110,10 +113,14 @@ switch ($action) {
$row['count_questions'] = $count_questions;
$response->rows[$i]['id'] = $row['exe_id'];
$response->rows[$i]['id'] = $row['exe_id'];
$remaining = strtotime($row['start_date'])+($oExe->expired_time*60) - strtotime(api_get_utc_datetime(time()));
$h = floor($remaining/3600);
$m = floor(($remaining - ($h*3600))/60);
$s = ($remaining - ($h*3600) - ($m*60));
$array = array( $row['firstname'],
$row['lastname'],
api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG),
api_format_date($row['start_date'], DATE_TIME_FORMAT_LONG).' ['.($h>0?$h.':':'').sprintf("%02d",$m).':'.sprintf("%02d",$s).']',
$row['count_questions'],
round($row['score']*100).'%'
);
@ -360,4 +367,4 @@ switch ($action) {
default:
echo '';
}
exit;
exit;

Loading…
Cancel
Save