123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- /**
- * Created by north.Deng's MAC
- * User: north.Deng
- * Date: 2018/5/4
- * Time: 上午10:15
- * description :
- */
- class QuestionController extends AdminController {
- public function actionIndex()
- {
- $this->render('index',array(
- ));
- }
- public function actionList()
- {
- $pageParams = CommonFn::getPageParams();
- $status = intval(Yii::app()->request->getParam('status', 100));
- $criteria = new EMongoCriteria($pageParams);
- /*if ($status != 100 ) {
- $criteria->status('==',$status);
- }*/
- $cursor = Question::model()->findAll($criteria);
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = Question::model()->parse($rows);
- $total = $cursor->count();
- echo CommonFn::composeDatagridData($parsedRows, $total);
- }
- public function actionEdit()
- {
- $id = Yii::app()->request->getParam('id','');
- $title = Yii::app()->request->getParam('title','');
- $questions = Yii::app()->request->getParam('questions','');
- $question = Question::get(new MongoId($id));
- if (!empty($title)) {
- $question->title = $title;
- }
- if (!empty($questions)) {
- $data = array();
- foreach ($questions as $key => $value) {
- if ($key == 4) {
- $data['result'] = $value;
- } else {
- $data['question'][] = $value;
- }
- }
- $question->question = $data;
- }
- $question->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- public function actionAdd()
- {
- $title = Yii::app()->request->getParam('title','');
- $questions = Yii::app()->request->getParam('questions','');
- $data =array();
- foreach ($questions as $key => $value) {
- if (empty($value)) {
- CommonFn::requestAjax(false,'题目不能为空');exit;
- }
- if ($key == 4) {
- $data['result'] = $value;
- } else {
- $data['question'][] = $value;
- }
- }
- $question = new Question();
- $question->title = $title;
- $question->question = $data;
- $question->save();
- CommonFn::requestAjax(true,'保存成功');exit;
- }
- }
|