testcnt INT NOT NULL,
tests TEXT,
timeout REAL NOT NULL,
- value INT,
+ value INT NOT NULL,
genformat TEXT,
gensource TEXT,
verformat TEXT,
use Term::ANSIColor qw/RED RESET/;
use Getopt::Long qw/:config require_order/;
+use constant LEVEL_VALUES => {
+ beginner => 100,
+ easy => 250,
+ medium => 500,
+ hard => 1000,
+};
+
##################################################
my $dsn = $ENV{GRUNTMASTER_DSN} // 'dbi:Pg:';
my $writer = prompt 'Problem statement writer (full name)';
my $owner = prompt 'Problem owner (username)';
my $level = prompt 'Problem level', -menu => "beginner\neasy\nmedium\nhard";
+ my $value = LEVEL_VALUES->{$level};
my $statement = read_file prompt 'File with problem statement', -complete => 'filenames';
my $generator = prompt 'Generator', -menu => "File\nRun\nUndef";
my $runner = prompt 'Runner', -menu => "File\nVerifier\nInteractive";
id => $id,
name => $name,
level => $level,
+ value => $value,
statement => $statement,
author => $author,
writer => $writer,
}
}
-use constant LEVEL_VALUES => {
- beginner => 100,
- easy => 250,
- medium => 500,
- hard => 1000,
-};
-
sub calc_score{
my ($mxscore, $time, $tries, $totaltime) = @_;
my $score = $mxscore;
my $open = $self->opens->find($ct->id, $job->problem->id, $job->owner->id);
my $time = $job->date - ($open ? $open->time : $ct->start);
next if $time < 0;
- my $value = $job->problem->value // LEVEL_VALUES->{$job->problem->level};
+ my $value = $job->problem->value;
my $factor = $job->result ? 0 : 1;
$factor = $1 / 100 if $job->result_text =~ /^(\d+ )/;
$scores{$job->owner->id}{$job->problem->id} = int ($factor * calc_score ($value, $time, $tries{$job->owner->id}{$job->problem->id}++, $ct->stop - $ct->start));
=head2 value
data_type: 'integer'
- is_nullable: 1
+ is_nullable: 0
=head2 genformat
"timeout",
{ data_type => "real", is_nullable => 0 },
"value",
- { data_type => "integer", is_nullable => 1 },
+ { data_type => "integer", is_nullable => 0 },
"genformat",
{ data_type => "text", is_nullable => 1 },
"gensource",
__PACKAGE__->many_to_many("contests", "contest_problems", "contest");
-# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-05-16 15:03:32
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tvap77v0faSMxFiLu1uggQ
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-01 14:39:28
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/p3BIfVYSG5AKSSgVgOoOQ
sub is_private {
my ($self, $time) = @_;
ok !$db->contest('rc')->is_finished(25), '!is_finished';
ok $db->contest('rc')->is_running(25), 'is_running';
-$db->problems->create({id => 'pb', name => 'Problem', generator => 'Undef', runner => 'File', judge => 'Absolute', level => 'beginner', owner => 'MGV', statement => '...', testcnt => 1, timeout => 1, private => 0});
+$db->problems->create({id => 'pb', name => 'Problem', generator => 'Undef', runner => 'File', judge => 'Absolute', level => 'beginner', value => 100, owner => 'MGV', statement => '...', testcnt => 1, timeout => 1, private => 0});
ok !$db->problem('pb')->is_private(25), '!is_private';
$db->problem('pb')->update({private => 1});
system $perl, 'gruntmaster-problem', 'set', 'pb', 'owner', 'nobody';
withdb { is $db->problem('pb')->owner->id, 'nobody', 'gruntmaster-problem set' };
-withdb { $db->problems->create({id => 'dummy', name => 'Dummy', generator => 'Undef', runner => 'File', judge => 'Absolute', level => 'beginner', owner => 'MGV', statement => '...', testcnt => 1, timeout => 1}) };
+withdb { $db->problems->create({id => 'dummy', name => 'Dummy', generator => 'Undef', runner => 'File', judge => 'Absolute', level => 'beginner', value => 100, owner => 'MGV', statement => '...', testcnt => 1, timeout => 1}) };
@list = sort `$perl gruntmaster-problem list`;
chomp @list;