Class: SurveyQuestion

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/questions.rb

Constant Summary collapse

ANSWERS =
[
    :yes_no,
    :disagree_agree,
    :disagree_undecided,
    :below_above,
    :strongly_agree,
    :unacceptable_excellent,
    :one_to_five,
    :one_to_ten
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name, #reset

Constructor Details

#initialize(browser, opts = {}) ⇒ SurveyQuestion

Returns a new instance of SurveyQuestion.



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/sambal-cle/data_objects/questions.rb', line 109

def initialize(browser, opts={})
  @browser = browser

  defaults = {
      :text=>random_alphanums,
      :answer=>ANSWERS[rand(ANSWERS.length)]
  }
  options = defaults.merge(opts)

  set_options(options)
  requires @assessment
end

Instance Attribute Details

#answerObject

Returns the value of attribute answer.



96
97
98
# File 'lib/sambal-cle/data_objects/questions.rb', line 96

def answer
  @answer
end

#assessmentObject

Returns the value of attribute assessment.



96
97
98
# File 'lib/sambal-cle/data_objects/questions.rb', line 96

def assessment
  @assessment
end

#feedbackObject

Returns the value of attribute feedback.



96
97
98
# File 'lib/sambal-cle/data_objects/questions.rb', line 96

def feedback
  @feedback
end

#partObject

Returns the value of attribute part.



96
97
98
# File 'lib/sambal-cle/data_objects/questions.rb', line 96

def part
  @part
end

#poolObject

Returns the value of attribute pool.



96
97
98
# File 'lib/sambal-cle/data_objects/questions.rb', line 96

def pool
  @pool
end

#textObject

Returns the value of attribute text.



96
97
98
# File 'lib/sambal-cle/data_objects/questions.rb', line 96

def text
  @text
end

Instance Method Details

#createObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/sambal-cle/data_objects/questions.rb', line 122

def create
  # Note that this method presumes that it's being called from
  # within methods in the AssessmentObject class, not directly
  # in a test script, so no positioning navigation is set up.
  on EditAssessment do |edit|
    edit.question_type "Survey"
  end
  on Survey do |add|
    add.question_text.set @text
    add.send(@answer).set
    add.assign_to_part.select /#{@part}/
    add.assign_to_pool.fit @pool
    add.feedback.fit @feedback
    add.save
  end
end

#edit(opts = {}) ⇒ Object



139
140
141
142
# File 'lib/sambal-cle/data_objects/questions.rb', line 139

def edit opts={}
  #TODO
  set_options(opts)
end