- my $private = (problem->private && !contest) ? 1 : 0;
- return reply 'This contest has finished' if contest && contest->is_finished;
- return reply 'This contest has not yet started' if contest && contest->is_pending;
- return reply 'This problem is private' if !admin && $private;
- return reply 'This problem does not belong to this contest' if contest && !db->contest_problems->find($_{contest}, $_{problem});
+ my $problem = db->problem_entry($_{problem});
+ my $private = $problem->{private} ? 1 : 0;
+ if ($_{contest}) {
+ $private = 0;
+ my $contest = db->contest_entry($_{contest});
+ return reply 'This contest has not yet started' if !$contest->{started};
+ 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 db->contest_has_problem($_{contest}, $_{problem});
+ }