/** * @param int $userId * @param array $cats * @param bool $saveToFile * @param bool $saveToHtmlFile * @param array $studentList * @param PDF $pdf * * @return string */ public static function generateTable($userId, $cats, $saveToFile = false, $saveToHtmlFile = false, $studentList = array(), $pdf = null) { $courseInfo = api_get_course_info(); $userInfo = api_get_user_info($userId); $cat = $cats[0]; $allcat = $cats[0]->get_subcategories($userId, api_get_course_id(), api_get_session_id()); $alleval = $cats[0]->get_evaluations($userId); $alllink = $cats[0]->get_links($userId); $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, null, true, false, $userId, $studentList); $gradebooktable->userId = $userId; if (api_is_allowed_to_edit()) { $gradebooktable->td_attributes = [4 => 'class=centered']; } else { $gradebooktable->td_attributes = [3 => 'class=centered', 4 => 'class=centered', 5 => 'class=centered', 6 => 'class=centered', 7 => 'class=centered']; } $table = $gradebooktable->return_table(); $graph = $gradebooktable->getGraph(); $sessionName = api_get_session_name(api_get_session_id()); $sessionName = !empty($sessionName) ? " - {$sessionName}" : ''; $params = array('pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['department_name']), 'session_info' => '', 'course_info' => '', 'pdf_date' => '', 'course_code' => api_get_course_id(), 'add_signatures' => false, 'student_info' => $userInfo, 'show_grade_generated_date' => true, 'show_real_course_teachers' => false, 'show_teacher_as_myself' => false, 'orientation' => 'P'); if (empty($pdf)) { $pdf = new PDF('A4', $params['orientation'], $params); } $pdf->params['student_info'] = $userInfo; $file = api_get_path(SYS_ARCHIVE_PATH) . uniqid() . '.html'; $content = $table . $graph . '<br />' . get_lang('Feedback') . '<br /> <textarea rows="5" cols="100" ></textarea>'; $address = api_get_setting('institution_address'); $phone = api_get_setting('administratorTelephone'); $address = str_replace('\\n', '<br />', $address); $pdf->custom_header = array('html' => "<h5 align='right'>{$address} <br />{$phone}</h5>"); $result = $pdf->html_to_pdf_with_template($content, $saveToFile, $saveToHtmlFile); if ($saveToHtmlFile) { file_put_contents($file, $result); return $file; } return $file; }
<?php /* See license terms in /license.txt */ //require_once '../inc/global.inc.php'; $categoryId = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : false; if (empty($categoryId)) { api_not_allowed(false); } $userId = api_get_user_id(); $cats = Category::load($categoryId); if (isset($cats[0])) { $cat = $cats[0]; } $allcat = $cats[0]->get_subcategories($userId, api_get_course_id(), api_get_session_id()); $alleval = $cats[0]->get_evaluations($userId); $alllink = $cats[0]->get_links($userId); $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, array(), false); $gradebooktable->userId = $userId; $table = $gradebooktable->return_table(); echo $gradebooktable->getGraph();
} $exportToPdf = false; if ($action == 'export_table') { $exportToPdf = true; } $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams, $exportToPdf); if (api_is_allowed_to_edit()) { $gradebooktable->td_attributes = [4 => 'class=centered']; } else { $gradebooktable->td_attributes = [3 => 'class=centered', 4 => 'class=centered', 5 => 'class=centered', 6 => 'class=centered', 7 => 'class=centered']; if ($action == 'export_table') { unset($gradebooktable->td_attributes[7]); } } $table = $gradebooktable->return_table(); $graph = $gradebooktable->getGraph(); if ($action == 'export_table') { ob_clean(); $sessionName = api_get_session_name(api_get_session_id()); $sessionName = !empty($sessionName) ? " - {$sessionName}" : ''; $params = array('pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['department_name']), 'course_code' => api_get_course_id(), 'session_info' => '', 'course_info' => '', 'pdf_date' => '', 'add_signatures' => false, 'student_info' => api_get_user_info(), 'show_grade_generated_date' => true, 'show_real_course_teachers' => false, 'show_teacher_as_myself' => false); $pdf = new PDF('A4', $params['orientation'], $params); $address = api_get_setting('platform.institution_address'); $phone = api_get_setting('admin.administrator_phone'); $address = str_replace('\\n', '<br />', $address); $pdf->custom_header = array('html' => "<h5 align='right'>{$address} <br />{$phone}</h5>"); $pdf->html_to_pdf_with_template($table . $graph . '<br />' . get_lang('Feedback') . '<br /> <textarea rows="5" cols="100" ></textarea>'); } else { echo $table; echo $graph;
/** * @param int $userId * @param int $categoryId * @param bool $saveToFile * @param bool $saveToHtmlFile * * @return string */ public static function generateTable($userId, $categoryId, $saveToFile = false, $saveToHtmlFile = false) { $courseInfo = api_get_course_info(); $userInfo = api_get_user_info($userId); $cats = Category::load($categoryId, null, null, null, null, null, false); $cat = $cats[0]; $allcat = $cats[0]->get_subcategories($userId, api_get_course_id(), api_get_session_id()); $alleval = $cats[0]->get_evaluations($userId); $alllink = $cats[0]->get_links($userId); $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, null, true, false, $userId); if (api_is_allowed_to_edit()) { $gradebooktable->td_attributes = [4 => 'class=centered']; } else { $gradebooktable->td_attributes = [3 => 'class=centered', 4 => 'class=centered', 5 => 'class=centered', 6 => 'class=centered', 7 => 'class=centered']; } $table = $gradebooktable->return_table(); $graph = $gradebooktable->getGraph(); $sessionName = api_get_session_name(api_get_session_id()); $sessionName = !empty($sessionName) ? " - {$sessionName}" : ''; $params = array('pdf_title' => $courseInfo['title'] . $sessionName, 'course_code' => api_get_course_id(), 'session_info' => api_get_session_info(api_get_session_id()), 'add_signatures' => false, 'student_info' => $userInfo, 'show_grade_generated_date' => true, 'show_real_course_teachers' => true); $file = api_get_path(SYS_ARCHIVE_PATH) . uniqid() . '.html'; $content = $table . $graph . '<br />' . get_lang('Feedback') . '<br /> <textarea rows="5" cols="100" ></textarea>'; $pdf = new PDF('A4', $params['orientation'], $params); $result = $pdf->html_to_pdf_with_template($content, $saveToFile, $saveToHtmlFile); if ($saveToHtmlFile) { file_put_contents($file, $result); return $file; } return $file; }