Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

sso^2
tangjiang 5 years ago
commit d895a8ac02

@ -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

@ -35,7 +35,7 @@ class HomeworkCommon < ApplicationRecord
# 学生的查重情况
has_many :homework_review_results, :dependent => :destroy
validates :name, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" }
validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" }
validates :explanation, length: { maximum: 5000, too_long: "不能超过5000个字符" }
validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" }

Loading…
Cancel
Save