]> iEval git - gruntmaster-page.git/blame - lib/Gruntmaster/Page/St.pm
Add gensrc
[gruntmaster-page.git] / lib / Gruntmaster / Page / St.pm
CommitLineData
5bbf0128
MG
1package Gruntmaster::Page::St;
2
3use 5.014000;
4use strict;
5use warnings;
bb95f538
MG
6use Gruntmaster::Page::Base st => 'Standings';
7our @ISA = qw/Gruntmaster::Page::Base/;
5bbf0128
MG
8our $VERSION = '0.001';
9
bb95f538 10use 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>
21HTML
bb95f538 22};
5bbf0128 23
bb95f538
MG
24sub _generate{
25 my ($self, $htc, $path, $lang) = @_;
5bbf0128 26
bb95f538 27 local $Gruntmaster::Data::contest = ($path =~ m,^ct/([^/]+)/,)[0];
cd9af27e
MG
28
29 my @problems = sort problems;
30 my %scores;
31 for (1 .. jobcard) {
32 if (job_result_text =~ m/^(\d+)/) {
33 $scores{job_user()}{job_problem()} = $1;
34 } else {
35 $scores{job_user()}{job_problem()} = job_result() ? 0 : 100;
36 }
5bbf0128 37 }
5bbf0128 38
cd9af27e
MG
39 my @st = sort { $b->{score} <=> $a->{score} } map {
40 my $user = $_;
41 +{
42 user => $user,
43 score => sum (values $scores{$user}),
44 scores => [map { $scores{$user}{$_} // '-'} @problems],
45 }
46 } keys %scores;
47 $htc->param(problems => \@problems);
48 $htc->param(st => \@st);
5bbf0128
MG
49}
50
511
This page took 0.028609 seconds and 4 git commands to generate.