12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * Created by north.Deng's MAC
- * User: north.Deng
- * Date: 2018/5/4
- * Time: 下午12:34
- * description :
- */
- class QuestionController extends JBaseController
- {
- public function actionList()
- {
- /* $tmp = Question::get(new MongoId('5aebc756b292c9171883858a'));
- for ($i=0;$i<20;$i++) {
- $q = new Question();
- $q->title = $tmp->title;
- $q->question = $tmp->question;
- $q->save();
- }*/
- $pageParams = CommonFn::getPageParams();
- $cursor = Question::model()->findAll();
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = Question::model()->parse($rows);
- $total = $cursor->count();
- if ($total > 10) {
- $offset = rand(0,$total-10);
- $limit = 10;
- $pageParams['offset'] = $offset;
- $pageParams['limit'] = $limit;
- $criteria = new EMongoCriteria($pageParams);
- $cursor = Question::model()->findAll($criteria);
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = Question::model()->parse($rows);
- $total = $cursor->count();
- }
- echo CommonFn::composeDatagridData($parsedRows, $total);
- }
- public function actionResult()
- {
- $user_id = Yii::app()->request->getParam('id','');
- $score = Yii::app()->request->getParam('score','');
- $jgemp = JGEmploye::get(new MongoId($user_id));
- if (!empty($jgemp)) {
- $jgemp->score = $score;
- $jgemp->degree -= 1;
- $jgemp->save();
- }
- CommonFn::requestAjax(true, '答题完毕', array());
- }
- }
|