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.
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} ] } = defaults.merge(opts) () requires @assessment end |
Instance Attribute Details
#correct_answer_feedback ⇒ Object
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_feedback ⇒ Object
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 |
#pairs ⇒ Object
Returns the value of attribute pairs.
325 326 327 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 325 def pairs @pairs end |
#point_value ⇒ Object
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 |
#text ⇒ Object
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
#create ⇒ Object
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 |
#delete ⇒ Object
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={} (opts) end |
#view ⇒ Object
387 388 389 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 387 def view end |