diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 03acd76cc..e4dffec23 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -40,6 +40,8 @@ class Users::VideosController < Users::BaseController def batch_publish Videos::BatchPublishService.call(observed_user, batch_publish_params) render_ok + rescue Videos::BatchPublishService::Error => ex + render_error(ex.message) end private diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 33e40ee52..d57edf497 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -8,7 +8,7 @@ class CourseGroup < ApplicationRecord has_many :homework_group_reviews, :dependent => :destroy scope :by_group_ids, lambda { |ids| where(id: ids)} - validates :name, length: { maximum: 20 } + validates :name, length: { maximum: 60 } after_create :generate_invite_code diff --git a/app/services/videos/batch_publish_service.rb b/app/services/videos/batch_publish_service.rb index 3ff16dc57..e435b9508 100644 --- a/app/services/videos/batch_publish_service.rb +++ b/app/services/videos/batch_publish_service.rb @@ -1,4 +1,6 @@ class Videos::BatchPublishService < ApplicationService + Error = Class.new(StandardError) + attr_reader :user, :params def initialize(user, params) @@ -16,6 +18,8 @@ class Videos::BatchPublishService < ApplicationService video = user.videos.find_by(uuid: param[:video_id]) next if video.blank? || video.processing_video_apply.present? + raise Error, '视频还未上传完成' if video.vod_uploading? + video.title = param[:title].to_s.strip.presence || video.title video.apply_publish video.save! diff --git a/app/views/exercise_questions/_exercise_questions.json.jbuilder b/app/views/exercise_questions/_exercise_questions.json.jbuilder index 51c30ad92..bbdf45440 100644 --- a/app/views/exercise_questions/_exercise_questions.json.jbuilder +++ b/app/views/exercise_questions/_exercise_questions.json.jbuilder @@ -17,7 +17,8 @@ if question.question_type <= 2 #当为选择题或判断题时,只显示选 end json.question_choices do json.array! exercise_choices.each_with_index.to_a do |a,index| - standard_answer_b = standard_answers_array.include?(a.choice_position) + #TODO: 旧版本来一个题只有一个标准答案的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + standard_answer_b = standard_answers_array.join("").include?(a.choice_position.to_s) user_answer_b = user_answer.include?(a.id) json.c_position (index+1) if ex_choice_random_boolean #当选项随机时,选项位置以此为准,否则不出现 json.choice_id a.id