Class: CommonCartridge::Elements::Resources::Resource

Inherits:
Object
  • Object
show all
Includes:
SAXMachine
Defined in:
lib/common_cartridge/elements/resources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#points_possibleObject

Switch statement based on ‘type’



81
82
83
84
85
# File 'lib/common_cartridge/elements/resources.rb', line 81

def points_possible
  @points_possible ||= if dependency = dependencies.detect { |d| d.points_possible && !d.points_possible.empty? }
    dependency.points_possible
  end
end

#question_countObject

Returns the value of attribute question_count.



67
68
69
# File 'lib/common_cartridge/elements/resources.rb', line 67

def question_count
  @question_count
end

#titleObject



87
88
89
90
91
92
93
# File 'lib/common_cartridge/elements/resources.rb', line 87

def title
  @title ||= if file = files.detect { |f| f.content && f.content.title && !f.content.title.empty? }
               file.content.title
             elsif dependency = dependencies.detect { |d| d.title && !d.title.empty? }
               dependency.title
             end
end

Instance Method Details

#file_locationsObject



95
96
97
98
99
100
101
102
# File 'lib/common_cartridge/elements/resources.rb', line 95

def file_locations
  [
    ::File.join(identifier, "assessment.xml"),
    ::File.join(identifier, "assessment_qti.xml"),
    ::File.join("non_cc_assessments", "#{identifier}.xml"),
    ::File.join("non_cc_assessments", "#{identifier}.xml.qti")
  ]
end

#is_announcement?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/common_cartridge/elements/resources.rb', line 104

def is_announcement?
  !!dependencies.collect(&:contents).flatten.detect { |c| c.type == 'announcement' }
end