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; }
public function questionList($examid) { $question = ExamQuestion::where('exam_id', $examid)->get(); return $question; }
public function addExamQuestion(array $question) { $exam = new ExamQuestion(); $exam->fill($question); $exam->exam()->associate($this->model->exam); $exam->save(); return $this; }