Class: Qti::AssessmentItemExporter
- Inherits:
-
Object
- Object
- Qti::AssessmentItemExporter
- Defined in:
- lib/qti/assessment_item_exporter.rb
Instance Attribute Summary collapse
-
#assessment_item ⇒ Object
readonly
Returns the value of attribute assessment_item.
-
#package_root_path ⇒ Object
readonly
Returns the value of attribute package_root_path.
Instance Method Summary collapse
- #export ⇒ Object
- #exported_file_path ⇒ Object
-
#initialize(assessment_item, args = {}) ⇒ AssessmentItemExporter
constructor
A new instance of AssessmentItemExporter.
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_item ⇒ Object (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_path ⇒ Object (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
#export ⇒ Object
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_path ⇒ Object
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 |