]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/St.pm
0e3c316dd254775c0d895bd09c29ec1fb595c5b5
1 package Gruntmaster
::Page
::St
;
3 use Gruntmaster
::Page
::Base st
=> 'Standings';
5 use constant LEVEL_VALUES
=> {
13 my ($mxscore, $time, $tries, $totaltime) = @_;
15 $time = 0 if $time < 0;
16 $time = 300 if $time > $totaltime;
17 $score = ($totaltime - $time) / $totaltime * $score;
18 $score -= $tries / 10 * $mxscore;
19 $score = $mxscore * 3 / 10 if $score < $mxscore * 3 / 10;
24 my ($self, $htc, $lang, $env) = @_;
25 #debug $env => "language is '$lang'";
27 my $ct = $env->{'gruntmaster.contest'} && db
($env)->contest($env->{'gruntmaster.contest'});
29 my @problems = map { $_->problem } db
($env)->contest_problems->search({contest
=> $ct && $ct->id}, {qw
/join problem order_by problem.level/});
31 for my $job (db
($env)->jobs->search({contest
=> $ct && $ct->id}, {order_by
=> 'id'})) {
34 my $open = db
($env)->opens->find($ct->id, $job->problem->id, $job->owner->id);
35 my $time = $job->date - ($open ?
$open->time : $ct->start);
37 my $value = $job->problem->value // LEVEL_VALUES
->{$job->problem->level};
38 $scores{$job->owner->id}{$job->problem->id} = $job->result ?
0 : calc_score
($value, $time, $tries{$job->owner}{$job->problem}, $ct->stop - $ct->start);
39 $tries{$job->owner->id}{$job->problem->id}++;
41 no warnings
'numeric';
42 $scores{$job->owner->id}{$job->problem->id} = 0 + $job->result_text || ($job->result ?
0 : 100)
46 my @st = sort { $b->{score
} <=> $a->{score
} or $a->{user
}->id cmp $b->{user
}->id} map {
49 user
=> db
($env)->user($user),
50 score
=> sum
(values $scores{$user}),
51 scores
=> [map { $scores{$user}{$_->id} // '-'} @problems],
57 $st[$_]->{rank
} = $st[$_ - 1]->{rank
} + ($st[$_]->{score
} < $st[$_ - 1]->{score
}) for 1 .. $#st;
58 $htc->param(problems
=> \
@problems) if $ct;
59 $htc->param(st
=> \
@st);
This page took 0.061808 seconds and 3 git commands to generate.