From e38d44f0c5ac829cd54fd526d49ff8a1e197dc06 Mon Sep 17 00:00:00 2001
From: Baoshuo
Date: Tue, 18 Oct 2022 06:44:15 +0800
Subject: [PATCH] feat(web/contest): send system msg after publish final
standings
---
web/app/controllers/contest_inside.php | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/web/app/controllers/contest_inside.php b/web/app/controllers/contest_inside.php
index e9cbdb8..9af328c 100644
--- a/web/app/controllers/contest_inside.php
+++ b/web/app/controllers/contest_inside.php
@@ -141,13 +141,20 @@
global $contest;
$contest_data = queryContestData($contest);
+ $problems_count = DB::selectCount("select count(*) from contests_problems where contest_id = {$contest['id']} order by dfn, problem_id");
calcStandings($contest, $contest_data, $score, $standings, true);
for ($i = 0; $i < count($standings); $i++) {
- $user = queryUser($standings[$i][2][0]);
- $user_link = getUserLink($user['username']);
-
DB::query("update contests_registrants set rank = {$standings[$i][3]} where contest_id = {$contest['id']} and username = '{$standings[$i][2][0]}'");
+
+ $user_link = getUserLink($standings[$i][2][0]);
+ $total_score = $problems_count * 100;
+ $tail = $standings[$i][0] == $total_score ? ',请继续保持!' : ',请继续努力!';
+ $content = <<
您参与的比赛 {$contest['name']} 现已结束,您的成绩为 {$standings[$i][0]}{$tail}
+EOD; + sendSystemMsg($standings[$i][2][0], '比赛成绩公布', $content); } DB::query("update contests set status = 'finished' where id = {$contest['id']}"); };