]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/St.pm
2100049934964b905a433176b30ca2d3502785af
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, $path, $lang) = @_;
49 my ($totaltime, $start);
51 $path =~ m
,^(?
:ct
/([^/]+)/)?
,;
52 local $Gruntmaster::Data
::contest
;
54 $start = contest_start
($1);
55 $totaltime = contest_end
($1) - $start;
56 $Gruntmaster::Data
::contest
= $1;
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/^(\d+)/) {
68 $scores{job_user
()}{job_problem
()} = $1;
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.061161 seconds and 3 git commands to generate.