Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues we encountered with production scorm files #3

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
4 changes: 2 additions & 2 deletions lib/scorm.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Scorm
VERSION = '1.0.2'
VERSION = '1.0.4'
end

require 'scorm/package'
require 'scorm/package'
18 changes: 18 additions & 0 deletions lib/scorm/datatypes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ def to_s
sec -= min*60
return "#{hours}:#{min}:#{sec}"
end

def to_scorm_s
sec = self.to_f
hours = (sec/60/60).to_i
sec -= hours*60*60
min = (sec/60).to_i
sec -= min*60
sec = (sec*100).round/100.0

rtn_str = "PT"
if hours > 0
rtn_str += "#{hours}H"
end
if min > 0
rtn_str += "#{min}M"
end
rtn_str += "#{sec}S"
end
end

end
Expand Down
15 changes: 12 additions & 3 deletions lib/scorm/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,28 @@ def initialize(id, type, scorm_type, href = nil, metadata = nil, files = nil, de
def self.from_xml(element)
metadata = nil
files = []
xml_base = element.attribute('xml:base').to_s

REXML::XPath.each(element, 'file') do |file_el|
files << element.attribute('xml:base').to_s + file_el.attribute('href').to_s
file = file_el.attribute('href').to_s
if xml_base.end_with?('/') || file.start_with?('/')
files << xml_base + file
else
files << xml_base + '/' + file
end
end
dependencies = []
REXML::XPath.each(element, 'dependency') do |dep_el|
dependencies << dep_el.attribute('identifierref').to_s
end




res = self.new(
element.attribute('identifier'),
element.attribute('type'),
element.attribute('scormType', 'adlcp') || element.attribute('scormtype', 'adlcp'),
element.attribute('xml:base').to_s + element.attribute('href').to_s,
xml_base + element.attribute('href').to_s,
metadata,
files,
dependencies)
Expand Down
4 changes: 2 additions & 2 deletions scorm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ Gem::Specification.new do |s|
s.executables = ['scorm']
s.default_executable = 'scorm'

s.add_dependency('rubyzip', '~> 0.9.4')
end
s.add_dependency('rubyzip', '~> 1.0.0')
end