mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 14:28:42 +00:00
feat(web/contest/self_reviews): markdown support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
60ba1a5829
commit
0d0b8b0ba7
@ -563,6 +563,7 @@ EOD;
|
|||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h4>修改我的赛后总结</h4>
|
<h4>修改我的赛后总结</h4>
|
||||||
|
<div class="small">赛后总结支持 Markdown 语法。</div>
|
||||||
<?php $self_reviews_update_form->printHTML(); ?>
|
<?php $self_reviews_update_form->printHTML(); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -41,7 +41,10 @@ $col_names = array('contest_id');
|
|||||||
$header_row .= '<th style="width: 35em;">'.UOJLocale::get('contests::contest self review').'</th>';
|
$header_row .= '<th style="width: 35em;">'.UOJLocale::get('contests::contest self review').'</th>';
|
||||||
$header_row .= '</tr>';
|
$header_row .= '</tr>';
|
||||||
|
|
||||||
$print_row = function($row) {
|
$parsedown = HTML::parsedown();
|
||||||
|
$purifier = HTML::purifier_inline();
|
||||||
|
|
||||||
|
$print_row = function($row) use ($parsedown, $purifier) {
|
||||||
global $username;
|
global $username;
|
||||||
|
|
||||||
$contest_id = $row['contest_id'];
|
$contest_id = $row['contest_id'];
|
||||||
@ -49,9 +52,6 @@ $col_names = array('contest_id');
|
|||||||
$contest_problems = queryContestProblems($contest_id);
|
$contest_problems = queryContestProblems($contest_id);
|
||||||
$n_contest_problems = count($contest_problems);
|
$n_contest_problems = count($contest_problems);
|
||||||
|
|
||||||
$result = '';
|
|
||||||
$purifier = HTML::purifier_inline();
|
|
||||||
|
|
||||||
for ($i = 0; $i < $n_contest_problems; $i++) {
|
for ($i = 0; $i < $n_contest_problems; $i++) {
|
||||||
$problem_id = $contest_problems[$i]['problem_id'];
|
$problem_id = $contest_problems[$i]['problem_id'];
|
||||||
$problem = queryProblemBrief($problem_id);
|
$problem = queryProblemBrief($problem_id);
|
||||||
@ -65,12 +65,12 @@ $col_names = array('contest_id');
|
|||||||
|
|
||||||
$problem_review_id = "review-$contest_id-$i";
|
$problem_review_id = "review-$contest_id-$i";
|
||||||
$result .= '<td>' . chr(ord('A') + $i) . '. <a href="/problem/' . $problem_id . '">' . $problem['title'] . '</a></td>';
|
$result .= '<td>' . chr(ord('A') + $i) . '. <a href="/problem/' . $problem_id . '">' . $problem['title'] . '</a></td>';
|
||||||
$result .= '<td>' . $purifier->purify($problem_self_review != null ? $problem_self_review['content'] : '') . '</td>';
|
$result .= '<td>' . $purifier->purify($problem_self_review != null ? $parsedown->line($problem_self_review['content']) : '') . '</td>';
|
||||||
|
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
$contest_review_id = "review-$contest_id-overall";
|
$contest_review_id = "review-$contest_id-overall";
|
||||||
$contest_self_review = DB::selectFirst("select content from contests_reviews where contest_id = $contest_id and problem_id = -1 and poster = '$username'");
|
$contest_self_review = DB::selectFirst("select content from contests_reviews where contest_id = $contest_id and problem_id = -1 and poster = '$username'");
|
||||||
$result .= '<td rowspan="' . $n_contest_problems . '">' . $purifier->purify($contest_self_review != null ? $contest_self_review['content'] : '') . '</td>';
|
$result .= '<td rowspan="' . $n_contest_problems . '">' . $purifier->purify($contest_self_review != null ? $parsedown->line($contest_self_review['content']) : '') . '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= '</tr>';
|
$result .= '</tr>';
|
||||||
|
@ -112,7 +112,9 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($show_reviews) {
|
if ($show_reviews) {
|
||||||
|
$parsedown = HTML::parsedown();
|
||||||
$purifier = HTML::purifier_inline();
|
$purifier = HTML::purifier_inline();
|
||||||
|
|
||||||
foreach ($contest_data['people'] as $person) {
|
foreach ($contest_data['people'] as $person) {
|
||||||
foreach ($contest_data['problems'] as $key => $problem) {
|
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]}'");
|
$review_result = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = {$problem} and poster = '{$person[0]}'");
|
||||||
@ -122,7 +124,7 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($review_result['content']) {
|
if ($review_result['content']) {
|
||||||
$score[$person[0]][$key][] = $purifier->purify($review_result['content']);
|
$score[$person[0]][$key][] = $purifier->purify($parsedown->line($review_result['content']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +149,7 @@ function calcStandings($contest, $contest_data, &$score, &$standings, $update_co
|
|||||||
$review_result = DB::selectFirst("select content from contests_reviews where contest_id = {$contest['id']} and problem_id = -1 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']) {
|
if ($review_result['content']) {
|
||||||
$cur[] = $purifier->purify($review_result['content']);
|
$cur[] = $purifier->purify($parsedown->line($review_result['content']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user