Class: ShortAnswerQuestion

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

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 = {}) ⇒ ShortAnswerQuestion

Returns a new instance of ShortAnswerQuestion.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/sambal-cle/data_objects/questions.rb', line 157

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

  defaults = {
      :text=>random_alphanums,
      :point_value=>(rand(100)+1).to_s,
      :model_answer=>random_alphanums,
      :rich_text=>false
  }
  options = defaults.merge(opts)

  set_options(options)
  requires @assessment, @part
end

Instance Attribute Details

#assessmentObject

Returns the value of attribute assessment.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def assessment
  @assessment
end

#feedbackObject

Returns the value of attribute feedback.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def feedback
  @feedback
end

#model_answerObject

Returns the value of attribute model_answer.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def model_answer
  @model_answer
end

#partObject

Returns the value of attribute part.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def part
  @part
end

#point_valueObject

Returns the value of attribute point_value.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def point_value
  @point_value
end

#poolObject

Returns the value of attribute pool.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def pool
  @pool
end

#rich_textObject

Returns the value of attribute rich_text.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def rich_text
  @rich_text
end

#textObject

Returns the value of attribute text.



154
155
156
# File 'lib/sambal-cle/data_objects/questions.rb', line 154

def text
  @text
end

Instance Method Details

#createObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/sambal-cle/data_objects/questions.rb', line 172

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 "Short Answer/Essay"
  end
  on ShortAnswer do |add|
    if @rich_text
      add.toggle_question_editor
      add.enter_source_text(add.question_editor, @text)
    else
      add.question_text.set @text
    end
    add.answer_point_value.set @point_value
    add.model_short_answer.set @model_answer
    add.feedback.fit @feedback
    add.assign_to_part.select /#{@part}/
    add.assign_to_pool.fit @pool
    add.save
  end
end

#edit(opts = {}) ⇒ Object



195
196
197
# File 'lib/sambal-cle/data_objects/questions.rb', line 195

def edit opts={}
  #TODO
end