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.
educoder/app/models/poll_question.rb

25 lines
601 B

class PollQuestion < ApplicationRecord
belongs_to :poll
has_many :poll_answers, :dependent => :delete_all
attr_accessor :question_answers, :question_other_anser
has_many :poll_votes
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