|
|
|
@ -368,6 +368,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
@homework = HomeworkCommon.new(homework_params)
|
|
|
|
|
@homework.reference_answer = params[:reference_answer].to_s.strip
|
|
|
|
|
@homework.homework_type = @homework_type
|
|
|
|
|
@homework.user_id = current_user.id
|
|
|
|
|
@homework.course_id = @course.id
|
|
|
|
@ -417,6 +418,7 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
@homework.update_attributes!(homework_params)
|
|
|
|
|
@homework.reference_answer = params[:reference_answer].to_s.strip
|
|
|
|
|
|
|
|
|
|
if @homework.homework_type == "group"
|
|
|
|
|
homework_detail_group = @homework.homework_detail_group
|
|
|
|
@ -1404,8 +1406,8 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def homework_params
|
|
|
|
|
tip_exception("name参数不能为空") if params[:name].blank?
|
|
|
|
|
tip_exception("description参数不能为空") if params[:description].blank?
|
|
|
|
|
tip_exception("标题不能为空") if params[:name].blank?
|
|
|
|
|
tip_exception("内容不能为空") if params[:description].blank?
|
|
|
|
|
params.require(:homework_common).permit(:name, :description, :reference_answer)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|