public function show($id) { $user = $this->getAll(); $cek = soal_temp::where('username', $user->username)->first(); if ($cek == null) { $ambil_soal = soal::where('kd_materi', $id)->orderByRaw("RAND()")->take(25)->get(); foreach ($ambil_soal as $data) { $simpan = array('kd_soal' => $data->kd_soal, 'kd_materi' => $data->kd_materi, 'pertanyaan' => $data->pertanyaan, 'jawab_a' => $data->jawab_a, 'jawab_b' => $data->jawab_b, 'jawab_c' => $data->jawab_c, 'jawab_d' => $data->jawab_d, 'username' => $user->username); $materi = $data->kd_materi; soal_temp::create($simpan); } $log = array('username' => $user->username, 'kd_materi' => $id, 'kd_belajar' => 'Q', 'skor' => 0, 'status' => 0); user_log::create($log); } else { $materi = $cek->kd_materi; } soal_temp::where('username', $user->username)->get(); $materi = materimodel::select('judul_materi')->where('kd_materi', $materi)->first(); $waktu = user_log::select('created_at', 'id')->where('kd_materi', $id)->where('kd_belajar', 'Q')->where('username', $user->username)->where('status', 0)->first(); $soal = array('soal' => soal_temp::where('username', $user->username)->get(), 'judul' => $materi->judul_materi, 'id_log' => $waktu->id, 'waktu' => date_add($waktu->created_at, date_interval_create_from_date_string("60 MINUTES"))); return view('mhs/quiz_view', $soal); }