/** * 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'); }
/** * 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; }
/** * Generate testData * * This command inserts all the required data to start testing the student view of the Dictation exercise * * @return void */ public function generateInsertCommand() { $quiz = new Quiz(); $quiz->setTitle('Dictation Insert'); $quiz->setAuthor('Test Instructor'); $quiz->setCreator('instructor'); $quiz->setIsDraft(false); $quiz->setType(0); $exercise = new InsertDictationExercise(); $exercise->setTitle('Spelling and Grammer: Insert Dictation'); $exercise->setDescription('Description'); $snippet = new DictationSnippet(); $snippet->setText('<span class="textShow">This is a very</span> <span class="textmark">marvellous</span> horse'); $markedText = new MarkedText(); $markedText->setText('marvellous'); $snippet->addMarkedText($markedText); $exercise->addSnippet($snippet); $snippet = new DictationSnippet(); $snippet->setText('<span class="textShow">This is another</span> <span class="textmark">sentence</span> horse'); $markedText = new MarkedText(); $markedText->setText('sentence'); $snippet->addMarkedText($markedText); $exercise->addSnippet($snippet); $snippet = new DictationSnippet(); $snippet->setText('<span class="textmark">Newest</span> <span class="textShow">more</span><span class="textmark">text</span>'); $markedText = new MarkedText(); $markedText->setText('Newest'); $snippet->addMarkedText($markedText); $markedText = new MarkedText(); $markedText->setText('text'); $snippet->addMarkedText($markedText); $exercise->addSnippet($snippet); $quiz->addExercise($exercise); $this->quizRepository->add($quiz); //Create QuizSession $quizSession = new QuizSession(); $quizSession->setQuiz($quiz); $quizSession->setInstructor('instructor'); $quizSession->setStudentCanSeeSummaryAndReviewExercises(1); $quizSession->setShowGradeOnSummary(1); $this->quizSessionRepository->add($quizSession); //Create studentQuizSession $studentQuizSession = new StudentQuizSession(); $studentQuizSession->setQuizSession($quizSession); $studentQuizSession->setStudent('student'); $this->studentQuizSessionRepository->add($studentQuizSession); }
/** * Stop a studentQuizSession, which means the just one student. * * @param \_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession * @param bool $writeCommandFile * @return int|string */ public function stopStudentQuizSession(\_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession, $writeCommandFile = TRUE) { $out = 1; $studentQuizSession->setStopTime(new \TYPO3\Flow\Utility\Now()); $this->studentQuizSessionRepository->update($studentQuizSession); if ($writeCommandFile) { $out = $this->writeCommandFile($studentQuizSession->getQuizSession()); } return $out; }
/** * @param \_OurBrand_\Quiz\Domain\Model\StudentQuizSession $studentQuizSession */ public function updateProgress($studentQuizSession) { $studentQuizSession->setCurrentTime(new \DateTime()); $this->studentQuizSessionRepository->update($studentQuizSession); }
/** * @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)); } }