Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions csp/contests/unpriv_main_page.csp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ ns_unparse_statement(
const unsigned char *bb,
int is_submittable);

int
compare_prob_with_start_date_name(const int * l, const int * r, const struct section_problem_data **probs) {
if (probs[*l]->start_date > probs[*r]->start_date) {
return -1;
}
if (probs[*l]->start_date < probs[*r]->start_date) {
return 1;
}
// qsort is unstable that why use id as stabilization
return *l - *r;
}

void
ns_unparse_answers(
FILE *fout,
Expand Down Expand Up @@ -278,11 +290,22 @@ ns_unparse_answers(
// vertical navigation bar
%></div></td><td class="b0" id="probNavRightList" valign="top"><%
prev_group_name[0] = 0;

for (i = 1, j = 0; i <= cs->max_prob; i++) {
int probs = 0;
int indexes[cs->max_prob];
for (i = 1; i <= cs->max_prob; i++) {
if (!(prob = cs->probs[i])) continue;
if (!(pinfo[i].status & PROB_STATUS_TABABLE)) continue;
indexes[probs] = i;
++probs;
}
if (global->vertical_navigation_sdate_sort > 0) {
qsort_r(indexes, probs, sizeof(indexes[0]), compare_prob_with_start_date_name, cs->probs);
}

for (j = 0; j < probs; ++j) {
i = indexes[j];
if (!(prob = cs->probs[i])) continue;
if (!(pinfo[i].status & PROB_STATUS_TABABLE)) continue;
if (prob->group_name && strcmp(prob->group_name, prev_group_name)) {
%><div class="probDisabled"><s:v value="prob->group_name" escape="false" /></div><%
snprintf(prev_group_name, sizeof(prev_group_name), "%s", prob->group_name);
Expand All @@ -303,7 +326,6 @@ ns_unparse_answers(
}
%><s:url name="ProblemUrl" ac="view-problem-submit"><s:param name="prob_id" value="i" /></s:url><%
%><s:a class="tab" url="ProblemUrl"><s:v value="prob->short_name" escape="false" /></s:a></div><%
j++;
}
%></td></tr></table>
<%
Expand Down
5 changes: 5 additions & 0 deletions csp/super-server/cnts_edit_cur_global_page.csp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static const unsigned char MSG_disable_user_standings[] = "Disable build-in stan
static const unsigned char MSG_disable_language[] = "Disable language column in new-client";
static const unsigned char MSG_problem_navigation[] = "Advanced problem navigation";
static const unsigned char MSG_vertical_navigation[] = "Place problem navigation vertically";
static const unsigned char MSG_vertical_navigation_sdate_sort[] = "Sort problem navigation vertically with problem start_date descending";
static const unsigned char MSG_disable_virtual_start[] = "Disable user Virtual start button";
static const unsigned char MSG_disable_virtual_auto_judge[] = "Disable auto-judging after virtual olympiad";
static const unsigned char MSG_enable_auto_print_protocol[] = "Enable automatic protocol printing";
Expand Down Expand Up @@ -328,6 +329,7 @@ static const unsigned char * const form_row_attrs[]=
<%@expand EDIT_BOOL_ROW "disable_language" "caps" "400px" %>
<%@expand EDIT_BOOL_ROW "problem_navigation" "caps" "400px" %>
<%@expand EDIT_BOOL_ROW "vertical_navigation" "caps" "400px" %>
<%@expand EDIT_BOOL_ROW "vertical_navigation_sdate_sort" "caps" "400px" %>
<%@expand EDIT_BOOL_ROW "disable_virtual_start" "caps" "400px" %>
<%@expand EDIT_BOOL_ROW "disable_virtual_auto_judge" "caps" "400px" %>
<%@expand EDIT_BOOL_ROW "enable_auto_print_protocol" "caps" "400px" %>
Expand Down Expand Up @@ -896,6 +898,7 @@ function popupCapsDialog(e, skipField)
"disable_language",
"problem_navigation",
"vertical_navigation",
"vertical_navigation_sdate_sort",
"disable_virtual_start",
"disable_virtual_auto_judge",
"enable_auto_print_protocol",
Expand Down Expand Up @@ -926,6 +929,7 @@ function capsDialogOnChange()
$("#caps-disable_banner_page-div").toggle($("#caps-enable_printing").is(':checked'));
$("#caps-printout_uses_login-div").toggle($("#caps-enable_printing").is(':checked') && $("#caps-disable_banner_page").is(':checked'));
$("#caps-vertical_navigation-div").toggle($("#caps-problem_navigation").is(':checked'));
$("#caps-vertical_navigation_sdate_sort-div").toggle($("#caps-problem_navigation").is(':checked'));
$("#caps-disable_virtual_start-div").toggle(<s:v type="jsbool" value="global->is_virtual > 0" />);
$("#caps-disable_virtual_auto_judge-div").toggle(<s:v type="jsbool" value="global->score_system == SCORE_OLYMPIAD" />);
$("#caps-enable_auto_print_protocol-div").toggle(<s:v type="jsbool" value="global->score_system == SCORE_OLYMPIAD" />);
Expand Down Expand Up @@ -1438,6 +1442,7 @@ function advancedDialogOnChange()
<%@expand ORIG_BOOL_ROW "disable_language" %>
<%@expand ORIG_BOOL_ROW "problem_navigation" %>
<%@expand ORIG_BOOL_ROW "vertical_navigation" %>
<%@expand ORIG_BOOL_ROW "vertical_navigation_sdate_sort" %>
<%@expand ORIG_BOOL_ROW "disable_virtual_start" %>
<%@expand ORIG_BOOL_ROW "disable_virtual_auto_judge" %>
<%@expand ORIG_BOOL_ROW "enable_auto_print_protocol" %>
Expand Down
3 changes: 3 additions & 0 deletions csp/super-server/glob_save_capabilities_form.csp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ejintbool_t disable_language = 0;
ejintbool_t problem_navigation = 0;
ejintbool_t vertical_navigation = 0;
ejintbool_t vertical_navigation_sdate_sort = 0;
ejintbool_t disable_virtual_start = 0;
ejintbool_t disable_virtual_auto_judge = 0;
ejintbool_t enable_auto_print_protocol = 0;
Expand Down Expand Up @@ -72,6 +73,7 @@
%><s:read var="disable_language" default="0" /><%
%><s:read var="problem_navigation" default="0" /><%
%><s:read var="vertical_navigation" default="0" /><%
%><s:read var="vertical_navigation_sdate_sort" default="0" /><%
%><s:read var="disable_virtual_start" default="0" /><%
%><s:read var="disable_virtual_auto_judge" default="0" /><%
%><s:read var="enable_auto_print_protocol" default="0" /><%
Expand Down Expand Up @@ -109,6 +111,7 @@
global->disable_language = disable_language;
global->problem_navigation = problem_navigation;
global->vertical_navigation = vertical_navigation;
global->vertical_navigation_sdate_sort = vertical_navigation_sdate_sort;
global->disable_virtual_start = disable_virtual_start;
global->disable_virtual_auto_judge = disable_virtual_auto_judge;
global->enable_auto_print_protocol = enable_auto_print_protocol;
Expand Down
1 change: 1 addition & 0 deletions gen/prepare_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static struct meta_info_item meta_info_section_global_data_data[] =
[CNTSGLOB_problem_navigation] = { CNTSGLOB_problem_navigation, 'B', XSIZE(struct section_global_data, problem_navigation), "problem_navigation", XOFFSET(struct section_global_data, problem_navigation) },
[CNTSGLOB_problem_tab_size] = { CNTSGLOB_problem_tab_size, 'i', XSIZE(struct section_global_data, problem_tab_size), "problem_tab_size", XOFFSET(struct section_global_data, problem_tab_size) },
[CNTSGLOB_vertical_navigation] = { CNTSGLOB_vertical_navigation, 'B', XSIZE(struct section_global_data, vertical_navigation), "vertical_navigation", XOFFSET(struct section_global_data, vertical_navigation) },
[CNTSGLOB_vertical_navigation_sdate_sort] = { CNTSGLOB_vertical_navigation_sdate_sort, 'B', XSIZE(struct section_global_data, vertical_navigation_sdate_sort), "vertical_navigation_sdate_sort", XOFFSET(struct section_global_data, vertical_navigation_sdate_sort) },
[CNTSGLOB_disable_virtual_start] = { CNTSGLOB_disable_virtual_start, 'B', XSIZE(struct section_global_data, disable_virtual_start), "disable_virtual_start", XOFFSET(struct section_global_data, disable_virtual_start) },
[CNTSGLOB_disable_virtual_auto_judge] = { CNTSGLOB_disable_virtual_auto_judge, 'B', XSIZE(struct section_global_data, disable_virtual_auto_judge), "disable_virtual_auto_judge", XOFFSET(struct section_global_data, disable_virtual_auto_judge) },
[CNTSGLOB_enable_auto_print_protocol] = { CNTSGLOB_enable_auto_print_protocol, 'B', XSIZE(struct section_global_data, enable_auto_print_protocol), "enable_auto_print_protocol", XOFFSET(struct section_global_data, enable_auto_print_protocol) },
Expand Down
1 change: 1 addition & 0 deletions include/ejudge/meta/prepare_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum
CNTSGLOB_problem_navigation,
CNTSGLOB_problem_tab_size,
CNTSGLOB_vertical_navigation,
CNTSGLOB_vertical_navigation_sdate_sort,
CNTSGLOB_disable_virtual_start,
CNTSGLOB_disable_virtual_auto_judge,
CNTSGLOB_enable_auto_print_protocol,
Expand Down
2 changes: 2 additions & 0 deletions include/ejudge/prepare.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ struct section_global_data
int problem_tab_size;
/** display problem tabs vertically */
ejintbool_t vertical_navigation;
/** use start_date sort order instead of problem id */
ejintbool_t vertical_navigation_sdate_sort;
/** disable "virtual start" command for contestants */
ejintbool_t disable_virtual_start;
/** disable auto-judging after virtual olympiad is finished for a user */
Expand Down
1 change: 1 addition & 0 deletions include/ejudge/prepare_dflt.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#define DFLT_G_DISABLE_LANGUAGE 0
#define DFLT_G_PROBLEM_NAVIGATION 0
#define DFLT_G_VERTICAL_NAVIGATION 0
#define DFLT_G_VERTICAL_NAVIGATION_SDATE_SORT 0
#define DFLT_G_DISABLE_VIRTUAL_START 0
#define DFLT_G_DISABLE_VIRTUAL_AUTO_JUDGE 0
#define DFLT_G_ENABLE_AUTO_PRINT_PROTOCOL 0
Expand Down
6 changes: 6 additions & 0 deletions lib/prepare.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static const struct config_parse_info section_global_params[] =
GLOBAL_PARAM(problem_navigation, "d"),
GLOBAL_PARAM(problem_tab_size, "d"),
GLOBAL_PARAM(vertical_navigation, "d"),
GLOBAL_PARAM(vertical_navigation_sdate_sort, "d"),
GLOBAL_PARAM(disable_virtual_start, "d"),
GLOBAL_PARAM(disable_virtual_auto_judge, "d"),
GLOBAL_PARAM(enable_auto_print_protocol, "d"),
Expand Down Expand Up @@ -884,6 +885,7 @@ global_init_func(struct generic_section_config *gp)
p->disable_language = -1;
p->problem_navigation = -1;
p->vertical_navigation = -1;
p->vertical_navigation_sdate_sort = -1;
p->disable_virtual_start = -1;
p->disable_virtual_auto_judge = -1;
p->enable_auto_print_protocol = -1;
Expand Down Expand Up @@ -2826,6 +2828,8 @@ set_defaults(
g->problem_navigation = DFLT_G_PROBLEM_NAVIGATION;
if (g->vertical_navigation == -1)
g->vertical_navigation = DFLT_G_VERTICAL_NAVIGATION;
if (g->vertical_navigation_sdate_sort == -1)
g->vertical_navigation_sdate_sort = DFLT_G_VERTICAL_NAVIGATION_SDATE_SORT;
if (g->disable_virtual_start == -1)
g->disable_virtual_start = DFLT_G_DISABLE_VIRTUAL_START;
if (g->disable_virtual_auto_judge == -1)
Expand Down Expand Up @@ -5474,6 +5478,7 @@ prepare_set_global_defaults(
if (g->disable_language < 0) g->disable_language = DFLT_G_DISABLE_LANGUAGE;
if (g->problem_navigation < 0) g->problem_navigation = DFLT_G_PROBLEM_NAVIGATION;
if (g->vertical_navigation < 0) g->vertical_navigation = DFLT_G_VERTICAL_NAVIGATION;
if (g->vertical_navigation_sdate_sort < 0) g->vertical_navigation_sdate_sort = DFLT_G_VERTICAL_NAVIGATION_SDATE_SORT;
if (g->disable_virtual_start < 0) g->disable_virtual_start = DFLT_G_DISABLE_VIRTUAL_START;
if (g->disable_virtual_auto_judge < 0) g->disable_virtual_auto_judge = DFLT_G_DISABLE_VIRTUAL_AUTO_JUDGE;
if (g->enable_auto_print_protocol < 0) g->enable_auto_print_protocol = DFLT_G_ENABLE_AUTO_PRINT_PROTOCOL;
Expand Down Expand Up @@ -5758,6 +5763,7 @@ prepare_new_global_section(int contest_id, const unsigned char *root_dir,
global->disable_language = DFLT_G_DISABLE_LANGUAGE;
global->problem_navigation = 1;
global->vertical_navigation = DFLT_G_VERTICAL_NAVIGATION;
global->vertical_navigation_sdate_sort = DFLT_G_VERTICAL_NAVIGATION_SDATE_SORT;
global->disable_virtual_start = DFLT_G_DISABLE_VIRTUAL_START;
global->disable_virtual_auto_judge = DFLT_G_DISABLE_VIRTUAL_AUTO_JUDGE;
global->enable_auto_print_protocol = DFLT_G_ENABLE_AUTO_PRINT_PROTOCOL;
Expand Down
2 changes: 2 additions & 0 deletions lib/prepare_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ prepare_unparse_global(
unparse_bool(f, "problem_navigation", global->problem_navigation);
if (global->vertical_navigation != DFLT_G_VERTICAL_NAVIGATION)
unparse_bool(f, "vertical_navigation", global->vertical_navigation);
if (global->vertical_navigation_sdate_sort != DFLT_G_VERTICAL_NAVIGATION_SDATE_SORT)
unparse_bool(f, "vertical_navigation_sdate_sort", global->vertical_navigation_sdate_sort);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ограничение на размер имени параметра - 32 символа.

vertical_navigation_sdate_sort - ровно 31.

if (global->disable_virtual_start != DFLT_G_DISABLE_VIRTUAL_START)
unparse_bool(f, "disable_virtual_start", global->disable_virtual_start);
if (global->disable_virtual_auto_judge != DFLT_G_DISABLE_VIRTUAL_AUTO_JUDGE)
Expand Down