Beispiel #1
0
 /**
  * Creates a new Quiz model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Quiz();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 /**
  * Creates a new Quiz model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Quiz();
     $quizQuestion = new QuizQuestions();
     $quizResults = new QuizResults();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($quizQuestion->saveQuizQuestions(Yii::$app->request->post('question'), $model['id'])) {
             if ($quizResults->saveQuizResults($model['id'], Yii::$app->request->post('results'))) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }