Add column "session_access_start_date" in report see BT#13187

pull/2487/head
jmontoyaa 7 years ago
parent c417011a44
commit d440f6eed2
  1. 2
      main/exercise/exercise_report.php
  2. 23
      main/inc/ajax/model.ajax.php
  3. 16
      main/inc/lib/exercise.lib.php
  4. 30
      main/mySpace/exercise_category_report.php

@ -316,7 +316,7 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
if (api_is_platform_admin() || api_is_course_admin() ||
api_is_course_tutor() || api_is_session_general_coach()
) {
$actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'">'.
$actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
$actions .= '<a href="live_stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.
Display::return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM).'</a>';

@ -554,8 +554,15 @@ switch ($action) {
);
break;
case 'get_exercise_results_report':
$exerciseId = $_REQUEST['exercise_id'];
api_protect_admin_script();
$exerciseId = isset($_REQUEST['exercise_id']) ? $_REQUEST['exercise_id'] : 0;
$courseId = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : 0;
if (empty($exerciseId)) {
exit;
}
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
} else {
@ -1217,21 +1224,25 @@ switch ($action) {
);
break;
case 'get_exercise_results_report':
api_protect_admin_script();
// Used inside ExerciseLib::get_exam_results_data()
$documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path']."/document";
$sessionId = api_get_session_id();
$columns = array(
'firstname',
'lastname',
'username',
'session',
'start_date',
'session_access_start_date',
'exe_date',
'score'
);
if ($operation == 'excel') {
$overwriteColumnHeaderExport['session_access_start_date'] = get_lang('SessionStartDate');
$overwriteColumnHeaderExport['exe_date'] = get_lang('StartDate');
}
$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
if (!empty($categoryList)) {
foreach ($categoryList as $categoryInfo) {
@ -1244,7 +1255,6 @@ switch ($action) {
}
$columns[] = 'actions';
$result = ExerciseLib::get_exam_results_data(
$start,
$limit,
@ -1255,7 +1265,8 @@ switch ($action) {
false,
$courseInfo['code'],
true,
true
true,
!empty($sessionId)
);
break;
case 'get_hotpotatoes_exercise_results':

@ -1676,6 +1676,7 @@ HOTSPOT;
* @param null $extra_where_conditions
* @param bool $get_count
* @param string $courseCode
*
* @return array
*/
public static function get_exam_results_data(
@ -2238,12 +2239,17 @@ HOTSPOT;
$category_list = [];
if ($is_allowedToEdit) {
$sessionName = '';
$sessionStartAccessDate = '';
if (!empty($results[$i]['session_id'])) {
$sessionName = api_get_session_name($results[$i]['session_id']);
$sessionInfo = api_get_session_info($results[$i]['session_id']);
if (!empty($sessionInfo)) {
$sessionName = $sessionInfo['name'];
$sessionStartAccessDate = api_get_local_time($sessionInfo['access_start_date']);
}
}
$objExercise = new Exercise($course_id);
if ($showExerciseCategories) {
$question_list = array();
// Getting attempt info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId);
if (!empty($exercise_stat_info['data_tracking'])) {
@ -2312,6 +2318,7 @@ HOTSPOT;
$results[$i]['category_'.$categoryId] = self::show_score($result['score'], $result['total']);
}
$results[$i]['session'] = $sessionName;
$results[$i]['session_access_start_date'] = $sessionStartAccessDate;
$results[$i]['status'] = $revisedLabel;
$results[$i]['score'] = $score;
$results[$i]['lp'] = $lp_name;
@ -2352,8 +2359,9 @@ HOTSPOT;
null,
date_default_timezone_get()
);
$hp_result = round(($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100, 2)
.'% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')';
$hp_result = round(($hpresults[$i][4] / ($hpresults[$i][5] != 0 ? $hpresults[$i][5] : 1)) * 100, 2);
$hp_result .= '% ('.$hpresults[$i][4].' / '.$hpresults[$i][5].')';
if ($is_allowedToEdit) {
$list_info[] = array(
$hpresults[$i][0],

@ -90,15 +90,15 @@ if ($form->validate() && !empty($courseInfo)) {
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results_report&exercise_id='.$exerciseId.'&start_date='.$startDate.'&cidReq='.$courseInfo['code'].'&export_filename='.$exportFilename;
$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
$columns = array(
$columns = [
get_lang('FirstName'),
get_lang('LastName'),
get_lang('LoginName'),
get_lang('Session'),
get_lang('SessionStartDate'),
get_lang('StartDate'),
get_lang('EndDate'),
get_lang('Score')
);
];
if (!empty($categoryList)) {
foreach ($categoryList as $categoryInfo) {
@ -107,15 +107,21 @@ if ($form->validate() && !empty($courseInfo)) {
}
$columns[] = get_lang('Actions');
$columnModel = array(
array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'true'),
array('name' => 'lastname', 'index' => 'lastname', 'width' => '50', 'align' => 'left', 'formatter' => 'action_formatter', 'search' => 'true'),
array('name' => 'login', 'index' => 'username', 'width' => '40', 'align' => 'left', 'search' => 'true', 'hidden' => 'true'),
array('name' => 'session', 'index' => 'session', 'width' => '40', 'align' => 'left', 'search' => 'false'),
array('name' => 'start_date', 'index' => 'start_date', 'width' => '60', 'align' => 'left', 'search' => 'true'),
array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'true'),
array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'center', 'search' => 'true')
);
$columnModel = [
['name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'true'],
['name' => 'lastname', 'index' => 'lastname', 'width' => '50', 'align' => 'left', 'formatter' => 'action_formatter', 'search' => 'true'],
['name' => 'login', 'index' => 'username', 'width' => '40', 'align' => 'left', 'search' => 'true', 'hidden' => 'true'],
['name' => 'session', 'index' => 'session', 'width' => '40', 'align' => 'left', 'search' => 'false'],
[
'name' => 'session_access_start_date',
'index' => 'session_access_start_date',
'width' => '50',
'align' => 'center',
'search' => 'true',
],
['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'true'],
['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'center', 'search' => 'true'],
];
if (!empty($categoryList)) {
foreach ($categoryList as $categoryInfo) {

Loading…
Cancel
Save