/**
  * Copy record
  * If copy is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be copy
  */
 public function actionCopy($id)
 {
     $data = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['GameEventUserLogModel'])) {
         $model = new GameEventUserLogModel();
         $model->attributes = $_POST['GameEventUserLogModel'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('copy', array('model' => $data));
 }
Example #2
0
 public function actionAnswer()
 {
     if (Yii::app()->request->isPostRequest) {
         $userPhone = yii::app()->user->getState('msisdn');
         $ansId = $_POST['answer'];
         if (empty($ansId)) {
             //khong chon cau tra loi
             $redirect = Yii::app()->createUrl('/event/play', array('notrep' => 1, 'askid' => $_POST['askid']));
             $this->redirect($redirect);
             Yii::app()->end();
         }
         $resAnswer = GameEventAnswerModel::model()->findByPk($ansId);
         if ($resAnswer->is_true) {
             $point = GameEventQuestionModel::model()->findByPk($_POST['askid'])->point;
         } else {
             $point = 0;
         }
         $completedTime = date('Y-m-d H:i:s');
         $gameEventLog = new GameEventUserLogModel();
         $gameEventLog->setAttribute('user_phone', $userPhone);
         $gameEventLog->setAttribute('ask_id', $_POST['askid']);
         $gameEventLog->setAttribute('answer_id', $ansId);
         $gameEventLog->setAttribute('thread_id', $_SESSION['thread']);
         $gameEventLog->setAttribute('point', $point);
         $gameEventLog->setAttribute('started_datetime', $_SESSION['startTime']);
         $gameEventLog->setAttribute('completed_datetime', $completedTime);
         $gameEventLog->save();
         $this->_removeQuestion($_POST['askid']);
         $_SESSION['count'] += 1;
     }
     $this->redirect('/event/play');
 }