/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $way = null) { if ($way == null) { $query = Exercise::find(); } else { $query = $way; } $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('subject'); $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; } $query->andFilterWhere(['id' => $this->id, 'teacher_id' => $this->teacher_id]); $query->andFilterWhere(['like', 'exercise.text', $this->text])->andFilterWhere(['like', 'exercise.name', $this->name])->andFilterWhere(['like', 'exercise_subject.name', $this->subject_id]); return $dataProvider; }
/** * @get exercises */ public function getExercises() { return $this->hasMany(Exercise::className(), ['teacher_id' => 'id']); }
public function getExercise() { return $this->hasOne(Exercise::className(), ['id' => 'exercise_id']); }
/** * Finds the Exercise model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Exercise the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Exercise::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
$.post( "' . Url::to(['//task/exersicespreview', 'list' => '']) . '"+arr, function( data ) { $( "#exersicespreview" ).html( data ); }); '], 'pluginOptions' => ['tags' => true]]); ?> <?php echo Html::tag('br'); ?> <div class="panel panel-default"> <div class='panel-heading'>Список упражнений</div> <div class='panel-body' id="exersicespreview" ><?php $list = ArrayHelper::getColumn($model->exercises, 'exercise.id'); $exersices = \common\models\Exercise::findAll($list); echo $this->render('/task/_exersicespreview', ['exersices' => $exersices]); ?> </div> </div> <?php //= $form->field($model, 'student_id')->listBox(TaskType::typeList(),['onchange' => '$.pjax.reload({container: "#form-give-task"});']) ?> <?php //= $form->field($model, 'text')->textarea(['rows' => 6]) ?> <div class="form-group">
public function actionExersicespreview($list) { $list = GivenTask::listToArray($list); $exersices = \common\models\Exercise::findAll($list); return $this->renderAjax('_exersicespreview', ['exersices' => $exersices]); }