diff --git a/web/app/controllers/contest_inside.php b/web/app/controllers/contest_inside.php index b705e7313..9f1f296da 100644 --- a/web/app/controllers/contest_inside.php +++ b/web/app/controllers/contest_inside.php @@ -396,6 +396,14 @@ function echoStandings() { $contest_data = queryContestData($contest); calcStandings($contest, $contest_data, $score, $standings); + if ($contest['cur_progress'] >= CONTEST_FINISHED && hasContestPermission(Auth::user(), $contest)) { + echo << + 下载排名 + + EOD; + } + uojIncludeView('contest-standings', [ 'contest' => $contest, 'standings' => $standings, @@ -550,4 +558,4 @@ function echoContestFinished() { - \ No newline at end of file + diff --git a/web/app/controllers/export_contest_standings_table.php b/web/app/controllers/export_contest_standings_table.php new file mode 100644 index 000000000..1880f724f --- /dev/null +++ b/web/app/controllers/export_contest_standings_table.php @@ -0,0 +1,68 @@ + $row) { + $row = [$rank, $row[2][0], $row[0], $row[1]]; + for ($i = 0; $i < $n_problems; $i++) { + $row[] = $score[$row[2][0]][$i][0] ?: ""; + $row[] = $score[$row[2][0]][$i][1] ?: ""; + $row[] = $score[$row[2][0]][$i][2] ?: ""; + } + $export_data[] = $row; +} + +$csv = array2csv($export_data); + +header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); +header("Last-Modified: {$now} GMT"); +header("Content-Type: text/csv"); +header("Content-Disposition: attachment;filename={$contest['id']}_standings.csv"); + +die($csv); diff --git a/web/app/route.php b/web/app/route.php index a4213e97a..3eabfbdf2 100644 --- a/web/app/route.php +++ b/web/app/route.php @@ -28,6 +28,7 @@ Route::any('/contest/{id}/submissions', '/contest_inside.php?tab=submissions'); Route::any('/contest/{id}/standings', '/contest_inside.php?tab=standings'); Route::any('/contest/{id}/backstage', '/contest_inside.php?tab=backstage'); + Route::any('/contest/{id}/export_standings', '/export_contest_standings_table.php'); Route::any('/contest/{contest_id}/problem/{id}', '/problem.php'); Route::any('/contest/{contest_id}/problem/{id}/statistics', '/problem_statistics.php');