mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-04 04:03:25 +08:00
init project
This commit is contained in:
12
app/forms/examination_intelligent_settings/save_exam_form.rb
Normal file
12
app/forms/examination_intelligent_settings/save_exam_form.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class ExaminationIntelligentSettings::SaveExamForm
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :name, :duration
|
||||
|
||||
validates :name, presence: true, length: { maximum: 60 }
|
||||
validate :validate_duration
|
||||
|
||||
def validate_duration
|
||||
raise '时长应为大于0的整数' if duration.present? && duration.to_i < 1
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class ExaminationIntelligentSettings::SaveExamSettingForm
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :discipline_id, :sub_discipline_id, :source, :difficulty, :tag_discipline_id, :question_settings
|
||||
|
||||
validates :discipline_id, presence: true
|
||||
validates :sub_discipline_id, presence: true
|
||||
validates :source, presence: true
|
||||
validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true }
|
||||
validates :question_settings, presence: true
|
||||
end
|
||||
Reference in New Issue
Block a user