public function searchGradeOne($params)
 {
     $query = GradeOneForm::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'grade_protection' => $this->grade_protection, 'enrolled_id' => $this->enrolled_id, 'grading_period' => $this->grading_period, 'core_value_1' => $this->core_value_1, 'core_value_2' => $this->core_value_2, 'core_value_3' => $this->core_value_3, 'core_value_4' => $this->core_value_4, 'subject_1' => $this->subject_1, 'subject_2' => $this->subject_2, 'subject_3' => $this->subject_3, 'subject_4' => $this->subject_4, 'subject_5' => $this->subject_5, 'subject_6' => $this->subject_6, 'subject_7' => $this->subject_7, 'subject_8' => $this->subject_8])->groupBy('enrolled_id');
     return $dataProvider;
 }
 /**
  * Creates a new EnrolledForm model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $sy = new SchoolYear();
     $model = new EnrolledForm();
     $model->enrollment_status = 1;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', 'New enrollee successfully created!');
         switch ($model->grade_level_id) {
             case 10:
                 //CREATE FOUR GRADINGS
                 for ($i = 1; $i < 5; $i++) {
                     $grade = new GradeOneForm();
                     $grade->grade_protection = 1;
                     $grade->enrolled_id = $model->id;
                     $grade->grading_period = $i;
                     $grade->save();
                 }
                 break;
             default:
                 break;
         }
         Yii::$app->session->setFlash('success', 'New grade form successfully created!');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'sy' => $sy]);
     }
 }
 protected function findGrade($eid)
 {
     if (($model = GradeOneForm::find()->where(['enrolled_id' => $eid])->all()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }