X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=gruntmaster-problem;h=3ab12196135a778d6ce1734de7c2e0645933a02c;hb=f1e0b2b219a0b771c0d2c206564edf518fa4affb;hp=80aa68d7485f8d38f5894ffe395d4c4912d96bd1;hpb=014ee8a614839ded741f61979d979cdd4f20044c;p=gruntmaster-data.git diff --git a/gruntmaster-problem b/gruntmaster-problem index 80aa68d..3ab1219 100755 --- a/gruntmaster-problem +++ b/gruntmaster-problem @@ -2,12 +2,11 @@ use v5.14; use Gruntmaster::Data; -use Gruntmaster::Page::Submit; use IO::Prompter [ -style => 'bold', '-stdio', '-verbatim' ]; use File::Slurp qw/read_file/; use Term::ANSIColor qw/RED RESET/; -use Getopt::Long qw/GetOptions/; +use Getopt::Long qw/:config require_order/; ################################################## @@ -21,50 +20,54 @@ sub prompt_file{ my ($meta, $name, $prefix) = @_; my $filename = prompt '$prefix filename', -complete => 'filenames'; $meta->{files}{$name}{content} = read_file $filename; - $meta->{files}{$name}{format} = prompt '$prefix format', -menu => Gruntmaster::Page::Submit::FORMATS; + $meta->{files}{$name}{format} = prompt '$prefix format', -menu => [qw/C CPP MONO JAVA PASCAL PERL PYTHON/]; $meta->{files}{$name}{name} = prompt "$prefix filename [$filename]", -default => $filename; } sub cmd_add{ my $id = shift; my $name = prompt 'Problem name'; + my $private = prompt('Private?', '-yn') eq 'y'; 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, + generator => $generator, + runner => $runner, + judge => $judge, + testcnt => $testcnt, + ($private ? (private => $private) : ()), + (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"; @@ -114,14 +117,58 @@ gruntmaster-problem - shell interface to Gruntmaster 6000 problems =head1 SYNOPSIS - gruntmaster-problem add problem_id - gruntmaster-problem list - gruntmaster-problem rm problem_id - gruntmaster-problem show problem_id - + gruntmaster-problem [--contest=mycontest] add problem_id + gruntmaster-problem [--contest=mycontest] list + gruntmaster-problem [--contest=mycontest] rm problem_id + gruntmaster-problem [--contest=mycontest] show problem_id + gruntmaster-problem [--contest=mycontest] set [--file] problem_id key value =head1 DESCRIPTION +gruntmaster-problem is a tool for managing problems. + +Select the contest with the optional argument I<--contest>. + +=over + +=item B + +Prints the list of problems in the selected contest. + +=item B I + +Prints detailed information about problem I. + +=item B I + +Adds a new problem with id I. + +=item B I + +Removes the problem with id I. + +=item B I I I + +Sets the I configuration option of problem I to I. + +=item B --file I I I + +Sets the I configuration option of problem I to the contents of the file I. + +=back + +=head1 AUTHOR + +Marius Gavrilescu Emarius@ieval.roE + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2014 by Marius Gavrilescu + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. =cut