]>
iEval git - gruntmaster-data.git/blob - gruntmaster-problem
d9dbb736aa4318b7ebe51ff8906a111af7b1581a
6 use IO
::Prompter
[ -style
=> 'bold', '-stdio', '-verbatim' ];
7 use File
::Slurp qw
/read_file/;
8 use JSON qw
/encode_json/;
9 use Term
::ANSIColor qw
/RED RESET/;
10 use Getopt
::Long qw
/:config require_order/;
12 use constant LEVEL_VALUES
=> {
19 ##################################################
21 my $dsn = $ENV{GRUNTMASTER_DSN
} // 'dbi:Pg:';
22 my $db = Gruntmaster
::Data
->connect($dsn);
30 my $name = prompt
'Problem name';
31 my $private = prompt
('Private?', '-yn') eq 'y';
32 my $contest = prompt
'Contest';
33 my $author = prompt
'Problem author (full name)';
34 my $writer = prompt
'Problem statement writer (full name)';
35 my $owner = prompt
'Problem owner (username)';
36 my $level = prompt
'Problem level', -menu
=> "beginner\neasy\nmedium\nhard";
37 my $value = LEVEL_VALUES
->{$level};
38 my $statement = read_file prompt
'File with problem statement', -complete
=> 'filenames';
39 my $generator = prompt
'Generator', -menu
=> "File\nRun\nUndef";
40 my $runner = prompt
'Runner', -menu
=> "File\nVerifier\nInteractive";
41 my $judge = prompt
'Judge', -menu
=> "Absolute\nPoints";
42 my $testcnt = prompt
'Test count', '-i';
44 my $timeout = prompt
'Time limit (seconds)', '-n';
45 my $olimit = prompt
'Output limit (bytes)', '-i';
46 say 'Memory limits are broken, so I won\'t ask you for one';
48 my (@tests, $gensource, $genformat, $versource, $verformat);
50 if ($generator eq 'Run') {
51 $gensource = read_file prompt
, '[Generator::Run] Generator file name', -complete
=> 'filenames';
52 $genformat = prompt
'[Generator::Run] Generator format', -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
55 if ($runner eq 'File') {
56 my $default = $judge eq 'Points' ?
10 : 'Ok';
57 $tests[$_ - 1] = prompt
"[Runner::File] Score for test ${_} [$default]", -default => $default for 1 .. $testcnt;
60 if ($runner eq 'Verifier' || $runner eq 'Interactive') {
61 say RED
, 'WARNING: Runner::Interactive is experimental', RESET
if $runner eq 'Interactive';
62 $versource = prompt
"[Runner::$runner] Verifier file name", -complete
=> 'filenames';
63 $verformat = prompt
"[Runner::$runner] Verifier format", -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
71 statement
=> $statement,
75 generator
=> $generator,
80 $options{private
} = $private if $private;
81 $options{timeout
} = $timeout if $timeout;
82 $options{olimit
} = $olimit if $olimit;
83 $options{tests
} = encode_json \
@tests if @tests;
84 $options{gensource
} = $gensource if $gensource;
85 $options{genformat
} = $genformat if $genformat;
86 $options{versource
} = $versource if $versource;
87 $options{verformat
} = $verformat if $verformat;
88 $db->problems->create (\
%options);
90 $db->contest_problems->create({problem
=> $id, contest
=> $contest}) if $contest;
95 GetOptions
( 'file!' => \
$file );
96 my ($id, %values) = @_;
97 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $file;
98 $db->problem($id)->update(\
%values);
103 say $db->problem($id)->get_column($col)
108 say map {$_->id} $db->problems->all
113 $db->problem($id)->delete;
117 my %columns = $db->problem(shift)->get_columns;
120 Author: $columns{author}
121 Statement written by: $columns{writer}
122 Owner: $columns{owner}
123 Level: $columns{level}
124 Output limit: $columns{olimit}
125 Time limit: $columns{timeout}
126 Test count: $columns{testcnt}
127 Generator: $columns{generator}
128 Runner: $columns{runner}
129 Judge: $columns{judge}
130 Private: $columns{private}
134 ##################################################
136 my $cmd = 'cmd_' . shift;
137 cmd_help
unless exists $main::{$cmd};
148 gruntmaster-problem - shell interface to Gruntmaster 6000 problems
152 gruntmaster-problem add problem_id
153 gruntmaster-problem list
154 gruntmaster-problem rm problem_id
155 gruntmaster-problem show problem_id
156 gruntmaster-problem set [--file] problem_id key value
157 gruntmaster-problem get problem_id key
161 gruntmaster-problem is a tool for managing problems.
167 Prints the list of problems in the selected contest.
171 Prints detailed information about problem I<id>.
175 Adds a new problem with id I<id>.
179 Removes the problem with id I<id>.
181 =item B<set> I<id> I<key> I<value>
183 Sets the I<key> configuration option of problem I<id> to I<value>.
185 =item B<get> I<id> I<key>
187 Get the value of the I<key> configuration option of problem I<id>
189 =item B<set> --file I<id> I<key> I<file>
191 Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
197 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
199 =head1 COPYRIGHT AND LICENSE
201 Copyright (C) 2014 by Marius Gavrilescu
203 This library is free software; you can redistribute it and/or modify
204 it under the same terms as Perl itself, either Perl version 5.18.1 or,
205 at your option, any later version of Perl 5 you may have available.
This page took 0.069278 seconds and 4 git commands to generate.