diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 0e3771e61..adf0dc6bf 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -376,6 +376,11 @@ class HomeworkCommonsController < ApplicationController @homework.user_id = current_user.id @homework.course_id = @course.id + if params[:category].present? + category = @course.course_second_categories.find_by(id: params[:category]) + @homework.course_second_category_id = category&.id.to_i + end + homework_detail_manual = HomeworkDetailManual.new @homework.homework_detail_manual = homework_detail_manual homework_detail_manual.te_proportion = 0.7 diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index bcb88ad85..af6305a64 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -212,6 +212,11 @@ class QuestionBanksController < ApplicationController homework_type: homework.homework_type, course_id: course.id, homework_bank_id: homework.id, reference_answer: homework.reference_answer) + if params[:category].present? + category = course.course_second_categories.find_by(id: params[:category]) + new_homework.course_second_category_id = category&.id.to_i + end + # 作业的基本设置复制 new_homework.homework_detail_manual = HomeworkDetailManual.new new_homework_detail_manual = new_homework.homework_detail_manual