Class: Qti::Importer

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, assessment_id = nil) ⇒ Importer

Returns a new instance of Importer.



24
25
26
27
28
# File 'lib/qti.rb', line 24

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_idObject (readonly)

Returns the value of attribute assessment_id.



19
20
21
# File 'lib/qti.rb', line 19

def assessment_id
  @assessment_id
end

#package_rootObject (readonly)

Returns the value of attribute package_root.



19
20
21
# File 'lib/qti.rb', line 19

def package_root
  @package_root
end

Class Method Details

.assessment_identifiers_for(path) ⇒ Object



30
31
32
# File 'lib/qti.rb', line 30

def self.assessment_identifiers_for(path)
  manifest(path)[2].assessment_identifiers
end

.manifest(path) ⇒ Object



41
42
43
44
45
46
# File 'lib/qti.rb', line 41

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



34
35
36
37
38
39
# File 'lib/qti.rb', line 34

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_refsObject



52
53
54
# File 'lib/qti.rb', line 52

def assessment_item_refs
  @import.assessment_items
end

#create_assessment_item(assessment_item) ⇒ Object



56
57
58
# File 'lib/qti.rb', line 56

def create_assessment_item(assessment_item)
  @import.create_assessment_item(assessment_item)
end

#create_bank_entry_item(bank_entry_item_ref) ⇒ Object



72
73
74
# File 'lib/qti.rb', line 72

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



68
69
70
# File 'lib/qti.rb', line 68

def create_question_group(question_group_ref)
  @import.create_question_group(question_group_ref)
end

#create_stimulus(stimulus_ref) ⇒ Object



64
65
66
# File 'lib/qti.rb', line 64

def create_stimulus(stimulus_ref)
  @import.create_stimulus(stimulus_ref)
end

#stimulus_ref(assessment_item_ref) ⇒ Object



60
61
62
# File 'lib/qti.rb', line 60

def stimulus_ref(assessment_item_ref)
  @import.stimulus_ref(assessment_item_ref)
end

#test_objectObject



48
49
50
# File 'lib/qti.rb', line 48

def test_object
  @import
end