コード例 #1
0
 /**
  * Creates a new StudentEvidence model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($task_id, $project_id, $student_id)
 {
     $studentEvidence = $this->findModelWithoutEvidence($task_id, $project_id, $student_id);
     $evidence = new Evidence();
     if (Yii::$app->request->post()) {
         $params = Yii::$app->request->post();
         $evidence->load($params);
         //Cambiar estado de evidencia a pendiente
         $studentEvidence->status = StudentEvidence::$PENDING;
         $evidence->file = UploadedFile::getInstance($evidence, 'file');
         if ($evidence->validate() && $evidence->save()) {
             $this->saveEvidenceFile($evidence);
             $evidence->update(false);
             $studentEvidence->evidence_id = $evidence->id;
             $studentEvidence->update();
             $notification = Yii::createObject(['class' => Notification::className(), 'user_id' => ProjectManager::findOne([Project::findOne([$project_id])->manager_id])->user_id, 'description' => Notification::RECEIVED_TASK, 'role' => Notification::ROLE_STUDENT, 'created_at' => Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'), 'viewed' => false, 'url' => Url::to(['/project_manager/task/show-feedback-screen', 'taskId' => $task_id, 'evidenceId' => $evidence->id])]);
             $notification->save(false);
             return $this->redirect(['view', 'task_id' => $studentEvidence->task_id, 'project_id' => $studentEvidence->project_id, 'student_id' => $studentEvidence->student_id]);
         } else {
             Yii::$app->session->setFlash('danger', 'Ocurrió un error al guardar. Vuelve a intentar');
             echo $evidence->validate();
             return $this->render('create', ['studentEvidence' => $studentEvidence, 'evidence' => $evidence]);
         }
     } else {
         return $this->render('create', ['studentEvidence' => $studentEvidence, 'evidence' => $evidence]);
     }
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Evidence::find();
     //$query->joinWith(['studentEvidences']);
     $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, 'accepted_date' => $this->accepted_date, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'attachment_path', $this->attachment_path])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
コード例 #3
0
 /**
  * Shows feedback screen for the selected task
  * @param $taskId
  * @param $evidenceId
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionShowFeedbackScreen($taskId, $evidenceId)
 {
     return $this->render('feedback', ['model' => $this->findModel($taskId), 'evidence' => Evidence::find()->where("id=" . $evidenceId)->one()]);
 }
コード例 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEvidence()
 {
     return $this->hasOne(Evidence::className(), ['id' => 'evidence_id']);
 }