|
|
|
@ -90,23 +90,25 @@ class QuestionBanksController < ApplicationController
|
|
|
|
|
def send_to_course
|
|
|
|
|
banks = @object_type.classify.constantize.where(id: params[:object_id])
|
|
|
|
|
course = current_user.manage_courses.find_by!(id: params[:course_id])
|
|
|
|
|
task_ids = []
|
|
|
|
|
banks.each do |bank|
|
|
|
|
|
case @object_type
|
|
|
|
|
when 'HomeworkBank' # 作业
|
|
|
|
|
quote_homework_bank bank, course
|
|
|
|
|
task = quote_homework_bank bank, course
|
|
|
|
|
when 'ExerciseBank'
|
|
|
|
|
if bank.container_type == 'Exercise' # 试卷
|
|
|
|
|
quote_exercise_bank bank, course
|
|
|
|
|
task = quote_exercise_bank bank, course
|
|
|
|
|
else # 问卷
|
|
|
|
|
quote_poll_bank bank, course
|
|
|
|
|
task = quote_poll_bank bank, course
|
|
|
|
|
end
|
|
|
|
|
when 'GtaskBank'
|
|
|
|
|
quote_gtask_bank bank, course
|
|
|
|
|
task = quote_gtask_bank bank, course
|
|
|
|
|
when 'GtopicBank'
|
|
|
|
|
quote_gtopic_bank bank, course
|
|
|
|
|
task = quote_gtopic_bank bank, course
|
|
|
|
|
end
|
|
|
|
|
task_ids << task.id if task
|
|
|
|
|
end
|
|
|
|
|
normal_status("发送成功")
|
|
|
|
|
render :json => {task_ids: task_ids, status: 0, message: "发送成功"}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|