public function actionWriteForUnit($id) { $unit = $this->setupCourseRegistry($this->unitRepository->find($id)); $this->deliver($unit); if (!$unit->isCurrentPhase(Unit::REVIEWS) and !$this->user->isAllowed('review', 'writeAnytime')) { throw new \Nette\Application\BadRequestException('Forbidden', 403); } $this->template->uploadPath = $this->uploadStorage->path; $this->deliver($unit->course); $solution = null; try { // needs splitting into readable methods $reviewer = $this->userRepository->find($this->user->id); if (!($review = $this->reviewRepository->findUnfinishedReview($unit, $reviewer))) { if ($solution = $this->solutionRepository->findSolutionToReview($unit, $reviewer)) { $review = $this->reviewRepository->createReview($solution, $reviewer); $review = $this->reviewRepository->find($review->id); // fetching all columns $this->logEvent($review, 'create'); } else { return; } } else { $solution = $review->solution; } $this->template->review = $this->setupCourseRegistry($review); $this->template->solution = $solution; $assignment = $solution->assignment; $this->template->assignment = $this->produce($assignment); } catch (\Model\Repository\SolutionToReviewNotFoundException $e) { $this->template->message = $this->translator->translate('messages.unit.noSolutionAvailable'); } catch (\Model\Repository\ReviewLimitReachedException $e) { $this->template->message = $this->translator->translate('messages.unit.enoughReviews', NULL, array('count' => $unit->course->reviewCount)); } }
public function renderDefault($id) { $course = $this->courseRegistry->course; $this->deliver($course); $this->deliver($course->units); $this->template->favoriteSolutions = $this->solutionRepository->findFavoriteByUnits($course->units); $this->template->favoriteReviews = $this->reviewRepository->findFavoriteByUnits($course->units); $this->template->reviewsWithProblems = $this->reviewRepository->findReviewsWithProblemsByUserAndCourse($this->userInfo, $course); }
public function actionDefault($id) { $solution = $this->solutionRepository->find($id); $this->setupCourseRegistry($solution); if (!$this->courseRegistry->unit->hasReviewsPhaseStarted() && !$this->user->isAllowed('solution', 'viewAnytime')) { throw new \Nette\Application\BadRequestException('Forbidden', 403); } if ($this->user->isAllowed('solution', 'viewLog')) { $this->template->solutionLog = $this->logRepository->findByEntity('Solution', $id); } }