Class: QuestionGroupTracker

Inherits:
Object
  • Object
show all
Defined in:
app/models/question_group_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(question_group_id) ⇒ QuestionGroupTracker

Returns a new instance of QuestionGroupTracker.



3
4
5
6
7
8
# File 'app/models/question_group_tracker.rb', line 3

def initialize(question_group_id)
  @questions = Question.where('question_group_id=?',question_group_id)
  @counter = 0
  @question_group_id = question_group_id
  @question_group = QuestionGroup.find(question_group_id)
end

Instance Attribute Details

#question_groupObject (readonly)

Returns the value of attribute question_group.



2
3
4
# File 'app/models/question_group_tracker.rb', line 2

def question_group
  @question_group
end

#question_group_idObject (readonly)

Returns the value of attribute question_group_id.



2
3
4
# File 'app/models/question_group_tracker.rb', line 2

def question_group_id
  @question_group_id
end

#questionsObject (readonly)

Returns the value of attribute questions.



2
3
4
# File 'app/models/question_group_tracker.rb', line 2

def questions
  @questions
end

Instance Method Details

#check_for_new_group(question) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'app/models/question_group_tracker.rb', line 10

def check_for_new_group(question)
  if question.question_group_id != @question_group_id || !defined?(@initial_check)
    initialize(question.question_group_id)
    @initial_check = true
    return true
  else
    return false
  end
end