]>
Commit | Line | Data |
---|---|---|
42546e6c MG |
1 | package Gruntmaster::Page::Pb; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
bb95f538 MG |
6 | use Gruntmaster::Page::Base pb => 'Problems'; |
7 | our @ISA = qw/Gruntmaster::Page::Base/; | |
42546e6c MG |
8 | our $VERSION = '0.001'; |
9 | ||
bb95f538 MG |
10 | use constant TEMPLATES => { |
11 | en => <<'HTML', | |
96f80a63 | 12 | <tmpl_if levels> |
9be91908 | 13 | <h2>Beginner</h2> |
42546e6c | 14 | <ul> |
3da9c3c2 | 15 | <tmpl_loop beginner><li><a href="<tmpl_var id>.var"><tmpl_var name></a> |
9be91908 MG |
16 | </tmpl_loop></ul> |
17 | ||
18 | <h2>Easy</h2> | |
19 | <ul> | |
3da9c3c2 | 20 | <tmpl_loop easy><li><a href="<tmpl_var id>.var"><tmpl_var name></a> |
9be91908 MG |
21 | </tmpl_loop></ul> |
22 | ||
23 | <h2>Medium</h2> | |
24 | <ul> | |
3da9c3c2 | 25 | <tmpl_loop medium><li><a href="<tmpl_var id>.var"><tmpl_var name></a> |
9be91908 MG |
26 | </tmpl_loop></ul> |
27 | ||
9be91908 MG |
28 | <h2>Hard</h2> |
29 | <ul> | |
3da9c3c2 | 30 | <tmpl_loop hard><li><a href="<tmpl_var id>.var"><tmpl_var name></a> |
42546e6c | 31 | </tmpl_loop></ul> |
96f80a63 MG |
32 | |
33 | <tmpl_else> | |
34 | <ul> | |
3da9c3c2 | 35 | <tmpl_loop problems><li><a href="<tmpl_var id>.var"><tmpl_var name></a> |
96f80a63 MG |
36 | </tmpl_loop></ul> |
37 | </tmpl_if> | |
42546e6c | 38 | HTML |
bb95f538 | 39 | }; |
42546e6c | 40 | |
bb95f538 MG |
41 | sub _generate{ |
42 | my ($self, $htc, $path, $lang) = @_; | |
42546e6c | 43 | |
bb95f538 | 44 | $path =~ m,^(?:ct/([^/]+)/)?pb/index.html$,; |
cd9af27e MG |
45 | local $Gruntmaster::Data::contest = $1; |
46 | ||
cd9af27e MG |
47 | my @problems = sort { $b->{name} cmp $a->{name} } map +{ |
48 | id => $_, | |
49 | name => problem_name, | |
50 | level => problem_level}, problems; | |
bb95f538 | 51 | |
cd9af27e MG |
52 | for my $d (qw/beginner easy medium advanced hard/) { |
53 | $htc->param($d => [grep {$_->{level} and $_->{level} eq $d} @problems]); | |
54 | } | |
55 | $htc->param(levels => grep { $_->{level} } @problems); | |
56 | $htc->param(problems => \@problems); | |
42546e6c MG |
57 | } |
58 | ||
59 | 1 |