]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Prevent participation in both divisions of a round
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster.pm
index c7c6620ed9f52bfe4952b15ebad4d029cbba8a15..8d9684266adb6093930aa10feea048335e249967 100644 (file)
@@ -28,6 +28,7 @@ use constant FORMAT_EXTENSION => {
        GOLANG => 'go',
        GOLFSCRIPT => 'gs',
        HASKELL => 'hs',
+       OBERON => 'm',
        MONO => 'cs',
        JAVA => 'java',
        PASCAL => 'pas',
@@ -106,7 +107,7 @@ sub dispatch_request{
                },
 
                sub (/st/:contest) {
-                       my @pb = map { [$_->{id}, $_->{name}] } @{problem_list contest => $_{contest}};
+                       my @pb = map { [$_->{id}, $_->{name}] } sort { $a->{value} <=> $b->{value} } @{problem_list contest => $_{contest}};
                        response st => 'Standings', {problems => \@pb, st => standings $_{contest}}, 10
                },
 
@@ -189,6 +190,11 @@ sub dispatch_request{
                                return reply 'This contest has finished' if $contest->{finished};
                                return reply 'This problem is private' if !admin && $private;
                                return reply 'This problem does not belong to this contest' unless contest_has_problem $_{contest}, $_{problem};
+                               if ($_{contest} =~ /d[12]$/) {
+                                       my $other = $_{contest} =~ y/12/21/r;
+                                       my ($ans) = db->query('SELECT COUNT(*) FROM jobs WHERE owner = ? AND contest = ?', remote_user->{id}, $other)->flat;
+                                       return reply 'You are not allowed to participate in both divisions of a round' if $ans;
+                               }
                        }
                        return reply 'Maximum source size is 10KB' if ($prog ? $prog->size : length $_{source_code}) > 10 * 1024;
                        return reply 'You must wait 30 seconds between jobs' if !admin && time <= remote_user->{lastjob} + 30;
This page took 0.021401 seconds and 4 git commands to generate.