exportCompleteReportCSV($documentPath, $hotpotatoes_path);
exit;
} else {
api_not_allowed(true);
}
}
$actions = null;
if ($is_allowedToEdit && $origin != 'learnpath') {
// the form
if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_session_general_coach()) {
$actions .= ''.
Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'';
}
} else {
$actions .= ''.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'';
}
if ($is_allowedToEdit) {
$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
case 'delete':
$fileToDelete = isset($_GET['id']) ? $_GET['id'] : null;
deleteAttempt($fileToDelete);
Display::addFlash(Display::return_message(get_lang('ItemDeleted')));
$url = api_get_self().'?'.api_get_cidreq().'&path='.$hotpotatoes_path;
header("Location: $url");
exit;
break;
}
}
$nameTools = get_lang('Results');
if ($is_allowedToEdit || $is_tutor) {
$nameTools = get_lang('StudentScore');
$interbreadcrumb[] = ["url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises')];
$objExerciseTmp = new Exercise();
} else {
$interbreadcrumb[] = ["url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises')];
$objExerciseTmp = new Exercise();
}
Display :: display_header($nameTools);
$actions = Display::div($actions, ['class' => 'actions']);
$extra = '';
$extra .= '
';
$form = new FormValidator('report', 'post', null, null, ['class' => 'form-vertical']);
$form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv', ['id' => 'export_format_csv_label']);
//$form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label'));
//$form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label'));
$form->setDefaults(['export_format' => 'csv']);
$extra .= $form->returnForm();
$extra .= '
';
if ($is_allowedToEdit) {
echo $extra;
}
echo $actions;
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_hotpotatoes_exercise_results&path='.$hotpotatoes_path.'&filter_by_user='.$filter_user;
$action_links = '';
// Generating group list
$group_list = GroupManager::get_group_list();
$group_parameters = ['group_all:'.get_lang('All'), 'group_none:'.get_lang('None')];
foreach ($group_list as $group) {
$group_parameters[] = $group['id'].':'.$group['name'];
}
if (!empty($group_parameters)) {
$group_parameters = implode(';', $group_parameters);
}
if ($is_allowedToEdit || $is_tutor) {
// The order is important you need to check the the $column variable in the model.ajax.php file
$columns = [
get_lang('FirstName'),
get_lang('LastName'),
get_lang('LoginName'),
get_lang('Group'),
get_lang('StartDate'),
get_lang('Score'),
get_lang('Actions'),
];
// Column config
// @todo fix search firstname/lastname that doesn't work. rmove search for the moment
$column_model = [
['name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'false'],
[
'name' => 'lastname',
'index' => 'lastname',
'width' => '50',
'align' => 'left',
'formatter' => 'action_formatter',
'search' => 'false',
],
[
'name' => 'login',
'hidden' => 'true',
'index' => 'username',
'width' => '40',
'align' => 'left',
'search' => 'false',
],
['name' => 'group_name', 'index' => 'group_id', 'width' => '40', 'align' => 'left', 'search' => 'false'],
['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'],
['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'],
['name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'],
];
$action_links = '
// add username as title in lastname filed - ref 4226
function action_formatter(cellvalue, options, rowObject) {
// rowObject is firstname,lastname,login,... get the third word
var loginx = "'.api_htmlentities(sprintf(get_lang("LoginX"), ":::"), ENT_QUOTES).'";
var tabLoginx = loginx.split(/:::/);
// tabLoginx[0] is before and tabLoginx[1] is after :::
// may be empty string but is defined
return ""+cellvalue+"";
}';
} else {
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = [
get_lang('StartDate'),
get_lang('Score'),
get_lang('Actions'),
];
//Column config
// @todo fix search firstname/lastname that doesn't work. rmove search for the moment
$column_model = [
['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'],
['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'],
['name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'],
];
}
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
?>