/**
  * @dataProvider isCompletedDataProvider
  * @param string $mode withComma or withoutComma
  * @param array $answers
  * @param integer $maxScore
  * @param integer $expected
  */
 public function testIsCompleted($mode, $answers, $maxScore, $expected)
 {
     $exercise = new SpellingAndGrammarCommaExercise();
     $exercise->setMaxScore($maxScore);
     $answers = array('answers' => $answers, 'mode' => $mode);
     $this->assertSame($expected, $exercise->isCompleted($answers));
 }
 /**
  * Register answer.
  *
  * @param \_OurBrand_\Quiz\Domain\Model\Exercises\SpellingAndGrammarCommaExercise $exercise
  * @return void
  */
 public function registerAnswerAction($exercise)
 {
     $answers = $this->request->hasArgument('answers') ? $this->request->getArgument('answers') : array();
     $mode = $this->request->hasArgument('mode') ? $this->request->getArgument('mode') : '';
     $answer = array('answers' => $answers, 'mode' => $mode);
     $score = $exercise->calculateScoreForAnswers($answer);
     $status = $exercise->isCompleted($answer);
     // Save the score, for the given answers, on this exercise, during this quiz.
     $this->exerciseService->registerAnswer($score, $status, $answer, $exercise, $this->studentQuizSession);
     $this->studentQuizSessionService->updateProgress($this->studentQuizSession);
     $this->view->assign('value', array('timeRemaining' => $this->studentQuizSession->getTimeRemaining()));
     if (!$this->isJson) {
         $this->redirect('studentnavigate', 'quiz', $this->request->hasArgument('goto') ? $this->request->getArgument('goto') : 'next');
     }
 }