From 4d002d776ee97c9de644291a7e1dce170011c514 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 29 Sep 2022 10:16:38 +0800 Subject: [PATCH] fix: problem order in contest --- web/app/libs/uoj-query-lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/app/libs/uoj-query-lib.php b/web/app/libs/uoj-query-lib.php index a64dc91..c7dd6e6 100644 --- a/web/app/libs/uoj-query-lib.php +++ b/web/app/libs/uoj-query-lib.php @@ -108,7 +108,8 @@ function queryContestProblemRank($contest, $problem) { if (!DB::selectFirst("select * from contests_problems where contest_id = {$contest['id']} and problem_id = {$problem['id']}")) { return null; } - return DB::selectCount("select count(*) from contests_problems where contest_id = {$contest['id']} and problem_id <= {$problem['id']}"); + $contest_problems = DB::selectAll("select problem_id from contests_problems where contest_id = {$contest['id']} order by dfn, problem_id"); + return array_search(array('problem_id' => $problem['id']), $contest_problems) + 1; } function querySubmission($id) { return DB::selectFirst("select * from submissions where id = $id", MYSQLI_ASSOC);