diff --git a/app/api/mobile/apis/homeworks.rb b/app/api/mobile/apis/homeworks.rb index dd6708b22..a7bb544af 100644 --- a/app/api/mobile/apis/homeworks.rb +++ b/app/api/mobile/apis/homeworks.rb @@ -35,7 +35,7 @@ module Mobile params do requires :token, type: String end - post ':id/alert_homework_anonymous_comment' do + post ':id/start_anonymous_comment' do statue = Homeworks.get_service.start_anonymous_comment params,current_user.nil? ? User.find(2):current_user messages = "" case statue @@ -50,6 +50,15 @@ module Mobile present :status, statue end + desc "关闭匿评" + params do + requires :token, type: String + end + post ':id/stop_anonymous_comment' do + Homeworks.get_service.stop_anonymous_comment params,current_user.nil? ? User.find(2):current_user + present :status, 0 + end + end end end diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index a659b167d..fe4b77404 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -86,6 +86,15 @@ class HomeworkService end @statue end + #关闭匿评 + def stop_anonymous_comment params,current_user + @bid = Bid.find(params[:id]) + @course = @bid.courses.first + unless is_course_teacher(current_user,@course) || current_user.admin? + raise '403' + end + @bid.update_column('comment_status', 2) + end # 匿评作品详情 # attachs 该作品的所有附件