]> iEval git - gruntmaster-page.git/blame - lib/Gruntmaster/Page/St.pm
Add contest support to gruntmaster-job rerun
[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
410a7b48 10use constant TEMPLATES => {
cd9af27e 11 en => <<'HTML',
5bbf0128
MG
12<table border>
13<thead>
746789c0
MG
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
5bbf0128
MG
18<tbody>
19<tmpl_loop st><tr><td><tmpl_var user>
746789c0
MG
20<tmpl_if problems><tmpl_loop scores><td><tmpl_var _>
21</tmpl_loop></tmpl_if><td><tmpl_var score>
5bbf0128
MG
22</tmpl_loop>
23</table>
24HTML
bb95f538 25};
5bbf0128 26
bb95f538
MG
27sub _generate{
28 my ($self, $htc, $path, $lang) = @_;
5bbf0128 29
410a7b48
MG
30 $path =~ m,^(?:ct/([^/]+)/)?,;
31 local $Gruntmaster::Data::contest = $1;
cd9af27e 32
410a7b48
MG
33 my @problems = problems;
34 @problems = sort @problems;
cd9af27e
MG
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 }
5bbf0128 42 }
5bbf0128 43
cd9af27e
MG
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;
746789c0 52 $htc->param(problems => [map { problem_name } @problems ]) if $Gruntmaster::Data::contest;
cd9af27e 53 $htc->param(st => \@st);
5bbf0128
MG
54}
55
561
This page took 0.026588 seconds and 4 git commands to generate.