]> iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/St.pm
Remove some languages
[gruntmaster-page.git] / lib / Gruntmaster / Page / St.pm
1 package Gruntmaster::Page::St;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6 use Gruntmaster::Page::Base st => 'Standings';
7 our @ISA = qw/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
9
10 use 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>
24 HTML
25 };
26
27 sub _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
56 1
This page took 0.051191 seconds and 4 git commands to generate.