read($exerciseId); if (!$result) { api_not_allowed(true); } $stats = ExerciseLib::getTrackExerciseAttemptsTable($objExercise); $table = new HTML_Table(['class' => 'table table-hover table-striped data_table']); $row = 0; $column = 0; foreach ($stats['headers'] as $header) { $table->setHeaderContents($row, $column, $header); $column++; } if ($exportXls) { $tableXls[] = $stats['headers_xls']; } $row++; foreach ($stats['rows'] as $rowTable) { $column = 0; foreach ($rowTable as $key => $cell) { $table->setCellContents($row, $column, $cell); $table->updateCellAttributes($row, $column, 'align="center"'); if ($exportXls) { $rowTable[$key] = strip_tags($cell); } $column++; } $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true); if ($exportXls) { $tableXls[] = $rowTable; } $row++; } $nameTools = get_lang('Results').': '.$objExercise->selectTitle(true); $content = ''; $content .= '
'; $content .= $table->toHtml(); $content .= '
'; if ($exportXls) { $fileName = get_lang('Report').'_'.api_get_course_id().'_'.api_get_local_time(); $tableXls = array_merge($tableXls); Export::arrayToXls($tableXls, $fileName); exit; } $interbreadcrumb[] = [ "url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'), ]; $interbreadcrumb[] = [ 'url' => "admin.php?exerciseId=$exerciseId&".api_get_cidreq(), 'name' => $objExercise->selectTitle(true), ]; $tpl = new Template(get_lang('ReportByAttempts')); $actions = ''. Display::return_icon( 'back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM ) .''; $actions .= Display::url( Display::return_icon('excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM), 'stats_attempts.php?exerciseId='.$exerciseId.'&export_xls=1&'.api_get_cidreq() ); $actions = Display::div($actions, ['class' => 'actions']); $content = $actions.$content; $tpl->assign('content', $content); $tpl->display_one_col_template();