deleteAll(); $cacheDriver->flushAll(); }*/ switch ($action) { case 'export_all': //Session::write('use_gradebook_cache', true); $cats = Category::load($cat_id, null, null, null, null, null, false); /** @var Category $cat */ $cat = $cats[0]; $allcat = $cat->get_subcategories( null, api_get_course_id(), api_get_session_id() ); $alleval = $cat->get_evaluations( null, true, api_get_course_id(), api_get_session_id() ); $alllink = $cat->get_links( null, true, api_get_course_id(), api_get_session_id() ); $gradebooktable = new GradebookTable( $cat, $allcat, $alleval, $alllink, null, // params true, // $exportToPdf false, // showteacher null, $userList, $loadStats ); $key = $gradebooktable->getPreloadDataKey(); // preloads data Session::erase($key); $defaultData = $gradebooktable->preloadData(); $tpl = new Template('', false, false, false); $params = [ 'pdf_title' => sprintf(get_lang('Grades from course: %s'), $courseInfo['name']), 'session_info' => '', 'course_info' => '', 'pdf_date' => '', 'course_code' => api_get_course_id(), 'student_info' => null, 'show_grade_generated_date' => true, 'show_real_course_teachers' => false, 'show_teacher_as_myself' => false, 'orientation' => 'P', ]; $pdf = new PDF('A4', $params['orientation'], $params, $tpl); $counter = 0; $htmlList = []; foreach ($userList as $index => $value) { $htmlList[] = GradebookUtils::generateTable( $courseInfo, $value['user_id'], $cats, false, true, $userList, $pdf ); $counter++; } if (!empty($htmlList)) { $counter = 0; $content = ''; foreach ($htmlList as $value) { $content .= $value.''; $counter++; } $tempFile = api_get_path(SYS_ARCHIVE_PATH).uniqid('gradebook_export_all').'.html'; file_put_contents($tempFile, $content); $pdf->html_to_pdf( $tempFile, null, null, false, true, true ); } // Delete calc_score session data Session::erase('calc_score'); break; case 'download': $userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null; $cats = Category::load($cat_id, null, null, null, null, null, false); GradebookUtils::generateTable($courseInfo, $userId, $cats); break; } $course_code = api_get_course_id(); $interbreadcrumb[] = [ 'url' => Category::getUrl(), 'name' => get_lang('Assessments'), ]; $interbreadcrumb[] = [ 'url' => '#', 'name' => get_lang('AssessmentsListOfLearnersReports'), ]; $this_section = SECTION_COURSES; Display::display_header(''); $token = Security::get_token(); echo Display::page_header(get_lang('AssessmentsListOfLearnersReports')); echo '
'; if (count($userList) > 0) { $url = api_get_self().'?action=export_all&'.api_get_cidreq().'&selectcat='.$cat_id; echo Display::url(get_lang('Export all to PDF'), $url, ['class' => 'btn btn-default']); } echo '
'; $allowSkillRelItem = api_get_configuration_value('allow_skill_rel_items'); if (count($userList) == 0) { echo Display::return_message(get_lang('No results available'), 'warning'); } else { echo '

'; echo ''; echo ''; foreach ($userList as $index => $value) { echo ''; echo ''; } echo '
'; echo get_lang('Learner'); echo ''; echo get_lang('Action'); echo '
' .api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') '; $link = ''; if ($allowSkillRelItem) { $url = api_get_path(WEB_CODE_PATH).'gradebook/skill_rel_user.php?'.api_get_cidreq().'&user_id='.$value['user_id'].'&selectcat='.$cat_id; $link = Display::url( get_lang('Skills'), $url, ['class' => 'btn btn-default'] ).' '; } $url = api_get_self().'?'.api_get_cidreq().'&action=download&user_id='.$value['user_id'].'&selectcat='.$cat_id; $link .= Display::url( get_lang('Export to PDF'), $url, ['target' => '_blank', 'class' => 'btn btn-default'] ); echo $link; echo '
'; } Display::display_footer();