public function actionIndex() { //unset($_SESSION['qt_list']); //unset($_SESSION['thread']); $params = array(); $completed = 0; $point = 0; $sharePoint = false; $rankThread = null; $msg = ""; $userSub = $this->userSub; $currDate = date('Y-m-d'); $userPhone = yii::app()->user->getState('msisdn'); /* if($userSub){ */ $countPlayByDate = GameEventThreadModel::countPlayByDate($userPhone, $currDate); if ($countPlayByDate <= 10) { //tạo session câu hỏi lần đầu tiên tham gia //if(!isset($_SESSION['qt_list']) && !isset($_SESSION['thread']) && $countPlayByDate==0){ if ($countPlayByDate == 0 && !isset($_SESSION['thread'])) { $newThread = GameEventThreadModel::getNewRandomThread($userPhone); if ($newThread) { $questionList = GameEventThreadModel::getQuestionsByThread($newThread); $qtList = array(); foreach ($questionList as $key => $value) { $qtList[] = $value['id']; } $_SESSION['qt_list'] = $qtList; $_SESSION['thread'] = $newThread; $_SESSION['count'] = 1; } else { //het 10 bo cau hoi $completed = 1; $msg = 'Bạn đã hoàn thành trả lời 10 bộ câu hỏi event 8/3.'; } //echo '<pre>';print_r($questionList); } //tra loi tiep theo if (isset($_SESSION['qt_list']) && isset($_SESSION['thread'])) { if (count($_SESSION['qt_list']) == 0) { $completed = 2; $msg = 'Bạn đã hoàn thành trả lời câu hỏi ngày hôm nay.'; $sharePoint = true; $isShare = GameEventActivityModel::isShareOnDay($userPhone, date('Y-m-d')); if ($isShare) { $sharePoint = false; } $point = GameEventUserLogModel::model()->getPoint($userPhone, $_SESSION['thread']); $rankThread = GameEventReportDayModel::model()->getRankByThread($_SESSION['thread']); } else { $qtList = $_SESSION['qt_list']; $maxQt = count($qtList) - 1; $indexRand = rand(0, $maxQt); $qtChosen = $qtList[$indexRand]; if (isset($_GET['notrep']) && $_GET['notrep'] == 1 && isset($_GET['askid']) && $_GET['askid'] > 0) { if (in_array($_GET['askid'], $qtList)) { $qtChosen = $_GET['askid']; } } $question = GameEventQuestionModel::model()->findByPk($qtChosen); $answer = GameEventAnswerModel::model()->findAllByAttributes(array('ask_id' => $qtChosen)); $_SESSION['startTime'] = date('Y-m-d H:i:s'); $params = array('question' => $question, 'answer' => $answer); } } else { $completed = 3; $msg = 'Bạn đã tham gia trả lời câu hỏi ngày hôm nay.'; } } else { //da choi ngay hom nay $completed = 4; $msg = 'Bạn đã tham gia trả lời câu hỏi ngày hôm nay.'; } /* }else{ $this->redirect('/event/register'); Yii::app()->end(); } */ $params['completed'] = $completed; $params['sharePoint'] = $sharePoint; $params['point'] = $point; $params['userSub'] = $userSub; $params['msg'] = $msg; $params['rankThread'] = $rankThread; $this->render('index', $params); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = GameEventReportDayModel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }