]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/St.pm
2186fea570647822782d3fb32f6a3492f0750c2c
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 if ($Gruntmaster::Data
::contest
) {
47 $tries{job_user
()}{job_problem
()}++;
48 $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;
49 } elsif (defined job_user
&& defined job_problem
&& defined job_result
) {
50 if (defined job_result_text
&& job_result_text
=~ m/^(\scores+)/) {
51 $scores{job_user
()}{job_problem
()} = $ct;
53 $scores{job_user
()}{job_problem
()} = 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.052642 seconds and 3 git commands to generate.