Class: MatchingQuestion
- Inherits:
-
Object
- Object
- MatchingQuestion
- Includes:
- DataFactory, Foundry, StringFactory, Workflows
- Defined in:
- lib/sambal-cle/data_objects/questions.rb
Instance Attribute Summary collapse
-
#correct_answer_feedback ⇒ Object
Returns the value of attribute correct_answer_feedback.
-
#incorrect_answer_feedback ⇒ Object
Returns the value of attribute incorrect_answer_feedback.
-
#pairs ⇒ Object
Returns the value of attribute pairs.
-
#point_value ⇒ Object
Returns the value of attribute point_value.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #edit(opts = {}) ⇒ Object
-
#initialize(browser, opts = {}) ⇒ MatchingQuestion
constructor
A new instance of MatchingQuestion.
- #view ⇒ Object
Methods included from Workflows
menu_link, #open_my_site_by_name, #reset
Constructor Details
#initialize(browser, opts = {}) ⇒ MatchingQuestion
Returns a new instance of MatchingQuestion.
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 320 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} ] } = defaults.merge(opts) () requires @assessment end |
Instance Attribute Details
#correct_answer_feedback ⇒ Object
Returns the value of attribute correct_answer_feedback.
318 319 320 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 318 def correct_answer_feedback @correct_answer_feedback end |
#incorrect_answer_feedback ⇒ Object
Returns the value of attribute incorrect_answer_feedback.
318 319 320 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 318 def incorrect_answer_feedback @incorrect_answer_feedback end |
#pairs ⇒ Object
Returns the value of attribute pairs.
318 319 320 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 318 def pairs @pairs end |
#point_value ⇒ Object
Returns the value of attribute point_value.
318 319 320 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 318 def point_value @point_value end |
#text ⇒ Object
Returns the value of attribute text.
318 319 320 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 318 def text @text end |
Instance Method Details
#create ⇒ Object
341 342 343 344 345 346 347 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 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 341 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 |
#delete ⇒ Object
384 385 386 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 384 def delete end |
#edit(opts = {}) ⇒ Object
375 376 377 378 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 375 def edit opts={} (opts) end |
#view ⇒ Object
380 381 382 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 380 def view end |