Ejemplo n.º 1
0
 /**
  * Return any question id's and warnings if a question does not have exactly 1 correct answer
  *
  * @return collection
  */
 public function warnings()
 {
     $warnings = new \Illuminate\Database\Eloquent\Collection();
     $questions = Question::where('quiz_id', '=', $this->id)->get();
     foreach ($questions as $question) {
         $number_of_correct_answers = $question->numberOfCorrectAnswers();
         if ($number_of_correct_answers != 1) {
             $warning = 'Question has ' . $number_of_correct_answers . ' correct answers!';
             $warnings->put($question->id, $warning);
         }
     }
     return $warnings;
 }