]>
Commit | Line | Data |
---|---|---|
42546e6c MG |
1 | package Gruntmaster::Page::Submit; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | use parent qw/Exporter/; | |
7 | our @EXPORT_OK = qw/generate/; | |
8 | our $VERSION = '0.001'; | |
9 | ||
10 | use constant FORMATS => [qw/CPP/]; | |
11 | use constant TITLE => 'Submit job'; | |
12 | ||
13 | use Fcntl qw/:flock/; | |
14 | use HTML::Template::Compiled; | |
42546e6c | 15 | use YAML::Any qw/LoadFile/; |
832cb45e | 16 | use Gruntmaster::Page::Common qw/header footer/; |
cd9af27e | 17 | use Gruntmaster::Data qw//; |
42546e6c MG |
18 | |
19 | my %templates = ( | |
cd9af27e | 20 | en => <<'HTML', |
42546e6c MG |
21 | <form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data"> |
22 | <label>Problem:<br> | |
23 | <select name="problem" required> | |
24 | <tmpl_loop problems><option value="<tmpl_var id>"><tmpl_var name></option> | |
25 | </tmpl_loop></select></label><p> | |
26 | ||
27 | <label>File:<br> | |
28 | <input name="prog" required type="file"></label><p> | |
29 | ||
30 | <label>File format:<br> | |
31 | <select name="prog_format" required> | |
32 | <tmpl_loop formats><option value="<tmpl_var _>"><tmpl_var _></option> | |
33 | </tmpl_loop></select></label><p> | |
34 | ||
35 | <input type="submit" value="Submit job"> | |
36 | HTML | |
37 | ); | |
38 | ||
39 | $templates{$_} = header($_, TITLE) . $templates{$_} for keys %templates; | |
40 | $templates{$_} .= footer $_ for keys %templates; | |
41 | ||
42 | sub generate{ | |
cd9af27e MG |
43 | my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]}); |
44 | my @problems = map +{ id => $_, name => problem_name }, problems; | |
45 | $htc->param(problems => \@problems); | |
46 | $htc->param(formats => FORMATS); | |
47 | $htc->output | |
42546e6c MG |
48 | } |
49 | ||
50 | 1 |