]>
iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/St.pm
1 package Gruntmaster
::Page
::St
;
3 use Gruntmaster
::Page
::Base st
=> 'Standings';
5 use constant LEVEL_VALUES
=> {
13 my ($user, $problem, $date, $tries, $totaltime) = @_;
14 my $mxscore = LEVEL_VALUES
->{problem_level
($problem)};
16 my $timetaken = $date - get_open
($problem, $user);
17 $timetaken = 0 if $timetaken < 0;
18 $timetaken = 300 if $timetaken > $totaltime;
19 $score = ($totaltime - $timetaken) / $totaltime * $score;
20 $score -= $tries / 10 * $mxscore;
21 $score = $mxscore * 3 / 10 if $score < $mxscore * 3 / 10;
26 my ($self, $htc, $lang, $env, $ct) = @_;
27 debug
$env => "language is '$lang' and contest is '$ct'";
28 my ($totaltime, $start);
30 local $Gruntmaster::Data
::contest
;
32 $start = contest_start
($ct);
33 $totaltime = contest_end
($ct) - $start;
34 $Gruntmaster::Data
::contest
= $ct;
37 my @problems = problems
;
38 @problems = sort @problems;
41 next unless defined job_user
&& defined job_problem
&& defined job_result
;
42 next if $Gruntmaster::Data
::contest
&& job_date
() < $start;
44 if ($Gruntmaster::Data
::contest
) {
45 $scores{job_user
()}{job_problem
()} = job_result
() ?
0 : calc_score
(job_user
(), job_problem
(), job_date
(), $tries{job_user
()}{job_problem
()}, $totaltime);
46 $tries{job_user
()}{job_problem
()}++;
48 no warnings
'numeric';
49 $scores{job_user
()}{job_problem
()} = 0 + job_result_text
() || (job_result
() ?
0 : 100)
53 my @st = sort { $b->{score
} <=> $a->{score
} or $a->{user
} cmp $b->{user
}} map {
57 name
=> do {local $Gruntmaster::Data
::contest
; user_name
$user},
58 score
=> sum
(values $scores{$user}),
59 scores
=> [map { $scores{$user}{$_} // '-'} @problems],
60 problems
=> $Gruntmaster::Data
::contest
,
65 $st[$_]->{rank
} = $st[$_ - 1]->{rank
} + ($st[$_]->{score
} < $st[$_ - 1]->{score
}) for 1 .. $#st;
66 $htc->param(problems
=> [map { problem_name
} @problems ]) if $Gruntmaster::Data
::contest
;
67 $htc->param(st
=> \
@st);
This page took 0.053619 seconds and 4 git commands to generate.