/** * Does the student has access? * * Checks if this is a correct demo access or if the real user has access * @param \_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession * @return bool */ protected function studentHasAccess($studentQuizSession) { if (true === $this->currentUser->IsDemoUser() && true === $studentQuizSession->getQuizSession()->getIsDemo() || $studentQuizSession->getStudent() === $this->currentUser->getIdentifier()) { return true; } return false; }
/** * Development function * @param \_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession */ public function ResetStudentQuizSessionAction($studentQuizSession) { $quiz = $studentQuizSession->getQuizSession()->getQuiz(); foreach ($quiz->getExercises() as $exercise) { $previousAnswers = $this->answerRepository->findBySessionAndExercise($studentQuizSession, $exercise); $trackers = $this->trackStudentAudioPlaybackRepository->findBySessionAndExercise($studentQuizSession, $exercise); if ($previousAnswers->count() > 0) { foreach ($previousAnswers as $previousAnswer) { $this->answerRepository->remove($previousAnswer); } } if ($trackers->count() > 0) { foreach ($trackers as $tracker) { $this->trackStudentAudioPlaybackRepository->remove($tracker); } } } $studentQuizSession->setStartTime(null); $studentQuizSession->setCurrentTime(null); $studentQuizSession->setFinishedTime(null); $studentQuizSession->setTimesResumed(0); $this->studentQuizSessionRepository->update($studentQuizSession); $this->persistenceManager->persistAll(); $this->redirect('studentindex'); }
/** * @param \_OurBrand_\Quiz\Domain\Model\Exercise $exercise * @param \_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession * @throws ForwardException * @throws AccessDeniedException */ public function reviewAction($exercise, $studentQuizSession) { if ($studentQuizSession->getQuizSession()->getQuiz() != $exercise->getQuiz()) { $this->throwStatus(403); } // TODO: Access. Can only be viewed by student or responsible instructor. $useController = $this->getControllerNameForExercise($exercise); if ($useController !== false) { $this->forward('review', $useController, null, array('exercise' => $exercise, 'studentQuizSession' => $studentQuizSession)); } else { throw new ForwardException('Can not forward to correct controller for object of type ' . get_class($exercise)); } }