public function saveKuis()
 {
     $data = Input::all();
     echo "<pre>";
     $rules = ['kode_pertanyaan' => 'required', 'kritiksaran' => 'required', 'idjadwal' => 'required'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('mahasiswa/kuesioner')->with('msge', $validator->messages());
     } else {
         $counter = 0;
         # validasi pengisian 2 kali
         $input = Input::get('idjadwal');
         $ceksoal = DB::table('Pertanyaan')->count();
         $cek = DB::table('Jawaban')->where('idjadwal', '=', $input)->count();
         if ($cek >= $ceksoal) {
             return Redirect::to('mahasiswa/kuesioner')->with('msge', 'Maaf....<br>Anda sudah pernah mengisi kuesioner matakuliah tersebut.');
         } else {
             foreach ($data['kode_pertanyaan'] as $key => $value) {
                 $datakuis = array('kode_pertanyaan' => $value, 'jawabanganda' => isset($data['jawabanganda'][$key]) ? $data['jawabanganda'][$key] : 5, 'tanggal_pengisian' => \Carbon\Carbon::now(), 'kritiksaran' => Input::get('kritiksaran'), 'idjadwal' => trim(Input::get('idjadwal')));
                 $tambah = Jawaban::create($datakuis);
                 if ($tambah) {
                     $counter++;
                 }
             }
         }
         if ($counter > 0) {
             Session::flash('msgs', 'Terimah Kasih<br> Anda telah mengisi kuesioner PBM!');
         } else {
             Session::flash('msge', 'Maaf....<br>, silahkan mencoba kembali dan perhatikan ketentuan yang berlaku');
         }
         return Redirect::to('mahasiswa/kuesioner');
     }
 }
예제 #2
0
 public function tambahpoll(CookieJar $cookieJar, Request $request)
 {
     $input = $request->except('_token');
     $update = Models\Jawaban::where('id_soal_poll', $input['id_soal_poll'])->where('jawaban', $input['jawaban'])->first();
     $update->counter = $update->counter + 1;
     $update->update();
     $cookieJar->queue(cookie('polling', 'sudah', 45000));
     return redirect()->to('lihatpoll');
 }
예제 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($poll_id, $id)
 {
     //
     $jawaban = Jawaban::find($id);
     if ($jawaban->delete()) {
         return response()->json(array('success' => TRUE));
     }
 }