Class: Qti::V1::Models::Interactions::UploadInteraction

Inherits:
BaseInteraction show all
Defined in:
lib/qti/v1/models/interactions/upload_interaction.rb

Instance Attribute Summary

Attributes inherited from BaseInteraction

#node

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path, #resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseInteraction

#answer_feedback, canvas_custom_fitb?, #canvas_item_feedback, canvas_multiple_fib?, #initialize, #locked_choices, maybe_question_type, new_quizzes_fib?, question_type, #rcardinality, #shuffled?

Methods inherited from Base

#qti_version, #return_inner_content!, #sanitize_attributes, #sanitize_attributes_by_node

Methods inherited from Models::Base

#css_with_single_check, from_path!, #initialize, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check

Constructor Details

This class inherits a constructor from Qti::V1::Models::Interactions::BaseInteraction

Class Method Details

.matches(node, parent) ⇒ Object

This will know if a class matches



7
8
9
10
11
12
13
14
15
# File 'lib/qti/v1/models/interactions/upload_interaction.rb', line 7

def self.matches(node, parent)
  meta_node = node.at_xpath(
    './/xmlns:qtimetadatafield[./xmlns:fieldlabel/text()="question_type"]'
  )
  return false unless meta_node.present?
  type_node = meta_node.at_xpath('.//xmlns:fieldentry')
  return false unless type_node&.text() == 'file_upload_question'
  new(node, parent)
end

Instance Method Details

#allowed_typesObject



31
32
33
# File 'lib/qti/v1/models/interactions/upload_interaction.rb', line 31

def allowed_types
  @allowed_types ||= @node.at_xpath('.//xmlns:presentation/@allowed_types')&.value
end

#files_countObject



35
36
37
# File 'lib/qti/v1/models/interactions/upload_interaction.rb', line 35

def files_count
  @files_count ||= @node.at_xpath('.//xmlns:presentation/@files_count')&.value
end

#item_bodyObject



17
18
19
20
21
22
23
24
25
# File 'lib/qti/v1/models/interactions/upload_interaction.rb', line 17

def item_body
  @item_body ||= begin
    node = @node.dup
    presentation = node.at_xpath('.//xmlns:presentation')
    mattext = presentation.at_xpath('.//xmlns:mattext')
    inner_content = return_inner_content!(mattext)
    sanitize_content!(inner_content)
  end
end

#scoring_data_structsObject



27
28
29
# File 'lib/qti/v1/models/interactions/upload_interaction.rb', line 27

def scoring_data_structs
  { value: '' }
end