/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $modal = new soal();
     $modal->destroy($id);
     return redirect('soal');
 }
 public function selesai(Request $request)
 {
     $user = $this->getAll();
     $benar = 0;
     $n = 0;
     $id_materi;
     foreach ($request->kd as $k) {
         $jawaban_benar = soal::select('jawaban', 'kd_materi')->where('kd_soal', $k)->first();
         $jawaban_user = soal_temp::select('jawaban')->where('kd_soal', $k)->where('username', $user->username)->first();
         $b = $jawaban_benar->jawaban;
         $u = $jawaban_user->jawaban;
         $b == $u ? $benar++ : "";
         $n++;
         $id_materi = $jawaban_benar->kd_materi;
     }
     $log = user_log::find($request->id_log);
     $log->status = 1;
     $log->save();
     soal_temp::where('username', $user->username)->delete();
     $wktumateri = user_log::getWaktu($id_materi, $user->username, 'M');
     $wktuLatihan = user_log::getWaktu($id_materi, $user->username, 'L');
     $nilai = $benar / $n * 100;
     /*echo "waktu mempelajari materi : ".$wktumateri->waktu."detik <br>";
       echo "waktu mengerjakan Latihan : ".$wktuLatihan->waktu."detik <br>";
       echo "waktu mengerjakan Quiz : ".$wktuQuiz->waktu."detik <br>";
       echo "Nilai Quiz : ".$nilai."<br>";
       */
     $wMateriCepat = $this->cepat($wktumateri->waktu, 20000, 10000);
     $wMateriLambat = $this->lambat($wktumateri->waktu, 20000, 10000);
     $WlatihanCepat = $this->cepat($wktuLatihan->waktu, 20000, 13000);
     $WlatihanLambat = $this->lambat($wktuLatihan->waktu, 20000, 13000);
     $nTinggi = $this->nilaiTinggi($nilai, 65, 100);
     $nRendah = $this->nilaiRendah($nilai, 75);
     // R1 materi cepat dan latihan cepat dan quiz tinggi maka lanjut
     $a1 = $this->carimin(array($wMateriCepat, $WlatihanCepat, $nTinggi));
     $z1 = $this->zlanjut(100, 70, $a1);
     // R2 materi cepat dan latihan cepat dan quiz rendah maka lanjut
     $a2 = $this->carimin(array($wMateriCepat, $WlatihanCepat, $nRendah));
     $z2 = $this->zlanjut(100, 70, $a2);
     // R3 materi cepat dan latihan lambat dan quiz tinggi maka lanjut
     $a3 = $this->carimin(array($wMateriCepat, $WlatihanLambat, $nTinggi));
     $z3 = $this->zlanjut(100, 70, $a3);
     // R4 materi cepat dan latihan lambat dan quiz rendah maka tetap
     $a4 = $this->carimin(array($wMateriCepat, $WlatihanLambat, $nRendah));
     $z4 = $this->ztetap(69, $a4);
     // R5 materi lambat dan latihan cepat dan quiz tinggi maka lanjut
     $a5 = $this->carimin(array($wMateriLambat, $WlatihanCepat, $nTinggi));
     $z5 = $this->zlanjut(100, 70, $a5);
     // R6 materi lambat dan latihan cepat dan quiz rendah maka tetap
     $a6 = $this->carimin(array($wMateriLambat, $WlatihanCepat, $nRendah));
     $z6 = $this->ztetap(69, $a6);
     // R7 materi lambat dan latihan lambat dan quiz tinggi maka lanjut
     $a7 = $this->carimin(array($wMateriLambat, $WlatihanLambat, $nTinggi));
     $z7 = $this->zlanjut(100, 70, $a7);
     // R8 materi lambat dan latihan lambat dan quiz rendah maka tetap
     $a8 = $this->carimin(array($wMateriLambat, $WlatihanLambat, $nRendah));
     $z8 = $this->ztetap(69, $a8);
     $az = $a1 * $z1 + $a2 * $z2 + $a3 * $z3 + $a4 * $z4 + $a5 * $z5 + $a6 * $z6 + $a7 * $z7 + $a8 * $z8;
     $a = $a1 + $a2 + $a3 + $a4 + $a5 + $a6 + $a7 + $a8;
     $ztot = $az / $a;
     $param = array('z' => $ztot, 'wm' => $wktumateri->waktu, 'nilai' => $nilai, 'wl' => $wktuLatihan->waktu, 'kd_materi' => $id_materi, 'judul' => materimodel::where('kd_materi', $id_materi)->first());
     $this->update_user($param);
     return view('mhs.UserHasilQuiz', $param);
 }