Exemplo n.º 1
0
 /**
  * Lists all Quiz models.
  * @return mixed
  */
 public function actionIndex()
 {
     if ($skill_id = Yii::$app->request->get('skill_id')) {
         $dataProvider = new ActiveDataProvider(['query' => Quiz::find()->where(['skill_id' => $skill_id])]);
     } else {
         $dataProvider = new ActiveDataProvider(['query' => Quiz::find()]);
     }
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $quiz = Quiz::find($id);
     if (empty($quiz)) {
         Flash::error('Quiz not found');
         return redirect(route('admin.quizzes.index'));
     }
     return view('admin.quizzes.show')->with('quiz', $quiz);
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Quiz::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'description' => $this->description, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Remove the specified Quiz from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     /** @var Quiz $quiz */
     $quiz = Quiz::find($id);
     if (empty($quiz)) {
         Flash::error('Quiz not found');
         return redirect(route('admin.quizzes.index'));
     }
     $quiz->delete();
     Flash::message('Quiz deleted successfully.');
     return redirect(route('admin.quizzes.index'));
 }