提示的调整

fix_latex
cxt 5 years ago
parent 6d8a7f5498
commit be6b16d3f3

@ -7,8 +7,6 @@ class ItemBanks::SaveItemForm
validates :sub_discipline_id, presence: true
validates :item_type, presence: true, inclusion: {in: %W(SINGLE MULTIPLE JUDGMENT COMPLETION SUBJECTIVE PRACTICAL PROGRAM)}
validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true }
validates :name, presence: true, length: { maximum: 1000, too_long: "不能超过1000个字符" }
validates :analysis, length: { maximum: 5000, too_long: "不能超过5000个字符" }
def validate!
super
@ -27,7 +25,6 @@ class ItemBanks::SaveItemForm
attr_accessor :choice_text, :is_answer
validates :choice_text, presence: true, length: { maximum: 500, too_long: "不能超过500个字符" }
validates :is_answer, presence: true, inclusion: {in: 0..1}, numericality: { only_integer: true }
end
end

@ -13,6 +13,8 @@ class ItemBank < ApplicationRecord
has_many :tag_disciplines, through: :tag_discipline_containers
belongs_to :container, polymorphic: true, optional: true
validates :name, presence: true, length: { maximum: 1000, too_long: "不能超过1000个字符" }
validates :analysis, length: { maximum: 5000, too_long: "不能超过5000个字符" }
def analysis
item_analysis&.analysis

@ -1,3 +1,5 @@
class ItemChoice < ApplicationRecord
belongs_to :item_bank, touch: true
validates :choice_text, presence: true, length: { maximum: 500, too_long: "不能超过500个字符" }
end

Loading…
Cancel
Save