Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/common_cartridge/elements/organizations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module CommonCartridge
module Elements
module Organizations

class Item
attr_accessor :type

Expand Down
57 changes: 43 additions & 14 deletions lib/common_cartridge/elements/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ module CommonCartridge
module Elements
module Resources

def self.type_mappings
{
Topic.pattern => Topic,
WebLink.pattern => WebLink,
Assignment.pattern => Assignment,
Assessment.pattern => Assessment,
Page.pattern => Page,
BasicLtiLink::BasicLtiLink.pattern => BasicLtiLink::BasicLtiLink
}
end

def self.type_mappings
{
Topic.pattern => Topic,
WebLink.pattern => WebLink,
Assignment.pattern => Assignment,
Assessment.pattern => Assessment,
Page.pattern => Page,
BasicLtiLink::BasicLtiLink.pattern => BasicLtiLink::BasicLtiLink
}
end

class Content
include SAXMachine
Expand Down Expand Up @@ -61,7 +60,33 @@ class File
element :attachments, class: Attachments::RootAttachment, as: :attachment_root
elements :dependency, class: Dependency, as: :dependencies

def attachments; attachment_root.attachments; end
def attachments
attachment_root.attachments;
end
end

class EndUserRole
include SAXMachine

element 'lom:value', as: :role
end

class Educational
include SAXMachine

element 'lom:intendedEndUserRole', class: CommonCartridge::Elements::Resources::EndUserRole, as: :end_user_role
end

class Lom
include SAXMachine

element 'lom:educational', class: CommonCartridge::Elements::Resources::Educational, as: :educational
end

class Metadata
include SAXMachine

element 'lom:lom', class: CommonCartridge::Elements::Resources::Lom, as: :lom
end

class Resource
Expand All @@ -76,13 +101,17 @@ class Resource

elements :file, class: File, as: :files
elements :dependency, class: Dependency, as: :dependencies
element :metadata, class: CommonCartridge::Elements::Resources::Metadata, as: :metadata

def role
metadata&.lom&.educational&.end_user_role&.role
end

# Switch statement based on 'type'
def points_possible
@points_possible ||= if dependency = dependencies.detect { |d| d.points_possible && !d.points_possible.empty? }
dependency.points_possible
end
dependency.points_possible
end
end

def title
Expand Down
11 changes: 11 additions & 0 deletions lib/common_cartridge/elements/resources/basic_lti_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class VendorContact
element 'lticp:email', as: :email
end

class Custom
include SAXMachine

element 'lticm:property', as: :type, with: {
name: "type"
}
end

class Vendor
include SAXMachine

Expand Down Expand Up @@ -48,6 +56,9 @@ class BasicLtiLink
element 'blti:description', as: :description
element 'blti:secure_launch_url', as: :secure_launch_url
element 'blti:launch_url', as: :launch_url
element 'blti:custom', class: Custom, as: :custom

element 'blti:icon', as: :icon
element 'blti:vendor', class: Vendor, as: :vendor

elements 'blti:extensions', class: Extension, as: :extensions
Expand Down