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!

Methods inherited from Models::Base

#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.



10
11
12
13
14
# File 'lib/qti/v1/models/question_group.rb', line 10

def initialize(item, package_root = nil)
  @doc = item
  @path = item.document.url
  self.package_root = package_root
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



8
9
10
# File 'lib/qti/v1/models/question_group.rb', line 8

def doc
  @doc
end

Instance Method Details

#assessment_item_refsObject



20
21
22
# File 'lib/qti/v1/models/question_group.rb', line 20

def assessment_item_refs
  items
end

#create_assessment_item(assessment_item) ⇒ Object



24
25
26
# File 'lib/qti/v1/models/question_group.rb', line 24

def create_assessment_item(assessment_item)
  Qti::V1::Models::AssessmentItem.new(assessment_item)
end

#group_item?(item) ⇒ Boolean

Returns:

  • (Boolean)


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

def group_item?(item)
  item.xpath('../section').first&.dig('ident') == ident
end

#identifierObject



44
45
46
# File 'lib/qti/v1/models/question_group.rb', line 44

def identifier
  @identifier ||= @doc.attribute('ident').value
end

#itemsObject



28
29
30
# File 'lib/qti/v1/models/question_group.rb', line 28

def items
  @doc.xpath('.//xmlns:item')
end

#points_per_itemObject



40
41
42
# File 'lib/qti/v1/models/question_group.rb', line 40

def points_per_item
  selection.xpath('xmlns:selection_extension/xmlns:points_per_item')&.text&.to_f
end

#selectionObject



32
33
34
# File 'lib/qti/v1/models/question_group.rb', line 32

def selection
  @doc.xpath('xmlns:selection_ordering/xmlns:selection')
end

#selection_numberObject



36
37
38
# File 'lib/qti/v1/models/question_group.rb', line 36

def selection_number
  selection&.xpath('xmlns:selection_number')&.text&.to_i
end

#test_objectObject



16
17
18
# File 'lib/qti/v1/models/question_group.rb', line 16

def test_object
  self
end

#titleObject



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

def title
  @title ||= @doc.attribute('title').value
end