public function actionPlayEnd() { $userId = Yii::$app->user->id; $chapterId = Yii::$app->request->post('courseId'); $userPlayModel = new UserPlay(); $userPlayModel = $userPlayModel->findOneLearnModel($userId, $chapterId); $userPlayModel->learn_status = $userPlayModel::LEARN_STATUS_FINISH; if (!Nut::isGetNut($userId, $chapterId)) { Nut::addData($userId, $chapterId); } if ($userPlayModel->save()) { echo Json::encode('true'); return; } else { echo Json::encode('false'); return; } }