コード例 #1
0
 protected function findModelByExercise($id, $gid)
 {
     if (($model = CompleteExercise::find()->where(['exercise_id' => $id])->andWhere(['given_task_id' => $gid])->one()) !== null) {
         return $model;
     } else {
         return false;
     }
 }
コード例 #2
0
 /**
  * 
  */
 public function actionCheck($id)
 {
     $model = $this->findModel($id);
     $givenTask = $model->givenTask;
     if ($model->load(Yii::$app->request->post()) && $model->save() && $givenTask->load(Yii::$app->request->post()) && $givenTask->save()) {
         // return $this->redirect(['view', 'id' => $givenTask->status]);
     }
     $exersices_all = CompleteExercise::find()->indexBy('id')->all();
     if (Model::loadMultiple($exersices_all, Yii::$app->request->post()) && Model::validateMultiple($exersices_all)) {
         foreach ($exersices_all as $exersice) {
             if ($givenTask->status == 3) {
                 $exersice->remake = 0;
             }
             $exersice->save(false);
         }
         return $this->redirect('given-list');
     }
     $model = CompleteTask::findOne($id);
     $exersices = $model->completeExersices;
     return $this->renderAjax('_check_form', ['model' => $model, 'exersices' => $exersices, 'givenTask' => $givenTask]);
 }
コード例 #3
0
ファイル: CompleteTask.php プロジェクト: mrhat24/site-for-pm
 public function getCompleteExersices()
 {
     return $this->hasMany(CompleteExercise::className(), ['given_task_id' => 'given_task_id']);
 }