]>
iEval git - plack-app-gruntmaster.git/blob - lib/Gruntmaster/Page/St.pm
1 package Gruntmaster
::Page
::St
;
6 use Gruntmaster
::Page
::Base st
=> 'Standings';
7 our @ISA = qw
/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
10 use constant TEMPLATES
=> {
14 <tmpl_if problems><tr><th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total
15 <tmpl_else><tr><th>Username<th>Score
19 <tmpl_loop st><tr><td><tmpl_var user>
20 <tmpl_if problems><tmpl_loop scores><td><tmpl_var _>
21 </tmpl_loop></tmpl_if><td><tmpl_var score>
27 use constant LEVEL_VALUES
=> {
35 my ($user, $problem, $date, $tries, $totaltime) = @_;
36 my $mxscore = LEVEL_VALUES
->{problem_level
($problem)};
38 my $timetaken = $date - get_open
($problem, $user);
39 $timetaken = 0 if $timetaken < 0;
40 $timetaken = 300 if $timetaken > $totaltime;
41 $score = ($totaltime - $timetaken) / $totaltime * $score;
42 $score -= $tries / 10 * $mxscore;
43 $score = $mxscore * 3 / 10 if $score < $mxscore * 3 / 10;
48 my ($self, $htc, $lang, $logger, $ct) = @_;
49 debug
$logger => "language is '$lang' and contest is '$ct'";
50 my ($totaltime, $start);
52 local $Gruntmaster::Data
::contest
;
54 $start = contest_start
($ct);
55 $totaltime = contest_end
($ct) - $start;
56 $Gruntmaster::Data
::contest
= $ct;
59 my @problems = problems
;
60 @problems = sort @problems;
63 if ($Gruntmaster::Data
::contest
) {
64 $tries{job_user
()}{job_problem
()}++;
65 $scores{job_user
()}{job_problem
()} = job_result
() ?
0 : calc_score
(job_user
(), job_problem
(), job_date
(), $tries{job_user
()}{job_problem
()}, $totaltime) if job_date
() > $start;
67 if (job_result_text
=~ m/^(\scores+)/) {
68 $scores{job_user
()}{job_problem
()} = $ct;
70 $scores{job_user
()}{job_problem
()} = job_result
() ?
0 : 100;
75 my @st = sort { $b->{score
} <=> $a->{score
} } map {
79 score
=> sum
(values $scores{$user}),
80 scores
=> [map { $scores{$user}{$_} // '-'} @problems],
81 problems
=> $Gruntmaster::Data
::contest
,
84 $htc->param(problems
=> [map { problem_name
} @problems ]) if $Gruntmaster::Data
::contest
;
85 $htc->param(st
=> \
@st);
This page took 0.045624 seconds and 4 git commands to generate.