Skip to content

Commit

Permalink
Merge pull request #312 from blackav/310-implement-privileged-problem…
Browse files Browse the repository at this point in the history
…-status-json

310 implement privileged problem status json
  • Loading branch information
blackav authored Mar 16, 2024
2 parents 9e34685 + 0128e78 commit 648021c
Show file tree
Hide file tree
Showing 10 changed files with 603 additions and 61 deletions.
2 changes: 1 addition & 1 deletion csp/contests/unpriv_main_page.csp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ns_unparse_answers(

unpriv_load_html_style(phr, cnts, 0, 0);

ns_get_user_problems_summary(cs, phr->user_id, phr->login, accepting_mode, start_time, stop_time, &phr->ip, pinfo);
ns_get_user_problems_summary(cs, phr->user_id, phr->login, accepting_mode, start_time, stop_time, 0, &phr->ip, pinfo);
for (i = 1; i <= cs->max_prob; ++i) {
summoned_count += pinfo[i].summoned_flag;
}
Expand Down
8 changes: 4 additions & 4 deletions csp/contests/unpriv_main_run_submit.csp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<%
if (prob_id > cs->max_prob) prob_id = 0;
if (prob_id > 0 && !(prob = cs->probs[prob_id])) prob_id = 0;
if (prob_id > 0 && !serve_is_problem_started(cs, phr->user_id, prob))
if (prob_id > 0 && !serve_is_problem_started(cs, phr->user_id, prob, 0))
prob_id = 0;
if (prob_id > 0 && prob) {
serve_is_problem_deadlined(cs, phr->user_id, phr->login, prob, &pinfo[prob_id].deadline);
serve_is_problem_deadlined(cs, phr->user_id, phr->login, prob, &pinfo[prob_id].deadline, 0);
}
/*
if (prob_id > 0 && serve_is_problem_deadlined(cs, phr->user_id, phr->login,
prob,
&pinfo[prob_id].deadline))
&pinfo[prob_id].deadline, 0))
prob_id = 0;
*/
//if (prob_id > 0 && prob->disable_user_submit > 0) prob_id = 0;
Expand Down Expand Up @@ -437,7 +437,7 @@
next_prob_id++;
for (; next_prob_id <= cs->max_prob; next_prob_id++) {
if (!(prob2 = cs->probs[next_prob_id])) continue;
if (!serve_is_problem_started(cs, phr->user_id, prob2))
if (!serve_is_problem_started(cs, phr->user_id, prob2, 0))
continue;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions csp/contests/unpriv_main_statements.csp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
variant = 0;
if (prob_id <= 0 || prob_id > cs->max_prob) continue;
if (!(prob = cs->probs[prob_id])) continue;
if (!serve_is_problem_started(cs, phr->user_id, prob)) continue;
if (!serve_is_problem_started(cs, phr->user_id, prob, 0)) continue;
if (serve_is_problem_deadlined(cs, phr->user_id, phr->login,
prob, &pinfo[prob_id].deadline))
prob, &pinfo[prob_id].deadline, 0))
continue;
if (prob->variant_num > 0
&& (variant = find_variant(cs, phr->user_id, prob_id, 0)) <= 0)
Expand Down
2 changes: 1 addition & 1 deletion csp/contests/unpriv_main_summary.csp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<%
for (prob_id = 1; prob_id <= cs->max_prob; prob_id++) {
if (!(prob = cs->probs[prob_id])) continue;
if (!serve_is_problem_started(cs, phr->user_id, prob)) continue;
if (!serve_is_problem_started(cs, phr->user_id, prob, 0)) continue;
if (prob->hidden > 0) continue;

const unsigned char *s = "";
Expand Down
1 change: 1 addition & 0 deletions include/ejudge/new-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ ns_get_user_problems_summary(
int accepting_mode,
time_t start_time,
time_t stop_time,
time_t point_in_time,
const ej_ip_t *ip,
struct UserProblemInfo *pinfo); /* user problem info */

Expand Down
8 changes: 5 additions & 3 deletions include/ejudge/serve_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef __SERVE_STATE_H__
#define __SERVE_STATE_H__

/* Copyright (C) 2006-2023 Alexander Chernov <[email protected]> */
/* Copyright (C) 2006-2024 Alexander Chernov <[email protected]> */

/*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -899,14 +899,16 @@ int
serve_is_problem_started(
const serve_state_t state,
int user_id,
const struct section_problem_data *prob);
const struct section_problem_data *prob,
time_t point_in_time);
int
serve_is_problem_deadlined(
const serve_state_t state,
int user_id,
const unsigned char *user_login,
const struct section_problem_data *prob,
time_t *p_deadline);
time_t *p_deadline,
time_t point_in_time);
int
serve_is_problem_started_2(
const serve_state_t state,
Expand Down
Loading

0 comments on commit 648021c

Please sign in to comment.