Skip to content

Commit 25f4d10

Browse files
committed
support rendering of markdown statements
1 parent 337e545 commit 25f4d10

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

csp/contests/priv_submit_page.csp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ns_unparse_answers(
4343
path_t variant_stmt_file;
4444
unsigned char title[1024];
4545
int enable_main_menu = 0;
46+
struct md_content *pmd = NULL;
4647

4748
if (cs) global = cs->global;
4849

@@ -238,11 +239,22 @@ ns_unparse_answers(
238239

239240
<%
240241
/* output the problem statement */
242+
pmd = NULL;
243+
if (prob && prob->variant_num > 0 && variant > 0 && prob->md_size > 0 && variant <= prob->md_size) {
244+
pmd = &prob->md_files[variant-1];
245+
} else if (prob && prob->variant_num <= 0 && prob->md_size == 1) {
246+
pmd = &prob->md_files[0];
247+
}
248+
if (pmd && pmd->data) {
249+
putc_unlocked('\n', out_f);
250+
fwrite_unlocked(pmd->data, 1, pmd->size, out_f);
251+
putc_unlocked('\n', out_f);
252+
}
241253
px = 0; pw = 0; pw_path = 0;
242-
if (prob && prob->variant_num > 0 && variant > 0 && prob->xml.a
254+
if (!pmd && prob && prob->variant_num > 0 && variant > 0 && prob->xml.a
243255
&& prob->xml.a[variant - 1]) {
244256
px = prob->xml.a[variant - 1];
245-
} else if (prob && prob->variant_num <= 0 && prob->xml.p) {
257+
} else if (!pmd && prob && prob->variant_num <= 0 && prob->xml.p) {
246258
px = prob->xml.p;
247259
}
248260
if (px && px->stmts) {

csp/contests/unpriv_main_page.csp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ns_unparse_answers(
6969
avatar_url[0] = 0;
7070
struct virtual_end_info_s *vend_info = NULL;
7171
int summoned_count = 0;
72+
struct md_content *pmd = NULL;
7273

7374
%><s:read var="telegram_token" ignoreerrors="yes" /><%
7475
%><s:read var="all_runs" ignoreerrors="yes" default="0" /><%

csp/contests/unpriv_main_run_submit.csp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@
236236

237237
<%
238238
px = 0;
239+
pmd = NULL;
240+
if (prob->variant_num > 0 && variant > 0 && prob->md_size > 0 && variant <= prob->md_size) {
241+
pmd = &prob->md_files[variant - 1];
242+
} else if (prob->variant_num <= 0 && variant <= 0 && prob->md_size == 1) {
243+
pmd = &prob->md_files[0];
244+
}
239245
if (variant > 0 && prob->xml.a && prob->xml.a[variant - 1]) {
240246
px = prob->xml.a[variant - 1];
241247
} else if (variant <= 0 && prob->xml.p) {
@@ -244,7 +250,11 @@
244250

245251
/* put problem statement */
246252
if (is_viewable) {
247-
if (px && px->stmts) {
253+
if (pmd && pmd->data) {
254+
putc_unlocked('\n', out_f);
255+
fwrite_unlocked(pmd->data, 1, pmd->size, out_f);
256+
putc_unlocked('\n', out_f);
257+
} else if (px && px->stmts) {
248258
ns_unparse_statement(out_f, phr, cnts, extra, prob, 0, px, NULL,
249259
pinfo[prob_id].status & PROB_STATUS_SUBMITTABLE);
250260
} else if (prob->statement_file && prob->statement_file[0] && is_viewable) {

0 commit comments

Comments
 (0)