]> iEval git - plack-app-gruntmaster.git/blame_incremental - lib/Gruntmaster/Page/St.pm
Remove some languages
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / St.pm
... / ...
CommitLineData
1package Gruntmaster::Page::St;
2
3use 5.014000;
4use strict;
5use warnings;
6use Gruntmaster::Page::Base st => 'Standings';
7our @ISA = qw/Gruntmaster::Page::Base/;
8our $VERSION = '0.001';
9
10use constant TEMPLATES => {
11 en => <<'HTML',
12<table border>
13<thead>
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
16</tmpl_if>
17
18<tbody>
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>
22</tmpl_loop>
23</table>
24HTML
25};
26
27sub _generate{
28 my ($self, $htc, $path, $lang) = @_;
29
30 $path =~ m,^(?:ct/([^/]+)/)?,;
31 local $Gruntmaster::Data::contest = $1;
32
33 my @problems = problems;
34 @problems = sort @problems;
35 my %scores;
36 for (1 .. jobcard) {
37 if (job_result_text =~ m/^(\d+)/) {
38 $scores{job_user()}{job_problem()} = $1;
39 } else {
40 $scores{job_user()}{job_problem()} = job_result() ? 0 : 100;
41 }
42 }
43
44 my @st = sort { $b->{score} <=> $a->{score} } map {
45 my $user = $_;
46 +{
47 user => $user,
48 score => sum (values $scores{$user}),
49 scores => [map { $scores{$user}{$_} // '-'} @problems],
50 }
51 } keys %scores;
52 $htc->param(problems => [map { problem_name } @problems ]) if $Gruntmaster::Data::contest;
53 $htc->param(st => \@st);
54}
55
561
This page took 0.022243 seconds and 4 git commands to generate.