Beispiel #1
0
 public function getQuiz()
 {
     $criteria = new CDbCriteria();
     $criteria->join = "left join ew_lesson l on  l.mediaId=t.id";
     $criteria->condition = "l.mediaType='quiz' and l.id=" . intval($this->id);
     $quiz = Quiz::model()->find($criteria);
     return $quiz;
 }
Beispiel #2
0
 public function getNewestQuizzesInCategory($category)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "category = '" . $category . "'";
     $criteria->order = 'created_at DESC';
     $data = Quiz::model()->findAll($criteria);
     return $data;
 }
Beispiel #3
0
 public function actionDeleteRatingQuiz()
 {
     $request = Yii::app()->request;
     try {
         $id = StringHelper::filterString($request->getPost('id'));
         if (Quiz::model()->delelteRatingQuiz($id)) {
             ResponseHelper::JsonReturnSuccess('');
         } else {
             ResponseHelper::JsonReturnError('');
         }
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage());
     }
 }
Beispiel #4
0
 protected function loadModel($id)
 {
     /**
      * TODO или сделать в один запрос?
      */
     $criteria = new CDbCriteria();
     $criteria->compare('t.active', Quiz::STATUS_ACTIVE);
     /** @var $quiz Quiz */
     $quiz = Quiz::model()->findByPk($id, $criteria);
     if ($quiz === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $criteria = new CDbCriteria(array('with' => 'answers', 'order' => 't.sequence ASC, answers.sequence ASC'));
     $criteria->compare('t.id_quiz', $id);
     $questions = QuizQuestion::model()->findAll($criteria);
     if (empty($questions)) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $quiz->addRelatedRecord('questions', $questions, false);
     return $quiz;
 }
 /**
  * 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 = Quiz::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #6
0
 public function actionGetCategories()
 {
     $data = Quiz::model()->getCategories();
     ResponseHelper::JsonReturnSuccess($data);
 }