Ограничение на количество попыток для задачи

Обсуждение вопросов, связанных с системой проведения турниров ejudge.
Post Reply
hotsnr
Posts:67
Joined:19 October 2012, 22:14
Ограничение на количество попыток для задачи

Post by hotsnr » 02 February 2013, 20:55

У задач есть опция Max submissions for the problem
Тем не менее система не ограничивает кол-во попыток.
Может я что то не так делаю?

Code: Select all

# -*- coding: utf-8 -*-
# $Id$
# Generated by ejudge-setup, version 2.3.26
# Generation date: 2013/02/01 23:33:16
contest_id = 1

contest_time = 300
score_system = acm
standings_locale = "ru"

compile_dir = "../../compile/var/compile"

problem_navigation


compile_max_vm_size = 512M
compile_max_file_size = 32M


stand_fancy_style

cr_serialization_key = 22723
advanced_layout
enable_l10n
team_download_time = 0

[language]
id = 1
short_name = "fpc"
long_name = "Free Pascal 2.6.0-7"
src_sfx = ".pas"

[language]
id = 2
short_name = "gcc"
long_name = "GNU C 4.6.3"
src_sfx = ".c"

[language]
id = 3
short_name = "g++"
long_name = "GNU C++ 4.6.3"
src_sfx = ".cpp"

[language]
id = 13
short_name = "python"
long_name = "Python 2.7.3"
arch = "linux-shared"
src_sfx = ".py"

[language]
id = 14
short_name = "perl"
long_name = "Perl 5.14.2"
arch = "linux-shared"
src_sfx = ".pl"

[language]
id = 18
short_name = "javac"
long_name = "Java JDK 1.6.0_24"
arch = "java"
src_sfx = ".java"
exe_sfx = ".jar"

[language]
id = 21
short_name = "ruby"
long_name = "Ruby 1.9.3p194"
arch = "linux-shared"
src_sfx = ".rb"

[language]
id = 22
short_name = "php"
long_name = "PHP 5.4.4-12"
arch = "linux-shared"
src_sfx = ".php"

[language]
id = 25
short_name = "make"
long_name = "Make 3.81"
arch = "linux-shared"
src_sfx = ".tar"

[language]
id = 51
short_name = "clang"
long_name = "clang C version"
arch = "linux-shared"
src_sfx = ".c"

[language]
id = 52
short_name = "clang++"
long_name = "clang C++ version"
arch = "linux-shared"
src_sfx = ".cpp"

[language]
id = 54
short_name = "make-vg"
long_name = "Make (valgrind) 3.81"
arch = "valgrind"
src_sfx = ".tar"

[problem]
abstract
short_name = "Generic"
use_stdin
use_stdout
xml_file = "statement.xml"
test_sfx = ".dat"
use_corr
corr_dir = "%Ps"
corr_sfx = ".ans"
time_limit = 1
real_time_limit = 5
max_vm_size = 64M
max_stack_size = 64M
max_file_size = 64M
check_cmd = "check"
max_user_run_count = 5

[problem]
id = 1
super = "Generic"
short_name = "A"
long_name = "Sum 1"
standard_checker = "cmp_int"

[problem]
id = 2
super = "Generic"
short_name = "B"
long_name = "Sum 2"
standard_checker = "cmp_int"

[tester]
name = Generic
arch = ""
abstract
no_core_dump
enable_memory_limit_error
kill_signal = KILL
memory_limit_type = "default"
secure_exec_type = "static"
clear_env
check_dir = "/home/ejudge/testing_dir"

[tester]
name = Linux-shared
arch = "linux-shared"
abstract
no_core_dump
enable_memory_limit_error
kill_signal = KILL
memory_limit_type = "default"
secure_exec_type = "dll"
clear_env
check_dir = "/home/ejudge/testing_dir"

[tester]
name = Linux-java
arch = "java"
abstract
no_core_dump
kill_signal = TERM
memory_limit_type = "java"
secure_exec_type = "java"
start_cmd = "runjava"
start_env = "LANG=C"
start_env = "EJUDGE_PREFIX_DIR"
check_dir = "/home/ejudge/testing_dir"

[tester]
name = Valgrind
arch = "valgrind"
abstract
no_core_dump
kill_signal = TERM
memory_limit_type = "valgrind"
secure_exec_type = "valgrind"
start_cmd = "runvg"
clear_env
start_env = "PATH=/usr/local/bin:/usr/bin:/bin"
start_env = "LANG=C"
start_env = "HOME"
check_dir = "/home/ejudge/testing_dir"

[tester]
any
super = Generic

[tester]
any
super = Linux-shared
arch = linux-shared

[tester]
any
super = Linux-java
arch = java

[tester]
any
super = Valgrind
arch = valgrind

# audit: edited 2013/02/01 23:47:57 1 (admin) 127.0.0.1
# audit: edited 2013/02/02 23:45:39 1 (admin) 127.0.0.1

cher
Posts:1153
Joined:13 March 2004, 17:00
Contact:

Re: Ограничение на количество попыток для задачи

Post by cher » 02 February 2013, 22:53

В текущей версии не реализовано

hotsnr
Posts:67
Joined:19 October 2012, 22:14

Re: Ограничение на количество попыток для задачи

Post by hotsnr » 02 February 2013, 23:15

Это будет реализовано в ближайших версиях или нет?
Если нет, то я лучше сам допишу.

cher
Posts:1153
Joined:13 March 2004, 17:00
Contact:

Re: Ограничение на количество попыток для задачи

Post by cher » 04 February 2013, 19:10

Реализация обсуждалась здесь на форуме. Даже был патч, но использующий другой конфигурационный параметр.
Если вы сделаете с использованием правильного конфигурационного параметра, то разместите патч, чтобы интегрировать в основную версию.

hotsnr
Posts:67
Joined:19 October 2012, 22:14

Re: Ограничение на количество попыток для задачи

Post by hotsnr » 04 February 2013, 20:05

Дело в том, что тот патч писал я. Он работает не очень и под старую версию. Ладно, напишу и выложу.

hotsnr
Posts:67
Joined:19 October 2012, 22:14

Re: Ограничение на количество попыток для задачи

Post by hotsnr » 06 February 2013, 13:16

И я обнаружил странность: если установить макс. кол-во посылок (max_run_num) в x, то только посылка x+2 отклонится. Это на чистой версии 2.3.26.

hotsnr
Posts:67
Joined:19 October 2012, 22:14

Re: Ограничение на количество попыток для задачи

Post by hotsnr » 12 February 2013, 14:26

Так что это за неточность такая?

cher
Posts:1153
Joined:13 March 2004, 17:00
Contact:

Re: Ограничение на количество попыток для задачи

Post by cher » 13 February 2013, 07:34

Ошибка. Будет исправлена в следующей версии.

hotsnr
Posts:67
Joined:19 October 2012, 22:14

Re: Ограничение на количество попыток для задачи

Post by hotsnr » 06 March 2013, 13:17

Вот новый патч:

Code: Select all

diff -cr ejudge/new_server_html_4.c ejudge-new/new_server_html_4.c
*** ejudge/new_server_html_4.c    2013-02-13 09:06:04.000000000 +0400
--- ejudge-new/new_server_html_4.c	2013-03-06 14:50:59.227602834 +0400
***************
*** 964,970 ****
        FAIL(NEW_SRV_ERR_CONTEST_NOT_STARTED);
      if (stop_time)
        FAIL(NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
!     if (serve_check_user_quota(cs, phr->user_id, run_size) < 0)
        FAIL(NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
      if (!serve_is_problem_started(cs, phr->user_id, prob))
        FAIL(NEW_SRV_ERR_PROB_UNAVAILABLE);
--- 964,970 ----
        FAIL(NEW_SRV_ERR_CONTEST_NOT_STARTED);
      if (stop_time)
        FAIL(NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
!     if (serve_check_user_quota(cs, prob, phr->user_id, run_size) < 0)
        FAIL(NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
      if (!serve_is_problem_started(cs, phr->user_id, prob))
        FAIL(NEW_SRV_ERR_PROB_UNAVAILABLE);
diff -cr ejudge/new_server_html.c ejudge-new/new_server_html.c
*** ejudge/new_server_html.c	2013-02-13 09:06:04.000000000 +0400
--- ejudge-new/new_server_html.c	2013-03-06 14:50:59.230602834 +0400
***************
*** 10626,10632 ****
    if (!admin_mode && stop_time > 0) {
      FAIL(NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
    }
!   if (!admin_mode && serve_check_user_quota(cs, user_id, run_size) < 0) {
      FAIL(NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
    }
    if (!admin_mode && !serve_is_problem_started(cs, user_id, prob)) {
--- 10626,10632 ----
    if (!admin_mode && stop_time > 0) {
      FAIL(NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
    }
!   if (!admin_mode && serve_check_user_quota(cs, prob, user_id, run_size) < 0) {
      FAIL(NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
    }
    if (!admin_mode && !serve_is_problem_started(cs, user_id, prob)) {
***************
*** 11251,11257 ****
      ns_error(log_f, NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
      goto done;
    }
!   if (serve_check_user_quota(cs, phr->user_id, run_size) < 0) {
      ns_error(log_f, NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
      goto done;
    }
--- 11251,11257 ----
      ns_error(log_f, NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
      goto done;
    }
!   if (serve_check_user_quota(cs, prob, phr->user_id, run_size) < 0) {
      ns_error(log_f, NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
      goto done;
    }
***************
*** 14775,14781 ****
    if (cs->clients_suspended) FAIL(NEW_SRV_ERR_CLIENTS_SUSPENDED);
    if (!start_time) FAIL(NEW_SRV_ERR_CONTEST_NOT_STARTED);
    if (stop_time) FAIL(NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
!   if (serve_check_user_quota(cs, phr->user_id, run_size) < 0)
      FAIL(NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
    // problem submit start time
    if (!serve_is_problem_started(cs, phr->user_id, prob))
--- 14775,14781 ----
    if (cs->clients_suspended) FAIL(NEW_SRV_ERR_CLIENTS_SUSPENDED);
    if (!start_time) FAIL(NEW_SRV_ERR_CONTEST_NOT_STARTED);
    if (stop_time) FAIL(NEW_SRV_ERR_CONTEST_ALREADY_FINISHED);
!   if (serve_check_user_quota(cs, prob, phr->user_id, run_size) < 0)
      FAIL(NEW_SRV_ERR_RUN_QUOTA_EXCEEDED);
    // problem submit start time
    if (!serve_is_problem_started(cs, phr->user_id, prob))
diff -cr ejudge/prepare.c ejudge-new/prepare.c
*** ejudge/prepare.c	2013-02-13 09:06:05.000000000 +0400
--- ejudge-new/prepare.c	2013-03-06 15:18:27.697099053 +0400
***************
*** 5869,5876 ****
    case CNTSPROB_max_user_run_count:
      if (out->max_user_run_count < 0 && abstr)
        out->max_user_run_count = abstr->max_user_run_count;
-     if (out->max_user_run_count < 0)
-       out->max_user_run_count = 0;
      break;
  
    case CNTSPROB_full_score:
--- 5869,5874 ----
***************
*** 7104,7110 ****
    .stand_hide_time = 0,
    .score_multiplier = 0,
    .prev_runs_to_show = 0,
!   .max_user_run_count = 0,
    .advance_to_next = 0,
    .disable_ctrl_chars = 0,
    .valuer_sets_marked = 0,
--- 7102,7108 ----
    .stand_hide_time = 0,
    .score_multiplier = 0,
    .prev_runs_to_show = 0,
!   .max_user_run_count = -1,
    .advance_to_next = 0,
    .disable_ctrl_chars = 0,
    .valuer_sets_marked = 0,
diff -cr ejudge/runlog.c ejudge-new/runlog.c
*** ejudge/runlog.c	2013-02-13 09:06:04.000000000 +0400
--- ejudge-new/runlog.c	2013-03-06 14:50:59.230602834 +0400
***************
*** 718,723 ****
--- 718,747 ----
    if (ps) *ps = sz;
  }
  
+ int run_get_team_problem_usage (
+ 	runlog_state_t state,
+ 	int teamid,
+ 	int prob_id,
+         int skip_ce_flag)
+ {
+   int i, n;
+   n = 0;
+   for (i = 0; i < state->run_u; i++) {
+     if (state->runs[i].status == RUN_VIRTUAL_START
+         || state->runs[i].status == RUN_VIRTUAL_STOP
+         || state->runs[i].status == RUN_EMPTY)
+       continue;
+     if ((state->runs[i].status == RUN_COMPILE_ERR
+          || state->runs[i].status == RUN_STYLE_ERR
+          || state->runs[i].status == RUN_REJECTED)
+         && skip_ce_flag) continue;
+     if (state->runs[i].user_id == teamid && state->runs[i].prob_id == prob_id)
+       n++;
+   }
+   return n;
+ }
+ 
+ 
  /* FIXME: VERY DUMB */
  int
  run_get_attempts(
diff -cr ejudge/runlog.h ejudge-new/runlog.h
*** ejudge/runlog.h	2013-02-13 09:06:04.000000000 +0400
--- ejudge-new/runlog.h	2013-03-06 14:50:59.231602834 +0400
***************
*** 161,167 ****
  time_t run_get_finish_time(runlog_state_t state);
  
  time_t run_get_duration(runlog_state_t);
! 
  void run_get_team_usage(runlog_state_t, int, int *, size_t*);
  int  run_get_attempts(runlog_state_t, int, int *, int *, int);
  int run_count_all_attempts(runlog_state_t state, int user_id, int prob_id);
--- 161,167 ----
  time_t run_get_finish_time(runlog_state_t state);
  
  time_t run_get_duration(runlog_state_t);
! int run_get_team_problem_usage(runlog_state_t, int, int, int);
  void run_get_team_usage(runlog_state_t, int, int *, size_t*);
  int  run_get_attempts(runlog_state_t, int, int *, int *, int);
  int run_count_all_attempts(runlog_state_t state, int user_id, int prob_id);
diff -cr ejudge/serve_2.c ejudge-new/serve_2.c
*** ejudge/serve_2.c	2013-02-13 09:06:04.000000000 +0400
--- ejudge-new/serve_2.c	2013-03-06 15:21:50.245088851 +0400
***************
*** 391,409 ****
  }
  
  int
! serve_check_user_quota(serve_state_t state, int user_id, size_t size)
  {
    int num;
    size_t total;
- 
    if (size > state->global->max_run_size) return -1;
    run_get_team_usage(state->runlog_state, user_id, &num, &total);
    if (num >= state->global->max_run_num
        || total + size > state->global->max_run_total)
      return -1;
    return 0;
  }
  
  int
  serve_check_clar_quota(serve_state_t state, int user_id, size_t size)
  {
--- 391,412 ----
  }
  
  int
! serve_check_user_quota(serve_state_t state, const struct section_problem_data *prob, int user_id, size_t size)
  {
    int num;
    size_t total;
    if (size > state->global->max_run_size) return -1;
    run_get_team_usage(state->runlog_state, user_id, &num, &total);
    if (num >= state->global->max_run_num
        || total + size > state->global->max_run_total)
      return -1;
+   num = run_get_team_problem_usage (state->runlog_state, user_id, prob->id, state->global->ignore_compile_errors);
+   if (num >= prob->max_user_run_count && prob->max_user_run_count>=0)
+ 	return -1;	
    return 0;
  }
  
+ 
  int
  serve_check_clar_quota(serve_state_t state, int user_id, size_t size)
  {
diff -cr ejudge/serve_state.h ejudge-new/serve_state.h
*** ejudge/serve_state.h	2013-02-13 09:06:05.000000000 +0400
--- ejudge-new/serve_state.h	2013-03-06 14:50:59.232602834 +0400
***************
*** 341,347 ****
  void serve_load_status_file(serve_state_t state);
  void serve_remove_status_file(serve_state_t state);
  
! int serve_check_user_quota(serve_state_t, int user_id, size_t size);
  int serve_check_clar_quota(serve_state_t, int user_id, size_t size);
  
  int serve_check_cnts_caps(serve_state_t state, const struct contest_desc *,
--- 341,347 ----
  void serve_load_status_file(serve_state_t state);
  void serve_remove_status_file(serve_state_t state);
  
! int serve_check_user_quota(serve_state_t, const struct section_problem_data*, int user_id, size_t size);
  int serve_check_clar_quota(serve_state_t, int user_id, size_t size);
  
  int serve_check_cnts_caps(serve_state_t state, const struct contest_desc *,

Post Reply