Exemplo n.º 1
0
 /**
  * Check if the score of the Paper is available to User.
  *
  * @param Exercise $exercise
  * @param Paper    $paper
  *
  * @return bool
  */
 public function isScoreAvailable(Exercise $exercise, Paper $paper)
 {
     $markMode = $exercise->getMarkMode();
     switch ($markMode) {
         case MarkMode::AFTER_END:
             $available = !empty($paper->getEnd());
             break;
         case MarkMode::NEVER:
             $available = false;
             break;
         case MarkMode::WITH_CORRECTION:
         default:
             $available = $this->isSolutionAvailable($exercise, $paper);
             break;
     }
     return $available;
 }
Exemplo n.º 2
0
 /**
  * Checks whether a User has access to a Paper
  * ATTENTION : As is, anonymous have access to all the other anonymous Papers !!!
  *
  * @param Paper     $paper
  * @param User|null $user
  */
 private function assertHasPaperAccess(Paper $paper, User $user = null)
 {
     if ($paper->getEnd() || $user !== $paper->getUser()) {
         throw new AccessDeniedHttpException();
     }
 }