Class: Course::Survey

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

Defined Under Namespace

Modules: ReorderingConcern Classes: Answer, AnswerOption, ClosingReminderJob, Controller, Question, QuestionOption, QuestionsController, ReminderService, Response, ResponsesController, Section, SectionsController, SurveysController

Instance Method Summary collapse

Instance Method Details

#can_toggle_anonymity?Boolean


33
34
35
# File 'app/models/course/survey.rb', line 33

def can_toggle_anonymity?
  !anonymous || !has_student_response?
end

#can_user_start?(_user) ⇒ Boolean


23
24
25
# File 'app/models/course/survey.rb', line 23

def can_user_start?(_user)
  allow_response_after_end || end_at.nil? || Time.zone.now < end_at
end

#has_student_response?Boolean


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

def has_student_response?
  responses.find do |response|
    response.experience_points_record.course_user.student?
  end.present?
end

#include_in_consolidated_email?(event) ⇒ Boolean


43
44
45
# File 'app/models/course/survey.rb', line 43

def include_in_consolidated_email?(event)
  Course::Settings::SurveyComponent.email_enabled?(course, "survey_#{event}".to_sym)
end

#initialize_duplicate(duplicator, other) ⇒ Object


37
38
39
40
41
# File 'app/models/course/survey.rb', line 37

def initialize_duplicate(duplicator, other)
  copy_attributes(other, duplicator)
  self.sections = duplicator.duplicate(other.sections)
  self.course = duplicator.options[:destination_course]
end