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