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.



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/sambal-cle/data_objects/questions.rb', line 266

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.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def answers
  @answers
end

#correct_answer_feedbackObject

Returns the value of attribute correct_answer_feedback.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def correct_answer_feedback
  @correct_answer_feedback
end

#incorrect_answer_feedbackObject

Returns the value of attribute incorrect_answer_feedback.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def incorrect_answer_feedback
  @incorrect_answer_feedback
end

#partObject

Returns the value of attribute part.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def part
  @part
end

#point_valueObject

Returns the value of attribute point_value.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def point_value
  @point_value
end

#poolObject

Returns the value of attribute pool.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def pool
  @pool
end

#textObject

Returns the value of attribute text.



264
265
266
# File 'lib/sambal-cle/data_objects/questions.rb', line 264

def text
  @text
end

Instance Method Details

#createObject



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/sambal-cle/data_objects/questions.rb', line 285

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



312
313
314
# File 'lib/sambal-cle/data_objects/questions.rb', line 312

def delete

end

#edit(opts = {}) ⇒ Object



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

def edit opts={}

  set_options(opts)
end

#viewObject



308
309
310
# File 'lib/sambal-cle/data_objects/questions.rb', line 308

def view

end