From: Marius Gavrilescu Date: Sun, 9 Feb 2014 16:47:09 +0000 (+0200) Subject: Move most problem parameters out of problem_meta X-Git-Tag: 5999.000_002~8 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=cd25d613ea68d3fae63a98225efe0a30cf82274e;p=gruntmaster-data.git Move most problem parameters out of problem_meta --- diff --git a/gruntmaster-problem b/gruntmaster-problem index a03b093..5b4375f 100755 --- a/gruntmaster-problem +++ b/gruntmaster-problem @@ -28,43 +28,35 @@ sub prompt_file{ sub cmd_add{ my $id = shift; my $name = prompt 'Problem name'; + my $private = prompt 'Private?', '-yn'; my $author = prompt 'Problem author (full name)'; my $owner = prompt 'Problem owner (username)'; my $level = prompt 'Problem level', -menu => "beginner\neasy\nmedium\nhard"; my $statement = read_file prompt 'File with problem statement', -complete => 'filenames'; my %meta; - $meta{generator} = prompt 'Generator', -menu => "File\nRun\nUndef"; - $meta{runner} = prompt 'Runner', -menu => "File\nVerifier\nInteractive"; - $meta{judge} = prompt 'Judge', -menu => "Absolute\nPoints"; - $meta{testcnt} = prompt 'Test count', '-i'; - - $meta{timeout} = prompt 'Time limit (seconds)', '-n'; - delete $meta{timeout} unless $meta{timeout}; - $meta{olimit} = prompt 'Output limit (bytes)', '-i'; - delete $meta{olimit} unless $meta{olimit}; - say 'Memory limits are broken, so I won\'t ask you for one'; + my $generator = prompt 'Generator', -menu => "File\nRun\nUndef"; + my $runner = prompt 'Runner', -menu => "File\nVerifier\nInteractive"; + my $judge = prompt 'Judge', -menu => "Absolute\nPoints"; + my $testcnt = prompt 'Test count', '-i'; - if ($meta{generator} eq 'File') { - my $prefix = prompt '[Generator::File] Input file prefix'; - $meta{infile}[$_ - 1] = read_file "$prefix$_.in" for 1 .. $meta{testcnt}; - } + my $timeout = prompt 'Time limit (seconds)', '-n'; + my $olimit = prompt 'Output limit (bytes)', '-i'; + say 'Memory limits are broken, so I won\'t ask you for one'; - prompt_file \%meta, gen => '[Generator::Run] Generator' if $meta{generator} eq 'Run'; + prompt_file \%meta, gen => '[Generator::Run] Generator' if $generator eq 'Run'; - if ($meta{runner} eq 'File') { - my $prefix = prompt '[Runner::File] Output file prefix'; - $meta{okfile}[$_ - 1] = read_file "$prefix$_.ok" for 1 .. $meta{testcnt}; - $meta{tests}[$_ - 1] = prompt "[Runner::File] Score for test ${_} [10]", '-i', -default => 10 for 1 .. $meta{testcnt}; + if ($runner eq 'File') { + $meta{tests}[$_ - 1] = prompt "[Runner::File] Score for test ${_} [10]", '-i', -default => 10 for 1 .. $testcnt; } - prompt_file \%meta, ver => '[Runner::Verifier] Verifier' if $meta{runner} eq 'Verifier'; + prompt_file \%meta, ver => '[Runner::Verifier] Verifier' if $runner eq 'Verifier'; - if ($meta{runner} eq 'Interactive') { + if ($runner eq 'Interactive') { say RED, 'WARNING: Runner::Interactive is experimental', RESET; - prompt_file int => '[Runner::Interactive] Interactive verifier'; + prompt_file \%meta, int => '[Runner::Interactive] Interactive verifier'; } - insert_problem $id => name => $name, level => $level, statement => $statement, author => $author, owner => $owner; + insert_problem $id => name => $name, level => $level, statement => $statement, author => $author, owner => $owner, private => $private, generator => $generator, runner => $runner, judge => $judge, testcnt => $testcnt, (defined $timeout ? (timeout => $timeout) : ()), (defined $olimit ? (olimit => $olimit) : ()); set_problem_meta $id => \%meta; PUBLISH genpage => $contest ? "ct/$contest/pb/index.html" : 'pb/index.html'; PUBLISH genpage => $contest ? "ct/$contest/pb/$id.html" : "pb/$id.html"; diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index 73a0217..c5941c9 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -75,7 +75,7 @@ sub defhash{ }; } -defhash problem => qw/name level statement owner author private/; +defhash problem => qw/name level statement owner author private generator runner judge testcnt timeout olimit/; defhash contest => qw/start end name owner/; defhash job => qw/date errors extension filesize private problem result result_text user/; defhash user => qw/name email town university level/;