Skip to content

A manifest file parser/validator for SCORM 2004 4th Edition.

License

Notifications You must be signed in to change notification settings

tnoda/scorm2004-manifest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scorm2004-manifest

Description

scorm2004-manifest is a Ruby gem that provides a manifest file parser for SCORM 2004 4th edition. It parses and validates the manifest file according to SCORM 2004 4th Edition Content Aggregation Model (CAM) Version 1.1. After parsing and validating, it builds an object tree that captures XML’s hierarchical structure.

Installation

To install scorm2004-manifest, use the following command:

$ gem install scorm2004-manifest

Requirements

  • ruby 1.9.3

  • nokogiri

  • activesupport

Synopsis

require 'scorm2004-manifest'

# Parse a manifest file
begin
  manifest = Scorm2004::Manifest(open('imsmanifest.xml'))
rescue Scorm2004::Manifest::Error => e
  # An exception will be raised if validation fails.
  # The exception 'e' will be an instance of
  # Scorm2004::Manifest::Error's subclass.
end

# Traverse an object tree
manifest.identifier        # => "LMSTestPackage_CM-01"
manifest.version           # => "1.1.1"
organizations = manifest.organizations
organization = organizations.organizations[0]
organization.identifier    # => "CM-01"
organization.title.content # => "LMS Test Content Package CM-01 "
item_0 = organization.items[0]
item_0.title.content       # => "Activity 1"
item_0.identifier          # => "activity_1"
item_0.identifierref       # => "SEQ01"
item_0.parameters          # => "?tc=CM-01&act=1"
item_0.sequencing.limit_conditions.attempt_absolute_duration_limit
# => "P5Y6M4DT12H30M58S"
item_0.presentation.navigation_interface.hide_lmsuis.map(&:content)
# => ["continue", "previous", "suspendAll"]
# ...

For every XML element in a manifest file, XML attributes and child elements defined in Content Aggregation Model can be accessed using accessor methods whose names are underscored. Namespace prefixes are omitted from the accessor methods, except for either adlseq_objectives, adlseq_objective, or adlseq_map_info. If an element may have multiple child elements, the accessor method for the child elements will be pluralized. For example, <organizations> element has one or more <organization> elements.

# <organizations> can be accessed using the organizations
# method of the manifest object.
organizations = manifest.organizations

# The <organization> collection of the <organizations>
# element can be accessed using the organizations method
# of the organizations object. To get the first
# <organization> of the <organizations>, use the
# following expression.
organization_0 = organizations.organizations[0]

Each parsed element also responds to the to_hash method. Using this method, you can convert your manifest file into Hash or more useful forms.

json_manifest = Scorm2004::Manifest(open('imsmanifest.xml')).to_hash.to_json

Documentation

To generate scorm2004-manifest’s document set, use the following command:

$ git clone git://github.com/tnoda/scorm2004-manifest.git
$ cd scorm2004-manifest
$ rake yard

The document set will be generated under the doc directory.

Contributing to scorm2004-manifest

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 Takahiro Noda. See LICENSE.txt for further details.

About

A manifest file parser/validator for SCORM 2004 4th Edition.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages