作业的子目录

PCqiandao
cxt 5 years ago
parent ceb5a5b38f
commit 119a76a585

@ -359,6 +359,9 @@ class HomeworkCommonsController < ApplicationController
def new def new
tip_exception("type参数有误") if params[:type].blank? || ![1, 3].include?(params[:type].to_i) tip_exception("type参数有误") if params[:type].blank? || ![1, 3].include?(params[:type].to_i)
@homework_type = params[:type].to_i @homework_type = params[:type].to_i
module_type = params[:type].to_i == 1 ? "common_homework" : "group_homework"
@main_category = @course.course_modules.find_by(module_type: module_type)
@category = @main_category.course_second_categories.find_by(id: params[:category]) if params[:category].present?
end end
def create def create
@ -409,7 +412,12 @@ class HomeworkCommonsController < ApplicationController
end end
def edit def edit
if @homework.course_second_category_id == 0
module_type = @homework.homework_type == "normal" ? "common_homework" : "group_homework"
@main_category = @course.course_modules.find_by(module_type: module_type)
else
@category = @homework.course_second_category
end
end end
def update def update

@ -1,6 +1,16 @@
json.course_id @course.id json.course_id @course.id
json.course_name @course.name json.course_name @course.name
json.category @homework.category_info # json.category @homework.category_info
json.category do
if @category.present?
json.category_id @category.id
json.category_name @category.name
else
json.category_id @main_category&.id
json.category_name @main_category&.module_name
end
end
json.(@homework, :id, :name, :description, :reference_answer) json.(@homework, :id, :name, :description, :reference_answer)

@ -1,3 +1,11 @@
json.course_id @course.id json.course_id @course.id
json.course_name @course.name json.course_name @course.name
json.category @course.category_info(@homework_type == 1 ? "common_homework" : "group_homework") json.category do
if @category.present?
json.category_id @category.id
json.category_name @category.name
else
json.category_id @main_category&.id
json.category_name @main_category&.module_name
end
end
Loading…
Cancel
Save