/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $studentEvidenceStatus, $student = true)
 {
     $dataArray = ['student_evidence.status' => $studentEvidenceStatus, 'task.name' => $this->task_name, 'task.delivery_data' => $this->task_delivery_date];
     if ($student) {
         $dataArray['student.user_id'] = Yii::$app->user->id;
     } else {
         $dataArray['project.manager_id'] = 2;
     }
     $query = StudentEvidence::find();
     $query->joinWith(['evidence', 'task', 'project', 'student']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere($dataArray);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStudentEvidences()
 {
     return $this->hasMany(StudentEvidence::className(), ['task_id' => 'id']);
 }
 /**
  * Finds the StudentEvidence model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $taskId
  * @param integer $projectId
  * @param integer $evidenceId
  * @param integer $studentId
  * @return StudentEvidence the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($taskId, $projectId, $evidenceId, $studentId)
 {
     if (($model = StudentEvidence::findOne(['taskId' => $taskId, 'projectId' => $projectId, 'evidenceId' => $evidenceId, 'studentId' => $studentId])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 /**
  * Downloads selected file
  * @param $evidenceId
  */
 public function actionDownload($evidenceId)
 {
     $studentEvidence = StudentEvidence::find()->where("evidence_id=" . $evidenceId)->one();
     return Yii::$app->response->sendFile(Yii::getAlias('@webroot') . $studentEvidence->evidence->attachment_path, $studentEvidence->evidence->attachment_name)->send();
 }
 /**
  * @param $evidence_id
  * @return null|static
  * @throws NotFoundHttpException
  */
 protected function findModelByEvidence($evidence_id)
 {
     if (($model = StudentEvidence::findOne(['evidence_id' => $evidence_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }