diff --git a/web/app/controllers/contest_inside.php b/web/app/controllers/contest_inside.php index b1627ec..f97afff 100644 --- a/web/app/controllers/contest_inside.php +++ b/web/app/controllers/contest_inside.php @@ -283,6 +283,56 @@ } else { $reply_question = null; } + } elseif ($cur_tab == 'self_reviews') { + if (hasParticipated(Auth::user(), $contest)) { + $self_reviews_update_form = new UOJForm('self_review_update'); + $self_reviews_update_form->ctrl_enter_submit = true; + + $contest_problems = DB::selectAll("select problem_id from contests_problems where contest_id = {$contest['id']} order by dfn, problem_id"); + for ($i = 0; $i < count($contest_problems); $i++) { + $contest_problems[$i]['problem'] = queryProblemBrief($contest_problems[$i]['problem_id']); + } + + for ($i = 0; $i < count($contest_problems); $i++) { + $content = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = {$contest_problems[$i]['problem_id']} and poster = '{$myUser['username']}'")['content']; + $self_reviews_update_form->addVTextArea('self_review_update__problem_' . chr(ord('A') + $i), '' . chr(ord('A') + $i) . ': ' . $contest_problems[$i]['problem']['title'], $content, + function ($content) { + return ''; + }, + null, + true + ); + } + + $content = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = -1 and poster = '{$myUser['username']}'")['content']; + $self_reviews_update_form->addVTextArea('self_review_update__overall', '比赛总结', $content, + function ($content) { + return ''; + }, + null, + true + ); + + $self_reviews_update_form->handle = function() { + global $contest, $contest_problems, $myUser; + + for ($i = 0; $i < count($contest_problems); $i++) { + if (isset($_POST['self_review_update__problem_' . chr(ord('A') + $i)])) { + $esc_content = DB::escape($_POST['self_review_update__problem_' . chr(ord('A') + $i)]); + $problem_id = $contest_problems[$i]['problem_id']; + + DB::query("replace into contests_reviews (contest_id, problem_id, poster, content) values ({$contest['id']}, $problem_id, '{$myUser['username']}', '$esc_content')"); + } + } + + if (isset($_POST['self_review_update__overall'])){ + $esc_content = DB::escape($_POST['self_review_update__overall']); + DB::query("replace into contests_reviews (contest_id, problem_id, poster, content) values ({$contest['id']}, -1, '{$myUser['username']}', '$esc_content')"); + } + }; + + $self_reviews_update_form->runAtServer(); + } } function echoDashboard() { @@ -508,7 +558,7 @@ EOD;
- - -
-
- - -

此次比赛为OI赛制。

-

注意:比赛时只显示测样例的结果。

- -

此次比赛为IOI赛制。

-

注意:比赛时显示测试所有数据的结果,但无法看到详细信息。

- + +
+
+ + +

此次比赛为OI赛制。

+

注意:比赛时只显示测样例的结果。

+ +

此次比赛为IOI赛制。

+

注意:比赛时显示测试所有数据的结果,但无法看到详细信息。

+ - 管理 + 管理
printHTML(); ?> @@ -543,24 +593,28 @@ EOD;
- - + +
+
+

修改我的赛后总结

+ printHTML(); ?> +
- -
- -
-

比赛资料

+ +
+ +
+

比赛资料

+
+
+ + + +
-
- - - -
-
diff --git a/web/app/libs/uoj-contest-lib.php b/web/app/libs/uoj-contest-lib.php index da691a2..45f166e 100644 --- a/web/app/libs/uoj-contest-lib.php +++ b/web/app/libs/uoj-contest-lib.php @@ -109,12 +109,20 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co } $score[$submission[2]][$submission[3]] = array($submission[4], $penalty, $submission[0]); - - if ($show_reviews) { - $review_result = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = {$contest_data['problems'][$submission[3]]} and poster = '{$person[0]}'"); + } - if ($review_result['content']) { - $score[$submission[2]][$submission[3]][] = $review_result['content']; + if ($show_reviews) { + foreach ($contest_data['people'] as $person) { + foreach ($contest_data['problems'] as $key => $problem) { + $review_result = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = {$problem} and poster = '{$person[0]}'"); + + if (!isset($score[$person[0]][$key])) { + $score[$person[0]][$key] = array(0, 0, 0); + } + + if ($review_result['content']) { + $score[$person[0]][$key][] = $review_result['content']; + } } } } @@ -135,7 +143,7 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co } if ($show_reviews) { - $review_result = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and poster = '{$person[0]}'"); + $review_result = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = -1 and poster = '{$person[0]}'"); if ($review_result['content']) { $cur[] = $review_result['content']; diff --git a/web/app/libs/uoj-form-lib.php b/web/app/libs/uoj-form-lib.php index 76d0391..6d4f515 100644 --- a/web/app/libs/uoj-form-lib.php +++ b/web/app/libs/uoj-form-lib.php @@ -71,12 +71,18 @@ $this->ajax_submit_js = $js; } - public function add($name, $html, $validator_php, $validator_js) { + public function add($name, $html, $validator_php, $validator_js, $no_val = false) { $this->main_html .= $html; - $this->data[] = array( + $data = array( 'name' => $name, 'validator_php' => $validator_php, 'validator_js' => $validator_js); + + if ($no_val) { + $data['no_val'] = ''; + } + + $this->data[] = $data; } public function appendHTML($html) { $this->main_html .= $html; @@ -183,7 +189,7 @@ EOD; ); } - public function addTextArea($name, $label_text, $default_value, $validator_php, $validator_js) { + public function addTextArea($name, $label_text, $default_value, $validator_php, $validator_js, $no_val = false) { $default_value = htmlspecialchars($default_value); $this->is_big = true; $html = <<
EOD; - $this->add($name, $html, $validator_php, $validator_js); + $this->add($name, $html, $validator_php, $validator_js, $no_val); } - public function addVTextArea($name, $label_text, $default_value, $validator_php, $validator_js) { + public function addVTextArea($name, $label_text, $default_value, $validator_php, $validator_js, $no_val = false) { $default_value = htmlspecialchars($default_value); $this->is_big = true; $html = << EOD; - $this->add($name, $html, $validator_php, $validator_js); + $this->add($name, $html, $validator_php, $validator_js, $no_val); } public function addCheckBox($name, $label_text, $default_value) { $default_value = htmlspecialchars($default_value); diff --git a/web/app/libs/uoj-query-lib.php b/web/app/libs/uoj-query-lib.php index 5d357a1..429c7d7 100644 --- a/web/app/libs/uoj-query-lib.php +++ b/web/app/libs/uoj-query-lib.php @@ -41,6 +41,11 @@ function hasRegistered($user, $contest) { function hasAC($user, $problem) { return DB::selectFirst("select * from best_ac_submissions where submitter = '${user['username']}' and problem_id = ${problem['id']}") != null; } +function hasParticipated($user, $contest) { + $result = DB::selectFirst("select * from contests_registrants where username = '${user['username']}' and contest_id = ${contest['id']}"); + + return $result != null && $result['has_participated']; +} function queryUser($username) { if (!validateUsername($username)) { diff --git a/web/js/uoj.js b/web/js/uoj.js index 746074a..99d362c 100644 --- a/web/js/uoj.js +++ b/web/js/uoj.js @@ -1079,25 +1079,31 @@ function showStandings() { col_tr += '' + getUserLink(row[2][0], row[2][1]) + ''; col_tr += '' + '
' + row[0] + '
' + '
' + getPenaltyTimeStr(row[1]) + '
'; for (var i = 0; i < problems.length; i++) { - col_tr += ''; + col_tr += ''; col = score[row[2][0]][i]; if (col != undefined) { - col_tr += '
' + col[0] + '
'; - if (standings_version < 2) { - col_tr += '
' + getPenaltyTimeStr(col[1]) + '
'; - } else { - if (col[0] > 0) { - col_tr += '
' + getPenaltyTimeStr(col[1]) + '
'; - } - } + col_tr += '
'; + + if (col[2]) col_tr += '' + col[0] + ''; + else col_tr += '' + col[0] + ''; + + col_tr += '
'; if (show_self_reviews) { col_tr += '
' + '