Class: Csv2qti::Outcome
- Inherits:
-
Object
- Object
- Csv2qti::Outcome
- Defined in:
- lib/csv2qti/outcome.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#enabling_outcomes ⇒ Object
readonly
Returns the value of attribute enabling_outcomes.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#license ⇒ Object
readonly
Returns the value of attribute license.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#questions ⇒ Object
readonly
Returns the value of attribute questions.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #add_enabling_outcome(row) ⇒ Object
- #add_question(row) ⇒ Object
- #add_questions(group) ⇒ Object
- #generate_assessment ⇒ Object
-
#initialize(row, parent_outcome = nil) ⇒ Outcome
constructor
A new instance of Outcome.
- #is_primary_outcome? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(row, parent_outcome = nil) ⇒ Outcome
Returns a new instance of Outcome.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/csv2qti/outcome.rb', line 5 def initialize(row, parent_outcome=nil) @number = row[0] @title = row[1] @description = row[2] @guid = row[3] @license = row[5] @parent_outcome = parent_outcome @enabling_outcomes = [] @questions = [] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def description @description end |
#enabling_outcomes ⇒ Object (readonly)
Returns the value of attribute enabling_outcomes.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def enabling_outcomes @enabling_outcomes end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def guid @guid end |
#license ⇒ Object (readonly)
Returns the value of attribute license.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def license @license end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def number @number end |
#questions ⇒ Object (readonly)
Returns the value of attribute questions.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def questions @questions end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/csv2qti/outcome.rb', line 3 def title @title end |
Instance Method Details
#add_enabling_outcome(row) ⇒ Object
16 17 18 19 |
# File 'lib/csv2qti/outcome.rb', line 16 def add_enabling_outcome(row) @enabling_outcomes << Outcome.new(row, self) @enabling_outcomes.last end |
#add_question(row) ⇒ Object
21 22 23 |
# File 'lib/csv2qti/outcome.rb', line 21 def add_question(row) @questions << Question.generate(row) end |
#add_questions(group) ⇒ Object
49 50 51 52 53 |
# File 'lib/csv2qti/outcome.rb', line 49 def add_questions(group) @questions.each do |q| q.add_to_group(group) end end |
#generate_assessment ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/csv2qti/outcome.rb', line 29 def generate_assessment assessment = CanvasCc::CanvasCC::Models::Assessment.new assessment.identifier = rand(10000).to_s assessment.items = [] assessment.title = @title add_questions(assessment) @enabling_outcomes.each do |eo| g = CanvasCc::CanvasCC::Models::QuestionGroup.new g.title = eo.title g.identifier = rand(10000).to_s g.selection_number = 1 g.points_per_item = 1 eo.add_questions(g) assessment.items << g end assessment end |
#is_primary_outcome? ⇒ Boolean
25 26 27 |
# File 'lib/csv2qti/outcome.rb', line 25 def is_primary_outcome? !! @parent_outcome end |
#to_s ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/csv2qti/outcome.rb', line 55 def to_s if is_primary_outcome? "#{number}: #{title} - #{description} - #{guid} - #{license} - #{questions.count} questions" else "#{number}: #{title} - #{description} - #{guid} - #{license} - #{enabling_outcomes.count} enabling outcomes" end end |