$_SESSION['gradebook_dest'].'?selectcat=1', 'name' => get_lang('ToolGradebook'));
$showeval = isset($_POST['showeval']) ? '1' : '0';
$showlink = isset($_POST['showlink']) ? '1' : '0';
if (($showlink == '0') && ($showeval == '0')) {
$showlink = '1';
$showeval = '1';
}
$cat = Category::load($_REQUEST['selectcat']);
if (isset($_GET['userid'])) {
$userid = Security::remove_XSS($_GET['userid']);
} else {
$userid = '';
}
if ($showeval) {
$alleval = $cat[0]->get_evaluations($userid, true);
} else {
$alleval = null;
}
if ($showlink) {
$alllinks = $cat[0]->get_links($userid, true);
} else {
$alllinks = null;
}
if (isset($export_flatview_form) && (!$file_type == 'pdf')) {
Display :: display_normal_message($export_flatview_form->toHtml(), false);
}
if (isset($_GET['selectcat'])) {
$category_id = Security::remove_XSS($_GET['selectcat']);
} else {
$category_id = '';
}
$simple_search_form = new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . $category_id);
$values = $simple_search_form->exportValues();
$keyword = '';
if (isset($_GET['search']) && !empty($_GET['search'])) {
$keyword = Security::remove_XSS($_GET['search']);
}
if ($simple_search_form->validate() && (empty($keyword))) {
$keyword = $values['keyword'];
}
if (!empty($keyword)) {
$users = find_students($keyword);
} else {
if (isset($alleval) && isset($alllinks)) {
$users = get_all_users($alleval, $alllinks);
} else {
$users = null;
}
}
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams);
$parameters=array('selectcat'=>intval($_GET['selectcat']));
$flatviewtable->set_additional_parameters($parameters);
if (isset($_GET['exportpdf'])) {
$interbreadcrumb[] = array (
'url' => api_get_self().'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('FlatView')
);
$export_pdf_form = new DataForm(DataForm::TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self().'?exportpdf=&offset='.intval($_GET['offset']).'&selectcat='.intval($_GET['selectcat']), '_blank', '');
if ($export_pdf_form->validate()) {
// Beginning of PDF report creation
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks);
$export = $export_pdf_form->exportValues();
// Reading report's CSS
//$css_file = api_get_path(TO_SYS, WEB_CSS_PATH).api_get_setting('stylesheets').'/print.css';
$css_file = api_get_path(SYS_CODE_PATH).'gradebook/print.css';
$css = file_exists($css_file) ? @file_get_contents($css_file) : '';
// HTML report creation first
$time = time();
$cat_name = trim($cat[0]->get_name());
$course_code = trim($cat[0]->get_course_code());
$organization = api_get_setting('Institution');
$displayscore = ScoreDisplay :: instance();
$customdisplays = $displayscore->get_custom_score_display_settings();
if (is_array($customdisplays) && count(($customdisplays))) {
$total = array();
foreach($customdisplays as $custom) {
$total[$custom['display']] = 0;
}
$user_results = $flatviewtable->datagen->get_data_to_graph2();
foreach($user_results as $user_result) {
$total[$user_result[count($user_result)-1][1]]++;
}
}
$html = '';
$img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
if (file_exists($img)) {
$img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$html .= "";
} else {
if (!empty($organization)) {
$html .= '
';
$html .= ' | ';
$html .= '