class Qti::V2::Models::AssessmentItem
Constants
- ScoringData
Public Instance Methods
feedback()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 44 def feedback @feedback ||= interaction_model.canvas_item_feedback end
identifier()
click to toggle source
Not used yet
# File lib/qti/v2/models/assessment_item.rb, line 19 def identifier @identifier ||= xpath_with_single_check('//xmlns:assessmentItem/@identifier').content end
interaction_model()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 34 def interaction_model @interaction_model ||= begin V2::Models::Interactions.interaction_model(@doc, self) end end
item_body()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 7 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_item_body(node) node.add_child(prompt) if prompt&.parent && prompt.parent != node sanitize_content!(node.to_html) end end
points_possible()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 27 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()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 40 def scoring_data_structs @scoring_data_structs ||= interaction_model.scoring_data_structs end
title()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 23 def title @title ||= xpath_with_single_check('//xmlns:assessmentItem/@title').content end
Private Instance Methods
dependency_hrefs()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 63 def dependency_hrefs return [] unless manifest manifest.doc.xpath("//xmlns:resource[@href='#{relative_path}']/xmlns:dependency/@identifierref").map do |id| manifest.xpath_with_single_check("//xmlns:resource[@identifier='#{id}']/@href") end end
filter_item_body(node)
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 54 def filter_item_body(node) # Filter undesired interaction nodes out of the list (need to make this a deep traversal) node.children.filter(INTERACTION_ELEMENTS_CSS).map(&:unlink) # Filter out rubrics node.children.filter('rubricBlock').map(&:unlink) # Filter out stimulus passages (these will be handled separately) filter_stimulus_passages!(node) end
filter_stimulus_passages!(node)
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 70 def filter_stimulus_passages!(node) dependency_hrefs.each do |href| node.at_css("object[type='text/html'][data='#{href}']").try(:unlink) end end
item_body_node()
click to toggle source
# File lib/qti/v2/models/assessment_item.rb, line 50 def item_body_node @item_body_node ||= xpath_with_single_check('//xmlns:itemBody') end