public function correctSpecialQuiz($id)
 {
     $specialquiz = Specialquiz::find($id);
     $date = sprintf('%02d', $specialquiz->day) . '/' . sprintf('%02d', $specialquiz->month) . '/' . $specialquiz->year;
     $specialquestions = Specialquestion::where('quiz_id', $id)->get();
     $answers = [];
     foreach ($specialquestions as $key => $specialquestion) {
         $answers[$specialquestion->id] = Specialanswer::where('question_id', $specialquestion->id)->where('submitted', 1)->get();
     }
     return view('admin/correctSpecialQuiz')->with(['questions' => $specialquestions, 'answers' => $answers, 'date' => $date]);
 }
 public function submitSpecialQuiz(Request $request)
 {
     $input = $request->all();
     $inputs = [];
     foreach ($input as $key => $value) {
         if (substr($key, 0, strlen('answer')) === 'answer') {
             $inputs[$key] = 'required';
             $question_id = explode('_', $key)[1];
         }
     }
     $inputs['banker'] = ['max:5'];
     $this->validate($request, $inputs);
     $year = date('Y');
     $month = date('n');
     $day = date('j');
     $user_id = Auth::user()->id;
     foreach ($inputs as $key => $validation) {
         if (substr($key, 0, strlen('answer')) === 'answer') {
             $question_id = explode('_', $key)[1];
             $specialquestion = Specialquestion::find($question_id);
             $specialquiz = Specialquiz::find($specialquestion->quiz_id);
             if (!($specialquiz->year == $year && $specialquiz->month == $month && $specialquiz->day == $day)) {
                 return redirect()->route('specialquiz');
             }
             $answer = Specialanswer::where('question_id', $question_id)->where('user_id', $user_id)->where('submitted', 1)->get();
             if (isset($input['banker']) && in_array($question_id, $input['banker'])) {
                 $banker = 1;
             } else {
                 $banker = 0;
             }
             if (!count($answer)) {
                 Specialanswer::create(['question_id' => $question_id, 'user_id' => $user_id, 'answer' => $input[$key], 'banker' => $banker, 'submitted' => 1]);
             }
         }
     }
     return redirect()->route('specialquiz');
 }