Class: Qti::Importer
- Inherits:
-
Object
- Object
- Qti::Importer
- Defined in:
- lib/qti.rb
Instance Attribute Summary collapse
-
#assessment_id ⇒ Object
readonly
Returns the value of attribute assessment_id.
-
#package_root ⇒ Object
readonly
Returns the value of attribute package_root.
Class Method Summary collapse
Instance Method Summary collapse
- #assessment_item_refs ⇒ Object
- #create_assessment_item(assessment_item) ⇒ Object
- #create_bank_entry_item(bank_entry_item_ref) ⇒ Object
- #create_question_group(question_group_ref) ⇒ Object
- #create_stimulus(stimulus_ref) ⇒ Object
-
#initialize(path, assessment_id = nil) ⇒ Importer
constructor
A new instance of Importer.
- #stimulus_ref(assessment_item_ref) ⇒ Object
- #test_object ⇒ Object
Constructor Details
#initialize(path, assessment_id = nil) ⇒ Importer
Returns a new instance of Importer.
25 26 27 28 29 |
# File 'lib/qti.rb', line 25 def initialize(path, assessment_id = nil) @path, @package_root, @manifest = Importer.manifest(path) @assessment_id = assessment_id || @manifest.assessment_identifiers.first @import = @manifest.assessment_test(@assessment_id) end |
Instance Attribute Details
#assessment_id ⇒ Object (readonly)
Returns the value of attribute assessment_id.
20 21 22 |
# File 'lib/qti.rb', line 20 def assessment_id @assessment_id end |
#package_root ⇒ Object (readonly)
Returns the value of attribute package_root.
20 21 22 |
# File 'lib/qti.rb', line 20 def package_root @package_root end |
Class Method Details
.assessment_identifiers_for(path) ⇒ Object
31 32 33 |
# File 'lib/qti.rb', line 31 def self.assessment_identifiers_for(path) manifest(path)[2].assessment_identifiers end |
.manifest(path) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/qti.rb', line 42 def self.manifest(path) mpath = manifest_path(path) package_root = File.dirname(mpath) manifest = Qti::Models::Manifest.from_path!(mpath, package_root: package_root) [mpath, package_root, manifest] end |
.manifest_path(path) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/qti.rb', line 35 def self.manifest_path(path) Find.find(path) do |subdir| return subdir if subdir =~ /imsmanifest.xml\z/ end raise 'Manifest not found' end |
Instance Method Details
#assessment_item_refs ⇒ Object
53 54 55 |
# File 'lib/qti.rb', line 53 def assessment_item_refs @import.assessment_items end |
#create_assessment_item(assessment_item) ⇒ Object
57 58 59 |
# File 'lib/qti.rb', line 57 def create_assessment_item(assessment_item) @import.create_assessment_item(assessment_item) end |
#create_bank_entry_item(bank_entry_item_ref) ⇒ Object
73 74 75 |
# File 'lib/qti.rb', line 73 def create_bank_entry_item(bank_entry_item_ref) @import.create_bank_entry_item(bank_entry_item_ref) end |
#create_question_group(question_group_ref) ⇒ Object
69 70 71 |
# File 'lib/qti.rb', line 69 def create_question_group(question_group_ref) @import.create_question_group(question_group_ref) end |
#create_stimulus(stimulus_ref) ⇒ Object
65 66 67 |
# File 'lib/qti.rb', line 65 def create_stimulus(stimulus_ref) @import.create_stimulus(stimulus_ref) end |
#stimulus_ref(assessment_item_ref) ⇒ Object
61 62 63 |
# File 'lib/qti.rb', line 61 def stimulus_ref(assessment_item_ref) @import.stimulus_ref(assessment_item_ref) end |
#test_object ⇒ Object
49 50 51 |
# File 'lib/qti.rb', line 49 def test_object @import end |