/** * List questions. * * @return Response */ public function Exam(Section\Section $section) { if ($section->examPassed()) { $next = $section->next(); if (count($next) > 0) { if (!in_array($next->id(), auth()->user()->sections()->lists('id')->toArray()) && !auth()->user()->isAdmin() && !$section->course->isAuthTeacher()) { auth()->user()->sections()->attach($next); } return redirect()->route('front.section', [$next->course, $next, $next->slug()]); } return redirect()->route('front.section', [$section->course, $section, $section->slug()]); } return view('Front::section.exam', ['section' => $section, 'questions' => $section->questions]); }
public function postOpenSection(Section\Section $section) { // if($section->hasQuestions() && $section->examNotPassed()) // { // $answers = auth()->user()->answers()->where('section_id', '=', $section->id()); // if(count($answers->get()) > 0) // { // $wrongs = $answers->where('answer', '=', 0)->get(); // auth()->user()->answers()->sync([]); // if(count($wrongs) == 0) // { // auth()->user()->sections()->sync([$section->id => ['passed' => true]], false); // } // else // { // auth()->user()->sections()->sync([$section->id => ['failed_at' => \Carbon\Carbon::now()->addHour()->format('Y-m-d H:i:s')]], false); // } // } // return redirect()->route('front.section.exam', $section); // } $next = $section->next(); if (count($next) > 0) { // if(!in_array($next->id(), auth()->user()->sections()->lists('id')->toArray()) && !auth()->user()->isAdmin() && !$section->course->isAuthTeacher()) // auth()->user()->sections()->attach($next); return redirect()->route('front.section', [$next->course, $next, $next->slug()]); } return redirect()->route('front.section', [$section->course, $section, $section->slug()]); }