You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#encoding: utf-8
|
|
|
|
class ExerciseQuestion < ApplicationRecord
|
|
|
|
|
|
|
|
belongs_to :exercise
|
|
|
|
belongs_to :shixun, optional: true
|
|
|
|
|
|
|
|
has_many :exercise_choices, :dependent => :destroy
|
|
|
|
has_many :exercise_answers
|
|
|
|
has_many :exercise_shixun_challenges,:dependent => :destroy
|
|
|
|
has_many :exercise_shixun_answers
|
|
|
|
has_many :exercise_answer_comments
|
|
|
|
has_many :exercise_standard_answers
|
|
|
|
|
|
|
|
scope :insert_question_ex, lambda {|k| where("question_number > ?",k)}
|
|
|
|
scope :find_by_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
|
|
|
|
scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
|
|
|
|
scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题
|
|
|
|
# scope :next_exercise, lambda {|k| where("question_number > ?",k).first}
|
|
|
|
# scope :last_exercise, lambda {|k| where("question_number < ?",k).last}
|
|
|
|
|
|
|
|
def question_type_name
|
|
|
|
case self.question_type
|
|
|
|
when 0
|
|
|
|
"单选题"
|
|
|
|
when 1
|
|
|
|
"多选题"
|
|
|
|
when 2
|
|
|
|
"判断题"
|
|
|
|
when 3
|
|
|
|
"填空题"
|
|
|
|
when 4
|
|
|
|
"简答题"
|
|
|
|
when 5
|
|
|
|
"实训题"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#获取问题的全部标准答案
|
|
|
|
def get_standard_answer_ids
|
|
|
|
exercise_standard_answers.pluck(:exercise_choice_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_standard_answer_text
|
|
|
|
exercise_standard_answers.pluck(:answer_text)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|