Skip to content

Commit

Permalink
Merge pull request #358 from blackav/349-make-finish-the-contest-acti…
Browse files Browse the repository at this point in the history
…on-configurable

349 make finish the contest action configurable
  • Loading branch information
blackav authored Sep 18, 2024
2 parents b133fc0 + a304765 commit a4b0260
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
17 changes: 16 additions & 1 deletion csp/contests/unpriv_main_info.csp
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<%
int enable_user_finish = 0;
if (global->is_virtual > 0) {
enable_user_finish = 1;
} else {
if (duration > 0) {
enable_user_finish = 1;
if (cnts->disable_user_finish > 0) {
enable_user_finish = 0;
}
} else {
if (cnts->enable_user_finish > 0) {
enable_user_finish = 1;
}
}
}
if (!cnts->exam_mode) {
%><div class="h2-long"><h2><s:_>Server status</s:_></h2></div>
<p><b><%
Expand Down Expand Up @@ -267,7 +282,7 @@ $(function() {
%><p><button class="ui-button ui-widget" id="virtual-stop-button"><s:_>Stop virtual contest</s:_></button></p><%
}
%></s:form><%
} else if (!cnts->exam_mode && global->is_virtual <= 0 && start_time > 0 && stop_time <= 0) {
} else if (!cnts->exam_mode && global->is_virtual <= 0 && start_time > 0 && stop_time <= 0 && enable_user_finish > 0) {
%><s:form id="real-stop-form">
<s:hidden name="action" ac="virtual-stop" /><%
if (cnts->exam_mode) {
Expand Down
4 changes: 4 additions & 0 deletions gen/contests_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static struct meta_info_item meta_info_contest_desc_data[] =
[CNTS_disable_standalone_reg] = { CNTS_disable_standalone_reg, 'b', XSIZE(struct contest_desc, disable_standalone_reg), "disable_standalone_reg", XOFFSET(struct contest_desc, disable_standalone_reg) },
[CNTS_enable_telegram_registration] = { CNTS_enable_telegram_registration, 'b', XSIZE(struct contest_desc, enable_telegram_registration), "enable_telegram_registration", XOFFSET(struct contest_desc, enable_telegram_registration) },
[CNTS_enable_special_flow] = { CNTS_enable_special_flow, 'b', XSIZE(struct contest_desc, enable_special_flow), "enable_special_flow", XOFFSET(struct contest_desc, enable_special_flow) },
[CNTS_enable_user_finish] = { CNTS_enable_user_finish, 'b', XSIZE(struct contest_desc, enable_user_finish), "enable_user_finish", XOFFSET(struct contest_desc, enable_user_finish) },
[CNTS_disable_user_finish] = { CNTS_disable_user_finish, 'b', XSIZE(struct contest_desc, disable_user_finish), "disable_user_finish", XOFFSET(struct contest_desc, disable_user_finish) },
[CNTS_reg_deadline] = { CNTS_reg_deadline, 't', XSIZE(struct contest_desc, reg_deadline), "reg_deadline", XOFFSET(struct contest_desc, reg_deadline) },
[CNTS_sched_time] = { CNTS_sched_time, 't', XSIZE(struct contest_desc, sched_time), "sched_time", XOFFSET(struct contest_desc, sched_time) },
[CNTS_open_time] = { CNTS_open_time, 't', XSIZE(struct contest_desc, open_time), "open_time", XOFFSET(struct contest_desc, open_time) },
Expand Down Expand Up @@ -212,6 +214,8 @@ void contest_desc_copy(struct contest_desc *dst, const struct contest_desc *src)
dst->disable_standalone_reg = src->disable_standalone_reg;
dst->enable_telegram_registration = src->enable_telegram_registration;
dst->enable_special_flow = src->enable_special_flow;
dst->enable_user_finish = src->enable_user_finish;
dst->disable_user_finish = src->disable_user_finish;
dst->reg_deadline = src->reg_deadline;
dst->sched_time = src->sched_time;
dst->open_time = src->open_time;
Expand Down
4 changes: 4 additions & 0 deletions include/ejudge/contests.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ enum
CONTEST_A_DISABLE_STANDALONE_REG,
CONTEST_A_ENABLE_TELEGRAM_REGISTRATION,
CONTEST_A_ENABLE_SPECIAL_FLOW,
CONTEST_A_ENABLE_USER_FINISH,
CONTEST_A_DISABLE_USER_FINISH,

CONTEST_LAST_ATTR
};
Expand Down Expand Up @@ -349,6 +351,8 @@ struct contest_desc
ejbytebool_t disable_standalone_reg;
ejbytebool_t enable_telegram_registration;
ejbytebool_t enable_special_flow;
ejbytebool_t enable_user_finish;
ejbytebool_t disable_user_finish;

time_t reg_deadline;
time_t sched_time;
Expand Down
2 changes: 2 additions & 0 deletions include/ejudge/meta/contests_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ enum
CNTS_disable_standalone_reg,
CNTS_enable_telegram_registration,
CNTS_enable_special_flow,
CNTS_enable_user_finish,
CNTS_disable_user_finish,
CNTS_reg_deadline,
CNTS_sched_time,
CNTS_open_time,
Expand Down
6 changes: 6 additions & 0 deletions lib/contests.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ const int contests_attr_to_meta_map[CONTEST_LAST_ATTR] =
[CONTEST_A_DISABLE_STANDALONE_REG] = CNTS_disable_standalone_reg,
[CONTEST_A_ENABLE_TELEGRAM_REGISTRATION] = CNTS_enable_telegram_registration,
[CONTEST_A_ENABLE_SPECIAL_FLOW] = CNTS_enable_special_flow,
[CONTEST_A_ENABLE_USER_FINISH] = CNTS_enable_user_finish,
[CONTEST_A_DISABLE_USER_FINISH] = CNTS_disable_user_finish,
};

char const * const contests_elem_map[] =
Expand Down Expand Up @@ -345,6 +347,8 @@ char const * const contests_attr_map[] =
"disable_standalone_reg",
"enable_telegram_registration",
"enable_special_flow",
"enable_user_finish",
"disable_user_finish",

0
};
Expand Down Expand Up @@ -889,6 +893,8 @@ static const unsigned char contest_bool_attr_set[CONTEST_LAST_ATTR] =
[CONTEST_A_DISABLE_STANDALONE_REG] = 1,
[CONTEST_A_ENABLE_TELEGRAM_REGISTRATION] = 1,
[CONTEST_A_ENABLE_SPECIAL_FLOW] = 1,
[CONTEST_A_ENABLE_USER_FINISH] = 1,
[CONTEST_A_DISABLE_USER_FINISH] = 1,
};

static void
Expand Down
1 change: 1 addition & 0 deletions lib/contests_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ contests_write_header(
CONTEST_A_MANAGED, CONTEST_A_RUN_MANAGED, CONTEST_A_OLD_RUN_MANAGED, CONTEST_A_READY, CONTEST_A_READ_ONLY_NAME,
CONTEST_A_ENABLE_OAUTH, CONTEST_A_ENABLE_REMINDERS,
CONTEST_A_DISABLE_STANDALONE_REG, CONTEST_A_ENABLE_TELEGRAM_REGISTRATION, CONTEST_A_ENABLE_SPECIAL_FLOW,
CONTEST_A_ENABLE_USER_FINISH, CONTEST_A_DISABLE_USER_FINISH,
0
};
for (i = 0; flist[i]; ++i) {
Expand Down

0 comments on commit a4b0260

Please sign in to comment.