Class: NumericResponseQuestion

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

Returns a new instance of NumericResponseQuestion.



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/sambal-cle/data_objects/questions.rb', line 259

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

  defaults = {
      :answers=>[rand(2000), rand(10000000)],
      :point_value=>(rand(100)+1).to_s
  }
  question_string = random_alphanums
  defaults[:answers].each do |answer|
    question_string << " {#{answer}} #{random_alphanums}"
  end
  defaults[:text]=question_string

  options = defaults.merge(opts)

  set_options(options)
  requires @text
end

Instance Attribute Details

#answersObject

Returns the value of attribute answers.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def answers
  @answers
end

#correct_answer_feedbackObject

Returns the value of attribute correct_answer_feedback.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def correct_answer_feedback
  @correct_answer_feedback
end

#incorrect_answer_feedbackObject

Returns the value of attribute incorrect_answer_feedback.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def incorrect_answer_feedback
  @incorrect_answer_feedback
end

#partObject

Returns the value of attribute part.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def part
  @part
end

#point_valueObject

Returns the value of attribute point_value.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def point_value
  @point_value
end

#poolObject

Returns the value of attribute pool.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def pool
  @pool
end

#textObject

Returns the value of attribute text.



257
258
259
# File 'lib/sambal-cle/data_objects/questions.rb', line 257

def text
  @text
end

Instance Method Details

#createObject



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/sambal-cle/data_objects/questions.rb', line 278

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 "Numeric Response"
  end
  on NumericResponse do |add|
    add.question_text.set @text
    add.answer_point_value.set @point_value
    add.assign_to_part.select /#{@part}/
    add.assign_to_pool.select @pool unless @pool==nil
    add.correct_answer_feedback.fit @correct_answer_feedback
    add.incorrect_answer_feedback.fit @incorrect_answer_feedback
    add.save
  end
end

#deleteObject



305
306
307
# File 'lib/sambal-cle/data_objects/questions.rb', line 305

def delete

end

#edit(opts = {}) ⇒ Object



296
297
298
299
# File 'lib/sambal-cle/data_objects/questions.rb', line 296

def edit opts={}

  set_options(opts)
end

#viewObject



301
302
303
# File 'lib/sambal-cle/data_objects/questions.rb', line 301

def view

end