Class: Course::Survey::Response

Inherits:
ApplicationRecord show all
Includes:
TodoConcern
Defined in:
app/models/course/survey/response.rb

Defined Under Namespace

Modules: TodoConcern

Instance Method Summary collapse

Methods included from TodoConcern

#todo

Instance Method Details

#build_missing_answersObject


34
35
36
37
38
39
# File 'app/models/course/survey/response.rb', line 34

def build_missing_answers
  answer_id_set = answers.pluck(:question_id).to_set
  survey.questions.each do |question|
    answers.build(question: question) unless answer_id_set.include?(question.id)
  end
end

#submitObject


18
19
20
21
22
23
24
25
# File 'app/models/course/survey/response.rb', line 18

def submit
  self. = Time.zone.now
  self.points_awarded = survey.base_exp
  self.points_awarded += survey.time_bonus_exp if \
    survey.allow_response_after_end &&  <= survey.end_at
  self.awarded_at = Time.zone.now
  self.awarder = creator
end

#submitted?Boolean


14
15
16
# File 'app/models/course/survey/response.rb', line 14

def 
  .present?
end

#unsubmitObject


27
28
29
30
31
32
# File 'app/models/course/survey/response.rb', line 27

def unsubmit
  self. = nil
  self.points_awarded = 0
  self.awarded_at = nil
  self.awarder = nil
end