Class: Csv2qti::Course
- Inherits:
-
Object
- Object
- Csv2qti::Course
- Defined in:
- lib/csv2qti/course.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#primary_outcomes ⇒ Object
readonly
Returns the value of attribute primary_outcomes.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #add_primary_outcome(row) ⇒ Object
- #generate_cc(filename = nil) ⇒ Object
-
#initialize(title, file_path) ⇒ Course
constructor
A new instance of Course.
- #to_s ⇒ Object
Constructor Details
#initialize(title, file_path) ⇒ Course
Returns a new instance of Course.
7 8 9 10 11 |
# File 'lib/csv2qti/course.rb', line 7 def initialize(title, file_path) @title = title @file_path = file_path @primary_outcomes = [] end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
5 6 7 |
# File 'lib/csv2qti/course.rb', line 5 def file_path @file_path end |
#primary_outcomes ⇒ Object (readonly)
Returns the value of attribute primary_outcomes.
5 6 7 |
# File 'lib/csv2qti/course.rb', line 5 def primary_outcomes @primary_outcomes end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/csv2qti/course.rb', line 5 def title @title end |
Instance Method Details
#add_primary_outcome(row) ⇒ Object
13 14 15 16 |
# File 'lib/csv2qti/course.rb', line 13 def add_primary_outcome(row) @primary_outcomes << Outcome.new(row) @primary_outcomes.last end |
#generate_cc(filename = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/csv2qti/course.rb', line 18 def generate_cc(filename=nil) filename ||= @title course = CanvasCc::CanvasCC::Models::Course.new course.title = @title course.identifier = rand(1000).to_s @primary_outcomes.each do |po| course.assessments << po.generate_assessment end dir = Dir.mktmpdir file = CanvasCc::CanvasCC::CartridgeCreator.new(course).create(dir) FileUtils.mv(file, "./#{filename.downcase.gsub(' ', '_')}.zip") end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/csv2qti/course.rb', line 34 def to_s @primary_outcomes.inject("#{title}\nOutcomes:") { |s, o| s + "\n" + o.to_s } end |