Exemplo n.º 1
0
 public function actionGetQuestionData($question_id)
 {
     $request = Yii::$app->request;
     if (!$request->isAjax) {
         throw new BadRequestHttpException();
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = Question::find()->where(['id' => $question_id])->andWhere(['<>', 'type', 'text'])->with('answerVariants')->one();
     if (!$model) {
         throw new NotFoundHttpException();
     }
     return ['question' => $model, 'answerVariants' => $model->answerVariants];
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Question::find()->where(['list_id' => $params['list_id']]);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'quest_text', $this->quest_text]);
     return $dataProvider;
 }
Exemplo n.º 3
0
?>

    <?php 
echo $form->field($model, 'ordering')->textInput(['type' => 'number']);
?>

    <?php 
echo $form->field($model, 'quest_text')->textArea(['maxlength' => true]);
?>

    <div id="visible_condition_block" class="panel panel-default">
        <div class="panel-heading"><h4><i class="glyphicon glyphicon-eye-open"></i> Условие видимости</h4></div>
        <div class="panel-body">
            <div class="col-md-6 col-sm-10">
                <?php 
$query = Question::find()->where(['list_id' => $list_id]);
$query->andWhere(['<>', 'type', 'text']);
// Если вопрос изменяется, то исключим его из выбора вопроса, связаного условием
if ($model->id) {
    $query->andWhere(['<>', 'id', $model->id]);
}
$questionsInList = ArrayHelper::map($query->all(), 'id', 'quest_text');
?>
                <?php 
echo $form->field($model, "visible_condition")->dropDownList($questionsInList, ['prompt' => 'Нет']);
?>
            </div>
            <div class="col-md-6 col-sm-10">
                <?php 
echo $form->field($model, 'visible_condition_value')->hiddenInput(['maxlength' => true]);
?>