Пример #1
0
 public function question($id, QuestionRequest $request)
 {
     if ($request->correct1 + $request->correct2 + $request->correct3 + $request->correct4 + $request->correct5 == null) {
         return redirect()->back()->withErrors(['There must be at least one correct answer.'])->withInput()->with('id', $id);
     }
     $course = Course::findorFail($id);
     $test = Test::where('course_id', '=', $course->id)->firstOrFail();
     $question = $test->questions()->create($request->all());
     $question->save();
     $this->evaluate($question, $question->test()->first());
     if ($course->done == 1) {
         Session::flash('qu_add', 'alt');
         return redirect('/exam/' . $course->id . '/edit');
     }
     Session::flash('question_or_finish', 'alt');
     return redirect('getQuestion/' . $id);
 }