]> iEval git - gruntmaster-page.git/commitdiff
Add non-interactive score and countdown on pb_entry
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 1 Dec 2014 13:23:35 +0000 (15:23 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 1 Dec 2014 13:23:35 +0000 (15:23 +0200)
lib/Plack/App/Gruntmaster.pm
lib/Plack/App/Gruntmaster/HTML.pm
tmpl/pb_entry.en

index 3e37ef12996dca805965d8509596847418c4eb38..4dd497f742c966d5ac164f67cd65dfab89ec950b 100644 (file)
@@ -76,6 +76,7 @@ sub response {
                $params = $title;
                $title = 'No title';
        }
+       $params->{time} = time;
        bless {template => $template, title => $title, params => $params}, __PACKAGE__.'::Response'
 }
 
index 16ae617ecf9c3635f5a9d2bbba0701a62c039659..04127828de03ee7704f2deb2887d0eba9142a2ee 100644 (file)
@@ -122,6 +122,18 @@ sub process_pb_entry {
                statement => literal $args{statement},
                author    =>         $args{author},
                owner     =>         $args{owner_name} || $args{owner});
+       if ($args{contest_stop}) {
+               my $countdown = $tree->fid('countdown');
+               $countdown->attr('data-start' => $args{contest_start});
+               $countdown->attr('data-stop' => $args{contest_stop});
+               $countdown->attr('data-time' => $args{time});
+               my $left = $args{contest_stop} - $args{time};
+               $countdown->replace_content(sprintf '%02d:%02d:%02d', $left/60/60, $left/60%60, $left%60);
+               $tree->fid('score')->attr('data-value' => $args{value});
+               $tree->fid('score')->replace_content(Gruntmaster::Data::calc_score($args{value}, $args{time} - $args{contest_start}, 0, $args{contest_stop} - $args{contest_start}));
+       } else {
+               $_->detach for $tree->fclass('rc'); # requires contest
+       }
        if ($args{cansubmit}) {
                $tree->look_down(name => 'problem')->attr(value => $args{id});
                my $contest = $tree->look_down(name => 'contest');
index 8189d0b745d6b7e72745e8e0a164ab01772dc1fe..4e0d324cbe18870b5d53ca252c95e0d04e53ece3 100644 (file)
@@ -7,6 +7,8 @@
 <dl>
 <dt>Author</dt> <dd id="author">author</dd>
 <dt>Owner</dt> <dd id="owner">owner</dd>
+<dt class="rc">Score</dt> <dd id="score" data-value="100" class="rc">50</dd>
+<dt class="rc">Contest ends in</dt> <dd id="countdown" data-start="..." data-time="..." data-stop="..." class="rc">01:30</dd>
 </dl>
 
 <a href="/pb/problem_id/log/" id="job_log">Job log</a>
This page took 0.025599 seconds and 4 git commands to generate.