]>
iEval git - gruntmaster-page.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 LEVEL_VALUES
=> {
18 my ($user, $problem, $date, $tries, $totaltime) = @_;
19 my $mxscore = LEVEL_VALUES
->{problem_level
($problem)};
21 my $timetaken = $date - get_open
($problem, $user);
22 $timetaken = 0 if $timetaken < 0;
23 $timetaken = 300 if $timetaken > $totaltime;
24 $score = ($totaltime - $timetaken) / $totaltime * $score;
25 $score -= $tries / 10 * $mxscore;
26 $score = $mxscore * 3 / 10 if $score < $mxscore * 3 / 10;
31 my ($self, $htc, $lang, $env, $ct) = @_;
32 debug
$env => "language is '$lang' and contest is '$ct'";
33 my ($totaltime, $start);
35 local $Gruntmaster::Data
::contest
;
37 $start = contest_start
($ct);
38 $totaltime = contest_end
($ct) - $start;
39 $Gruntmaster::Data
::contest
= $ct;
42 my @problems = problems
;
43 @problems = sort @problems;
46 next unless defined job_user
&& defined job_problem
&& defined job_result
;
47 next if $Gruntmaster::Data
::contest
&& job_date
() < $start;
49 if ($Gruntmaster::Data
::contest
) {
50 $scores{job_user
()}{job_problem
()} = job_result
() ?
0 : calc_score
(job_user
(), job_problem
(), job_date
(), $tries{job_user
()}{job_problem
()}, $totaltime);
51 $tries{job_user
()}{job_problem
()}++;
53 no warnings
'numeric';
54 $scores{job_user
()}{job_problem
()} = 0 + job_result_text
() || (job_result
() ?
0 : 100)
58 my @st = sort { $b->{score
} <=> $a->{score
} or $a->{user
} cmp $b->{user
}} map {
62 score
=> sum
(values $scores{$user}),
63 scores
=> [map { $scores{$user}{$_} // '-'} @problems],
64 problems
=> $Gruntmaster::Data
::contest
,
69 $st[$_]->{rank
} = $st[$_ - 1]->{rank
} + ($st[$_]->{score
} < $st[$_ - 1]->{score
}) for 1 .. $#st;
70 $htc->param(problems
=> [map { problem_name
} @problems ]) if $Gruntmaster::Data
::contest
;
71 $htc->param(st
=> \
@st);
This page took 0.052465 seconds and 4 git commands to generate.