]> iEval git - gruntmaster-page.git/blob - lib/Gruntmaster/Page/Pb/Entry.pm
Add submit
[gruntmaster-page.git] / lib / Gruntmaster / Page / Pb / Entry.pm
1 package Gruntmaster::Page::Pb::Entry;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6 use Gruntmaster::Page::Base pb_entry => '<tmpl_var name>';
7 our @ISA = qw/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
9
10 use constant TEMPLATES => {
11 en => <<'HTML',
12 <div class="row">
13 <div class="col-md-9">
14 <tmpl_var ESCAPE=0 statement>
15 </div>
16
17 <div class="col-md-3">
18 <dl>
19 <dt>Author</dt> <dd><tmpl_var author></dd>
20 <dt>Owner</dt> <dd><tmpl_var owner></dd>
21 </dl>
22
23 <tmpl_if cansubmit>
24 <h1>Submit solution</h1>
25 <form action="<tmpl_var id>/submit" method="POST" enctype="multipart/form-data" role="form">
26 <input type="hidden" name="problem" value="<tmpl_var id>">
27 <tmpl_if_defined contest><input type="hidden" name="contest" value="<tmpl_var contest>"></tmpl_if_defined>
28
29 <div class="form-group"><label for="prog">File:</label><input id="prog" name="prog" type="file"></div>
30 <div class="form-group"><label for="source_code">Source code:</label> <textarea class="form-control" id="source_code" name="source_code"></textarea></div>
31 <div class="form-group"><label for="prog_format">File format:</label><select id="prog_format" name="prog_format" class="form-control" required>
32 <tmpl_loop formats><option value="<tmpl_var _>"><tmpl_var _></option>
33 </tmpl_loop></select></div>
34
35 <input type="submit" value="Submit job" class="btn btn-primary">
36 </form>
37 </tmpl_if>
38 </div>
39 HTML
40 };
41
42 use constant FORMATS => [qw/C CPP MONO JAVA PASCAL PERL PYTHON/];
43
44 sub _generate{
45 my ($self, $htc, $lang, $env, $contest, $id) = @_;
46 debug $env => "language is '$lang', contest is '$contest', id is '$id'";
47
48 $htc->param(cansubmit => 1);
49 if ($contest) {
50 $htc->param(cansubmit => time <= contest_end $contest);
51 $htc->param(contest => $contest);
52 }
53 $htc->param(formats => FORMATS);
54 $htc->param(id => $id);
55 local $Gruntmaster::Data::contest = $contest if $contest;
56 $htc->param(name => problem_name $id);
57 $htc->param(author => problem_author $id);
58 $htc->param(owner => problem_owner $id);
59 $htc->param(statement => problem_statement $id);
60 }
61
62 1
This page took 0.052607 seconds and 5 git commands to generate.