/**
  * @param \_OurBrand_\Quiz\Domain\Model\Exercises\SpellingAndGrammarCommaExercise $exercise
  * @return void
  */
 public function updateAction($exercise)
 {
     $questions = $questionsWithComma = $questionsWithoutComma = array();
     if ($this->request->hasArgument('questionWithComma')) {
         $questionsWithComma = $this->request->getArgument('questionWithComma');
     }
     if ($this->request->hasArgument('questionWithoutComma')) {
         $questionsWithoutComma = $this->request->getArgument('questionWithoutComma');
     }
     foreach ($questionsWithComma as $i => $questionText) {
         $questions[] = array('questionWithComma' => $questionText, 'questionWithoutComma' => $questionsWithoutComma[$i]);
     }
     $exercise->setQuestionsFromArray($questions);
     if ($this->request->hasArgument('quiz')) {
         $this->updateQuizBeforeUpdatingExercise($exercise->getQuiz(), $this->request->getArgument('quiz'));
     }
     if (!$this->request->hasArgument('json')) {
         $this->forward('update', 'exercise', null, array('exercise' => $exercise));
     }
     $this->forward('updateSilent', 'exercise', null, array('exercise' => $exercise, 'json' => $this->request->getArgument('json')));
 }
 /**
  * @dataProvider calculateScoreForAnswersDataProvider
  * @param string $mode withComma or withoutComma
  * @param array $answers
  * @param integer $expected
  */
 public function testCalculateScoreForAnswers($mode, $answers, $expected)
 {
     $exercise = new SpellingAndGrammarCommaExercise();
     $data = array(array('questionWithComma' => 'q, w, e', 'questionWithoutComma' => 'q, w e'), array('questionWithComma' => 'qqq www, eee', 'questionWithoutComma' => 'qqq www eee'), array('questionWithComma' => 'rrr, ttt eee www', 'questionWithoutComma' => 'rrr ttt eee www'));
     $exercise->setQuestionsFromArray($data);
     $answers = array('answers' => $answers, 'mode' => $mode);
     $this->assertSame($expected, $exercise->calculateScoreForAnswers($answers));
 }