Class: MultipleChoiceQuestion
- Inherits:
-
Object
- Object
- MultipleChoiceQuestion
- Includes:
- DataFactory, Foundry, StringFactory, Workflows
- Defined in:
- lib/sambal-cle/data_objects/questions.rb
Instance Attribute Summary collapse
-
#answer_credit ⇒ Object
Returns the value of attribute answer_credit.
-
#answers ⇒ Object
Returns the value of attribute answers.
-
#answers_feedback ⇒ Object
Returns the value of attribute answers_feedback.
-
#assessment ⇒ Object
Returns the value of attribute assessment.
-
#correct_answer ⇒ Object
Returns the value of attribute correct_answer.
-
#correct_answer_feedback ⇒ Object
Returns the value of attribute correct_answer_feedback.
-
#correct_type ⇒ Object
Returns the value of attribute correct_type.
-
#incorrect_answer_feedback ⇒ Object
Returns the value of attribute incorrect_answer_feedback.
-
#negative_point_value ⇒ Object
Returns the value of attribute negative_point_value.
-
#part ⇒ Object
Returns the value of attribute part.
-
#point_value ⇒ Object
Returns the value of attribute point_value.
-
#pool ⇒ Object
Returns the value of attribute pool.
-
#randomize_answers ⇒ Object
Returns the value of attribute randomize_answers.
-
#require_rationale ⇒ Object
Returns the value of attribute require_rationale.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #create ⇒ Object
- #edit(opts = {}) ⇒ Object
-
#initialize(browser, opts = {}) ⇒ MultipleChoiceQuestion
constructor
A new instance of MultipleChoiceQuestion.
Methods included from Workflows
menu_link, #open_my_site_by_name, #reset
Constructor Details
#initialize(browser, opts = {}) ⇒ MultipleChoiceQuestion
Returns a new instance of MultipleChoiceQuestion.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 19 def initialize(browser, opts={}) @browser = browser defaults = { :text=>random_alphanums, :point_value=>(rand(100)+1).to_s, :correct_type=>:single_correct, :answers=>[random_alphanums, random_alphanums, random_alphanums, random_alphanums], } defaults[:correct_answer]=(rand(defaults[:answers].length)+65).chr.to_s = defaults.merge(opts) () requires @assessment, @part end |
Instance Attribute Details
#answer_credit ⇒ Object
Returns the value of attribute answer_credit.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def answer_credit @answer_credit end |
#answers ⇒ Object
Returns the value of attribute answers.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def answers @answers end |
#answers_feedback ⇒ Object
Returns the value of attribute answers_feedback.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def answers_feedback @answers_feedback end |
#assessment ⇒ Object
Returns the value of attribute assessment.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def assessment @assessment end |
#correct_answer ⇒ Object
Returns the value of attribute correct_answer.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def correct_answer @correct_answer end |
#correct_answer_feedback ⇒ Object
Returns the value of attribute correct_answer_feedback.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def correct_answer_feedback @correct_answer_feedback end |
#correct_type ⇒ Object
Returns the value of attribute correct_type.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def correct_type @correct_type end |
#incorrect_answer_feedback ⇒ Object
Returns the value of attribute incorrect_answer_feedback.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def incorrect_answer_feedback @incorrect_answer_feedback end |
#negative_point_value ⇒ Object
Returns the value of attribute negative_point_value.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def negative_point_value @negative_point_value end |
#part ⇒ Object
Returns the value of attribute part.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def part @part end |
#point_value ⇒ Object
Returns the value of attribute point_value.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def point_value @point_value end |
#pool ⇒ Object
Returns the value of attribute pool.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def pool @pool end |
#randomize_answers ⇒ Object
Returns the value of attribute randomize_answers.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def randomize_answers @randomize_answers end |
#require_rationale ⇒ Object
Returns the value of attribute require_rationale.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def require_rationale @require_rationale end |
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 8 def text @text end |
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 33 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 "Multiple Choice" end on MultipleChoice do |add| add.answer_point_value.set @point_value add.question_text.set @text add.send(@correct_type).set add.send(@answer_credit).set unless @answer_credit==nil add.negative_point_value.fit @negative_point_value case(@answers.length) when 1..3 (4-@answers.length).times { add.remove_last_answer } when 4 # Do nothing yet when 5..10 add.insert_additional_answers.select((@answers.length-4).to_s) when 11..16 add.insert_additional_answers.select "6" add.insert_additional_answers.select((@answers.length-10).to_s) when 17..22 2.times {add.insert_additional_answers.select "6"} add.insert_additional_answers.select((@answers.length-16).to_s) when 23..26 3.times {add.insert_additional_answers.select "6"} add.insert_additional_answers.select((@answers.length-22).to_s) else raise "There is no support for more than 26 choices right now" end @answers.each_with_index do |answer, x| add.answer_text((x+65).chr).set answer end @answers_feedback.each_with_index do |feedback, x| add.answer_feedback_text((x+65).chr).set feedback end add.correct_answer(@correct_answer).set add.randomize_answers_yes.set if @randomize_answers=="yes" add.require_rationale_yes.set if @require_rationale=="yes" 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 add.save end end |
#edit(opts = {}) ⇒ Object
82 83 84 85 |
# File 'lib/sambal-cle/data_objects/questions.rb', line 82 def edit opts={} # TODO (opts) end |