public function getAllByIds($ids) { $questions = array(); $arrIds = explode(",", $ids); $cr = new CDbCriteria(); $cr->addInCondition('id', $arrIds); $questions = GameEventQuestionModel::model()->published()->findAll($cr); return $questions; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $questions = GameEventQuestionModel::model()->findAllByAttributes(array('status' => 1), array('order' => 'id DESC')); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['GameEventThreadModel'])) { $model->attributes = $_POST['GameEventThreadModel']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'questions' => $questions)); }
<?php $types = array('text' => Yii::t('admin', 'text'), 'image' => Yii::t('admin', 'image')); echo CHtml::dropDownList("GameEventQuestionModel[type]", !$model->isNewRecord ? $model->type : 'text', $types, array("onchange" => "changeType(this)")); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'Trạng thái'); ?> <?php $status = array(1 => Yii::t('admin', 'Hiển thị'), 0 => Yii::t('admin', 'Không hiển thị')); echo CHtml::dropDownList("GameEventQuestionModel[status]", !$model->isNewRecord ? GameEventQuestionModel::model()->findByPk($model->id)->status : 1, $status); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'level'); ?> <?php echo $form->textField($model, 'level'); ?> <?php echo $form->error($model, 'level'); ?> </div> <div id='type_text' style="<?php
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'); }
public function actionAddQuestion() { $flag = true; $threadId = Yii::app()->request->getParam('thread_id', ""); if (Yii::app()->getRequest()->ispostRequest) { $flag = false; $questionList = $_POST['cid']; $model = GameEventThreadModel::model()->findByPk($threadId); $oldQuestionList = explode(',', $model['question_list']); $newQuestionList = $model['question_list'] ? ',' . $model['question_list'] : ''; foreach ($questionList as $question) { $newQuestionList .= in_array($question, $oldQuestionList) ? '' : ',' . $question; } $newQuestionList = $newQuestionList != '' ? substr($newQuestionList, 1) : ''; $model->question_list = $newQuestionList; $model->save(); //AdminCollectionItemModel::model()->addList($this->userId, $collect_id, $albumList, 'album'); } if ($flag) { Yii::app()->user->setState('pageSize', 20); $questionModel = new GameEventQuestionModel(); $questionModel->unsetAttributes(); if (isset($_GET['GameEventQuestionModel'])) { $questionModel->attributes = $_GET['GameEventQuestionModel']; } $questionModel->setAttributes(array('status' => GameEventQuestionModel::PUBLISHED)); Yii::app()->clientScript->scriptMap['jquery.js'] = false; $this->renderPartial('addQuestion', array('questionModel' => $questionModel, 'thread_id' => $threadId), false, true); } }