Пример #1
0
 public function submitExamMember(Exam $exam, $answers = [])
 {
     $member = $this->getMemberSessionExam($exam);
     if ($member) {
         $answers = collect($answers)->map(function ($answer, $question_id) {
             $question = ExamQuestion::find($question_id);
             return new ExamAnswer(['question_id' => $question_id, 'answer' => $answer, 'is_correct' => $question->correct == $answer]);
         });
         $member->answers()->saveMany($answers);
         return $member->answers;
     }
     return null;
 }
Пример #2
0
 public function questionList($examid)
 {
     $question = ExamQuestion::where('exam_id', $examid)->get();
     return $question;
 }
Пример #3
0
 public function addExamQuestion(array $question)
 {
     $exam = new ExamQuestion();
     $exam->fill($question);
     $exam->exam()->associate($this->model->exam);
     $exam->save();
     return $this;
 }