Class: Scorm::Organization::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/scorm/organization.rb

Overview

An item has an id, title, and (in some cases) a parent item. An item is associated with a resource, which in most cases is a SCO (Shareable Content Object) resource.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, title, isvisible = true, parameters = nil, resource_id = nil, children = nil) ⇒ Item


50
51
52
53
54
55
56
57
# File 'lib/scorm/organization.rb', line 50

def initialize(id, title, isvisible = true, parameters = nil, resource_id = nil, children = nil)
  @id = id.to_s
  @title = title.to_s
  @isvisible = isvisible || true
  @parameters = parameters
  @resource_id = resource_id
  @children = children if children.is_a? Array
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children


45
46
47
# File 'lib/scorm/organization.rb', line 45

def children
  @children
end

#completion_thresholdObject

Returns the value of attribute completion_threshold


48
49
50
# File 'lib/scorm/organization.rb', line 48

def completion_threshold
  @completion_threshold
end

#data_from_lmsObject

Returns the value of attribute data_from_lms


47
48
49
# File 'lib/scorm/organization.rb', line 47

def data_from_lms
  @data_from_lms
end

#idObject

Returns the value of attribute id


40
41
42
# File 'lib/scorm/organization.rb', line 40

def id
  @id
end

#isvisibleObject

Returns the value of attribute isvisible


42
43
44
# File 'lib/scorm/organization.rb', line 42

def isvisible
  @isvisible
end

#parametersObject

Returns the value of attribute parameters


43
44
45
# File 'lib/scorm/organization.rb', line 43

def parameters
  @parameters
end

#resource_idObject

Returns the value of attribute resource_id


44
45
46
# File 'lib/scorm/organization.rb', line 44

def resource_id
  @resource_id
end

#time_limit_actionObject

Returns the value of attribute time_limit_action


46
47
48
# File 'lib/scorm/organization.rb', line 46

def time_limit_action
  @time_limit_action
end

#titleObject

Returns the value of attribute title


41
42
43
# File 'lib/scorm/organization.rb', line 41

def title
  @title
end

Class Method Details

.from_xml(element) ⇒ Object


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/scorm/organization.rb', line 59

def self.from_xml(element)
  item_id = element.attribute('identifier').to_s
  item_title = element.get_elements('title').first.text.to_s if element.get_elements('title').first
  item_isvisible = (element.attribute('isvisible').to_s == 'true')
  item_parameters = element.attribute('parameters').to_s
  children = []
  if element.get_elements('item').empty?
    resource_id = element.attribute('identifierref').to_s
  else
    element.each_element('item') do |item_el|
      child_item = self.from_xml(item_el)
      children << child_item
    end
  end
  return self.new(item_id, item_title, item_isvisible, item_parameters, resource_id, children)
end