Class: Qti::V2::Models::AssessmentItem
- Inherits:
-
Base
- Object
- Models::Base
- Base
- Qti::V2::Models::AssessmentItem
- Defined in:
- lib/qti/v2/models/assessment_item.rb
Defined Under Namespace
Classes: ScoringData
Constant Summary
Constants inherited from Base
Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS
Constants inherited from Models::Base
Instance Attribute Summary
Attributes inherited from Models::Base
Instance Method Summary collapse
-
#identifier ⇒ Object
Not used yet.
- #interaction_model ⇒ Object
- #item_body ⇒ Object
- #points_possible ⇒ Object
- #scoring_data_structs ⇒ Object
- #title ⇒ Object
Methods inherited from Base
Methods inherited from Models::Base
#css_with_single_check, from_path!, #initialize, #parse_xml, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!, #xpath_with_single_check
Constructor Details
This class inherits a constructor from Qti::Models::Base
Instance Method Details
#identifier ⇒ Object
Not used yet
25 26 27 |
# File 'lib/qti/v2/models/assessment_item.rb', line 25 def identifier @identifier ||= xpath_with_single_check('//xmlns:assessmentItem/@identifier').content end |
#interaction_model ⇒ Object
40 41 42 43 44 |
# File 'lib/qti/v2/models/assessment_item.rb', line 40 def interaction_model @interaction_model ||= begin V2::Models::Interactions.interaction_model(@doc) end end |
#item_body ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qti/v2/models/assessment_item.rb', line 10 def item_body @item_body ||= begin node = item_body_node.dup # ensure a prompt is carried into the html prompt = node.at_xpath('//xmlns:prompt') # Filter undesired interaction nodes out of the list (need to make this a deep traversal) node.children.filter(INTERACTION_ELEMENTS_CSS).map(&:unlink) node.add_child(prompt) if prompt&.parent && prompt.parent != node sanitize_content!(node.to_html) end end |
#points_possible ⇒ Object
33 34 35 36 37 38 |
# File 'lib/qti/v2/models/assessment_item.rb', line 33 def points_possible @points_possible ||= begin xpath_with_single_check("//xmlns:outcomeDeclaration[@identifier='SCORE']/@normalMaximum")&.content || xpath_with_single_check("//xmlns:outcomeDeclaration[@identifier='MAXSCORE']//xmlns:value")&.content end end |
#scoring_data_structs ⇒ Object
46 47 48 |
# File 'lib/qti/v2/models/assessment_item.rb', line 46 def scoring_data_structs @scoring_data_structs ||= interaction_model.scoring_data_structs end |
#title ⇒ Object
29 30 31 |
# File 'lib/qti/v2/models/assessment_item.rb', line 29 def title @title ||= xpath_with_single_check('//xmlns:assessmentItem/@title').content end |