]>
iEval git - gruntmaster-data.git/blob - gruntmaster-problem
fa1403e71c3692a7900566a63e78b5eca50f9c39
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 ##################################################
14 my $dsn = $ENV{GRUNTMASTER_DSN
} // 'dbi:Pg:';
15 my $db = Gruntmaster
::Data
->connect($dsn);
23 my $name = prompt
'Problem name';
24 my $private = prompt
('Private?', '-yn') eq 'y';
25 my $contest = prompt
'Contest';
26 my $author = prompt
'Problem author (full name)';
27 my $writer = prompt
'Problem statement writer (full name)';
28 my $owner = prompt
'Problem owner (username)';
29 my $level = prompt
'Problem level', -menu
=> "beginner\neasy\nmedium\nhard";
30 my $statement = read_file prompt
'File with problem statement', -complete
=> 'filenames';
31 my $generator = prompt
'Generator', -menu
=> "File\nRun\nUndef";
32 my $runner = prompt
'Runner', -menu
=> "File\nVerifier\nInteractive";
33 my $judge = prompt
'Judge', -menu
=> "Absolute\nPoints";
34 my $testcnt = prompt
'Test count', '-i';
36 my $timeout = prompt
'Time limit (seconds)', '-n';
37 my $olimit = prompt
'Output limit (bytes)', '-i';
38 say 'Memory limits are broken, so I won\'t ask you for one';
40 my (@tests, $gensource, $genformat, $versource, $verformat);
42 if ($generator eq 'Run') {
43 $gensource = read_file prompt
, '[Generator::Run] Generator file name', -complete
=> 'filenames';
44 $genformat = prompt
'[Generator::Run] Generator format', -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
47 if ($runner eq 'File') {
48 my $default = $judge eq 'Points' ?
10 : 'Ok';
49 $tests[$_ - 1] = prompt
"[Runner::File] Score for test ${_} [$default]", -default => $default for 1 .. $testcnt;
52 if ($runner eq 'Verifier' || $runner eq 'Interactive') {
53 say RED
, 'WARNING: Runner::Interactive is experimental', RESET
if $runner eq 'Interactive';
54 $versource = prompt
"[Runner::$runner] Verifier file name", -complete
=> 'filenames';
55 $verformat = prompt
"[Runner::$runner] Verifier format", -menu
=> [qw
/C CPP MONO JAVA PASCAL PERL PYTHON/];
62 statement
=> $statement,
66 generator
=> $generator,
71 $options{private
} = $private if $private;
72 $options{timeout
} = $timeout if $timeout;
73 $options{olimit
} = $olimit if $olimit;
74 $options{tests
} = encode_json \
@tests if @tests;
75 $options{gensource
} = $gensource if $gensource;
76 $options{genformat
} = $genformat if $genformat;
77 $options{versource
} = $versource if $versource;
78 $options{verformat
} = $verformat if $verformat;
79 $db->problems->create (\
%options);
81 $db->contest_problems->create({problem
=> $id, contest
=> $contest}) if $contest;
86 GetOptions
( 'file!' => \
$file );
87 my ($id, %values) = @_;
88 %values = map { $_ => scalar read_file
$values{$_} } keys %values if $file;
89 $db->problem($id)->update(\
%values)
94 say $db->problem($id)->get_column($col)
99 say map {$_->id} $db->problems->all
103 $db->problem(shift)->delete
107 my %columns = $db->problem(shift)->get_columns;
110 Author: $columns{author}
111 Statement written by: $columns{writer}
112 Owner: $columns{owner}
113 Level: $columns{level}
114 Output limit: $columns{olimit}
115 Time limit: $columns{timeout}
116 Test count: $columns{testcnt}
117 Generator: $columns{generator}
118 Runner: $columns{runner}
119 Judge: $columns{judge}
120 Private: $columns{private}
124 ##################################################
126 my $cmd = 'cmd_' . shift;
127 cmd_help
unless exists $main::{$cmd};
138 gruntmaster-problem - shell interface to Gruntmaster 6000 problems
142 gruntmaster-problem add problem_id
143 gruntmaster-problem list
144 gruntmaster-problem rm problem_id
145 gruntmaster-problem show problem_id
146 gruntmaster-problem set [--file] problem_id key value
147 gruntmaster-problem get problem_id key
151 gruntmaster-problem is a tool for managing problems.
157 Prints the list of problems in the selected contest.
161 Prints detailed information about problem I<id>.
165 Adds a new problem with id I<id>.
169 Removes the problem with id I<id>.
171 =item B<set> I<id> I<key> I<value>
173 Sets the I<key> configuration option of problem I<id> to I<value>.
175 =item B<get> I<id> I<key>
177 Get the value of the I<key> configuration option of problem I<id>
179 =item B<set> --file I<id> I<key> I<file>
181 Sets the I<key> configuration option of problem I<id> to the contents of the file I<file>.
187 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
189 =head1 COPYRIGHT AND LICENSE
191 Copyright (C) 2014 by Marius Gavrilescu
193 This library is free software; you can redistribute it and/or modify
194 it under the same terms as Perl itself, either Perl version 5.18.1 or,
195 at your option, any later version of Perl 5 you may have available.
This page took 0.06701 seconds and 3 git commands to generate.