/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SubjectSection::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['SubjectSectionId' => $this->SubjectSectionId, 'SectionType' => $this->SectionType, 'SectionName' => $this->SectionName, 'SubjectId' => $this->SubjectId]); return $dataProvider; }
<div class="col-xs-12 col-sm-12 col-md-3 col-md-push-6 col-lg-3 col-lg-push-6"> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-md-pull-3 col-lg-6 col-lg-pull-3"> <h4>Exams</h3> <ul class="list-group"> <li class="list-group-item"> <?php foreach ($exams as $exam) { ?> <?php $section = SubjectSection::findOne(['SubjectSectionId' => $exam->SubjectSectionId]); if (Yii::$app->user->identity->ClassSection == $section->SectionName) { if ($exam->IsActive) { echo '<a href="index.php?r=site%2Fexam&id=' . $exam->ExamId . '"><h4>' . $exam->Description . '</h4></a> created by ' . $exam->CreatedBy; } else { echo '<a>' . $exam->Description . '</a>'; } } ?> <br /> <?php } ?> </li> </ul> </div>
/** * Finds the Posts model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Posts the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SubjectSection::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
?> <?php echo $form->field($model, 'MaxScore')->textInput(['type' => 'number']); ?> <?php echo $form->field($model, 'NumQuestions')->textInput(['type' => 'number']); ?> <?php echo $form->field($model, 'IsActive')->textInput(['type' => 'number']); ?> <?php $sections = SubjectSection::find()->where(['SectionType' => 'Laboratory'])->all(); $items = array(); foreach ($sections as $section) { $items[$section->SubjectSectionId . ''] = $section->SectionName; } ?> <?php echo $form->field($model, 'SubjectSectionId')->dropDownList($items); ?> <div class="form-group"> <?php
/** * @return \yii\db\ActiveQuery */ public function getSubjectSection() { return $this->hasMany(SubjectSection::className(), ['SubjectId' => 'SubjectId']); }
/** * @return \yii\db\ActiveQuery */ public function getUsers() { return $this->hasMany(SubjectSection::className(), ['UserId' => 'UserId']); }