From 196d25362ee32ce5df10c08b1dadb87a76812fa7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 5 Dec 2019 11:36:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E8=AE=BE=E7=BD=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weapps/homework_commons_controller.rb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/controllers/weapps/homework_commons_controller.rb diff --git a/app/controllers/weapps/homework_commons_controller.rb b/app/controllers/weapps/homework_commons_controller.rb new file mode 100644 index 000000000..00d2ce926 --- /dev/null +++ b/app/controllers/weapps/homework_commons_controller.rb @@ -0,0 +1,37 @@ +class Weapps::HomeworkCommonsController < Weapps::BaseController + before_action :require_login + before_action :find_homework, :user_course_identity + before_action :teacher_allowed + + def update_settings + begin + # 课堂结束后不能再更新 + if @course.is_end + UpdateHomeworkSettingService.call(@homework, publish_params) + else + tip_exception("课堂已结束不能再更新") + end + rescue Exception => e + uid_logger(e.backtrace) + tip_exception(e.message) + raise ActiveRecord::Rollback + end + end + + private + + def teacher_allowed + return render_forbidden unless @user_course_identity < Course::STUDENT + end + + def find_homework + @homework = HomeworkCommon.find_by!(id: params[:id]) + @course = @homework.course + @homework_detail_manual = @homework.homework_detail_manual + end + + def publish_params + params.permit(:unified_setting, :publish_time, :end_time, group_settings: []) + end + +end \ No newline at end of file