Class: Qti::V1::Models::QuestionGroup
- Inherits:
-
Base
show all
- Defined in:
- lib/qti/v1/models/question_group.rb
Instance Attribute Summary collapse
Attributes inherited from Models::Base
#manifest, #package_root, #path, #resource
Instance Method Summary
collapse
Methods inherited from Base
#qti_version, #return_inner_content!, #sanitize_attributes, #sanitize_attributes_by_node
#css_with_single_check, from_path!, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check
Constructor Details
#initialize(item, package_root = nil) ⇒ QuestionGroup
Returns a new instance of QuestionGroup.
7
8
9
10
11
|
# File 'lib/qti/v1/models/question_group.rb', line 7
def initialize(item, package_root = nil)
@doc = item
@path = item.document.url
self.package_root = package_root
end
|
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
5
6
7
|
# File 'lib/qti/v1/models/question_group.rb', line 5
def doc
@doc
end
|
Instance Method Details
#assessment_item_refs ⇒ Object
17
18
19
|
# File 'lib/qti/v1/models/question_group.rb', line 17
def assessment_item_refs
items
end
|
#create_assessment_item(assessment_item) ⇒ Object
21
22
23
|
# File 'lib/qti/v1/models/question_group.rb', line 21
def create_assessment_item(assessment_item)
Qti::V1::Models::AssessmentItem.new(assessment_item)
end
|
#group_item?(item) ⇒ Boolean
61
62
63
|
# File 'lib/qti/v1/models/question_group.rb', line 61
def group_item?(item)
item.xpath('../section').first&.dig('ident') == ident
end
|
#identifier ⇒ Object
53
54
55
|
# File 'lib/qti/v1/models/question_group.rb', line 53
def identifier
@identifier ||= @doc.attribute('ident').value
end
|
#items ⇒ Object
25
26
27
|
# File 'lib/qti/v1/models/question_group.rb', line 25
def items
@doc.xpath('.//xmlns:item')
end
|
#parent_stimulus_item_ident ⇒ Object
45
46
47
|
# File 'lib/qti/v1/models/question_group.rb', line 45
def parent_stimulus_item_ident
@parent_stimulus_item_ident ||= @doc.attribute('parent_stimulus_item_ident')&.value
end
|
#points_per_item ⇒ Object
49
50
51
|
# File 'lib/qti/v1/models/question_group.rb', line 49
def points_per_item
selection.xpath('xmlns:selection_extension/xmlns:points_per_item')&.text&.to_f
end
|
#selection ⇒ Object
29
30
31
|
# File 'lib/qti/v1/models/question_group.rb', line 29
def selection
@doc.xpath('xmlns:selection_ordering/xmlns:selection')
end
|
#selection_number ⇒ Object
33
34
35
|
# File 'lib/qti/v1/models/question_group.rb', line 33
def selection_number
selection&.xpath('xmlns:selection_number')&.text&.to_i
end
|
#sourcebank_export_id ⇒ Object
41
42
43
|
# File 'lib/qti/v1/models/question_group.rb', line 41
def sourcebank_export_id
selection&.xpath('xmlns:sourcebank_export_id')&.text
end
|
#sourcebank_ref ⇒ Object
37
38
39
|
# File 'lib/qti/v1/models/question_group.rb', line 37
def sourcebank_ref
selection&.xpath('xmlns:sourcebank_ref')&.text
end
|
#test_object ⇒ Object
13
14
15
|
# File 'lib/qti/v1/models/question_group.rb', line 13
def test_object
self
end
|
#title ⇒ Object
57
58
59
|
# File 'lib/qti/v1/models/question_group.rb', line 57
def title
@title ||= @doc.attribute('title').value
end
|