Class: MatchingQuestion

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

Returns a new instance of MatchingQuestion.



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/sambal-cle/data_objects/questions.rb', line 327

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

  defaults = {
      :text=>random_alphanums,
      :point_value=>(rand(100)+1).to_s,
      :pairs=>[
          {:choice=>random_alphanums, :match=>random_alphanums, :correct_match_feedback=>random_alphanums, :incorrect_match_feedback=>random_alphanums},
          {:choice=>random_alphanums, :match=>random_alphanums, :correct_match_feedback=>random_alphanums, :incorrect_match_feedback=>random_alphanums},
          {:choice=>random_alphanums, :match=>:distractor, :correct_match_feedback=>random_alphanums, :incorrect_match_feedback=>random_alphanums},
          {:choice=>random_alphanums, :match=>random_alphanums, :correct_match_feedback=>random_alphanums, :incorrect_match_feedback=>random_alphanums},
          {:choice=>random_alphanums, :match=>random_alphanums, :correct_match_feedback=>random_alphanums, :incorrect_match_feedback=>random_alphanums},
          {:choice=>random_alphanums, :match=>:distractor, :correct_match_feedback=>random_alphanums, :incorrect_match_feedback=>random_alphanums}
      ]
  }
  options = defaults.merge(opts)

  set_options(options)
  requires @assessment
end

Instance Attribute Details

#correct_answer_feedbackObject

Returns the value of attribute correct_answer_feedback.



325
326
327
# File 'lib/sambal-cle/data_objects/questions.rb', line 325

def correct_answer_feedback
  @correct_answer_feedback
end

#incorrect_answer_feedbackObject

Returns the value of attribute incorrect_answer_feedback.



325
326
327
# File 'lib/sambal-cle/data_objects/questions.rb', line 325

def incorrect_answer_feedback
  @incorrect_answer_feedback
end

#pairsObject

Returns the value of attribute pairs.



325
326
327
# File 'lib/sambal-cle/data_objects/questions.rb', line 325

def pairs
  @pairs
end

#point_valueObject

Returns the value of attribute point_value.



325
326
327
# File 'lib/sambal-cle/data_objects/questions.rb', line 325

def point_value
  @point_value
end

#textObject

Returns the value of attribute text.



325
326
327
# File 'lib/sambal-cle/data_objects/questions.rb', line 325

def text
  @text
end

Instance Method Details

#createObject



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/sambal-cle/data_objects/questions.rb', line 348

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

    @pairs.each do |pair|
      add.choice.set pair[:choice]
      if pair[:match]==:distractor
        add.distractor
      else
        add.match.set pair[:match]
      end
      if add.correct_match_feedback.present?
        add.correct_match_feedback.fit pair[:correct_match_feedback]
        add.incorrect_match_feedback.fit pair[:incorrect_match_feedback]
      end
      add.save_pairing
      add.choice.wait_until_present
    end

    add.save
  end
end

#deleteObject



391
392
393
# File 'lib/sambal-cle/data_objects/questions.rb', line 391

def delete

end

#edit(opts = {}) ⇒ Object



382
383
384
385
# File 'lib/sambal-cle/data_objects/questions.rb', line 382

def edit opts={}

  set_options(opts)
end

#viewObject



387
388
389
# File 'lib/sambal-cle/data_objects/questions.rb', line 387

def view

end