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.
25 lines
622 B
25 lines
622 B
6 years ago
|
class PollQuestion < ApplicationRecord
|
||
|
|
||
|
belongs_to :poll
|
||
|
has_many :poll_answers, :dependent => :destroy
|
||
|
attr_accessor :question_answers, :question_other_anser
|
||
|
has_many :poll_votes, :dependent => :destroy
|
||
|
|
||
|
scope :ques_count, lambda {|k| where("question_type = ?",k)}
|
||
|
scope :ques_necessary, -> {where("is_necessary = ?",1)}
|
||
|
scope :insert_question, lambda {|k| where("question_number > ?",k)}
|
||
|
|
||
|
def question_type_name
|
||
|
case self.question_type
|
||
|
when 1
|
||
|
"单选题"
|
||
|
when 2
|
||
|
"多选题"
|
||
|
when 3
|
||
|
"主观题"
|
||
|
when 4
|
||
|
"多行主观题"
|
||
|
end
|
||
|
end
|
||
|
end
|