Class: Qti::AssessmentItemExporter

Inherits:
Object
  • Object
show all
Defined in:
lib/qti/assessment_item_exporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assessment_item, args = {}) ⇒ AssessmentItemExporter

Returns a new instance of AssessmentItemExporter.



5
6
7
8
# File 'lib/qti/assessment_item_exporter.rb', line 5

def initialize(assessment_item, args = {})
  @assessment_item = assessment_item
  @package_root_path = args[:package_root_path] || '.'
end

Instance Attribute Details

#assessment_itemObject (readonly)

Returns the value of attribute assessment_item.



3
4
5
# File 'lib/qti/assessment_item_exporter.rb', line 3

def assessment_item
  @assessment_item
end

#package_root_pathObject (readonly)

Returns the value of attribute package_root_path.



3
4
5
# File 'lib/qti/assessment_item_exporter.rb', line 3

def package_root_path
  @package_root_path
end

Instance Method Details

#exportObject



14
15
16
17
18
# File 'lib/qti/assessment_item_exporter.rb', line 14

def export
  File.open(exported_file_path, 'wb') do |f|
    f.write xml_string_for_assessment_item
  end
end

#exported_file_pathObject



10
11
12
# File 'lib/qti/assessment_item_exporter.rb', line 10

def exported_file_path
  @exported_file_path ||= File.join(package_root_path, "#{assessment_item.identifier}.xml")
end