]>
Commit | Line | Data |
---|---|---|
5bbf0128 MG |
1 | package Gruntmaster::Page::St; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
bb95f538 MG |
6 | use Gruntmaster::Page::Base st => 'Standings'; |
7 | our @ISA = qw/Gruntmaster::Page::Base/; | |
5bbf0128 MG |
8 | our $VERSION = '0.001'; |
9 | ||
410a7b48 | 10 | use constant TEMPLATES => { |
cd9af27e | 11 | en => <<'HTML', |
5bbf0128 MG |
12 | <table border> |
13 | <thead> | |
14 | <tr><th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total | |
15 | <tbody> | |
16 | <tmpl_loop st><tr><td><tmpl_var user> | |
17 | <tmpl_loop scores><td><tmpl_var _> | |
18 | </tmpl_loop><td><tmpl_var score> | |
19 | </tmpl_loop> | |
20 | </table> | |
21 | HTML | |
bb95f538 | 22 | }; |
5bbf0128 | 23 | |
bb95f538 MG |
24 | sub _generate{ |
25 | my ($self, $htc, $path, $lang) = @_; | |
5bbf0128 | 26 | |
410a7b48 MG |
27 | $path =~ m,^(?:ct/([^/]+)/)?,; |
28 | local $Gruntmaster::Data::contest = $1; | |
cd9af27e | 29 | |
410a7b48 MG |
30 | my @problems = problems; |
31 | @problems = sort @problems; | |
cd9af27e MG |
32 | my %scores; |
33 | for (1 .. jobcard) { | |
34 | if (job_result_text =~ m/^(\d+)/) { | |
35 | $scores{job_user()}{job_problem()} = $1; | |
36 | } else { | |
37 | $scores{job_user()}{job_problem()} = job_result() ? 0 : 100; | |
38 | } | |
5bbf0128 | 39 | } |
5bbf0128 | 40 | |
cd9af27e MG |
41 | my @st = sort { $b->{score} <=> $a->{score} } map { |
42 | my $user = $_; | |
43 | +{ | |
44 | user => $user, | |
45 | score => sum (values $scores{$user}), | |
46 | scores => [map { $scores{$user}{$_} // '-'} @problems], | |
47 | } | |
48 | } keys %scores; | |
410a7b48 | 49 | $htc->param(problems => [map { problem_name } @problems ]); |
cd9af27e | 50 | $htc->param(st => \@st); |
5bbf0128 MG |
51 | } |
52 | ||
53 | 1 |