scorm-package 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6c845da6facaddb39a95ceda211bc5f65916e26bcadd79df356fb34b5d1bc8f
4
- data.tar.gz: 8ec19304fc472e74a9c21058a2e2e579ab5f2be5dd2a68a5e8dfed0edaf7e6b1
3
+ metadata.gz: c77235f46904e9d96f27cd7921747dfe4f8ff663f5407e825ab95e3c4b2dfbf4
4
+ data.tar.gz: 22d29281fbcdf7d62d7335e73236c81ed067205a8df992159eb2d988b9eb6836
5
5
  SHA512:
6
- metadata.gz: ac99c8c52027ceed7dc9c8180883ec82d45d0bd4926a07e04e85fbc15c7169e0bbff194ce0c42e19afe8dbe7da2619acc30b8cecd387f0146bc2a792056738d1
7
- data.tar.gz: 978bf31fcd77485a62b7a7dcb73be8f94e405a51229d20b7117b7bb81c3975cf2626c40d40ef200cd868098038596c5aa4af789b8212ee639c22e60eac51f6ea
6
+ metadata.gz: 6441635343f691037c0d2027d4644807b753cd39baa911f6ce900306ab9e83818cf78bab81dd1131802dc9d9ff59ab6de4aa50810354d1554d9605d172978def
7
+ data.tar.gz: f66403c1a34352d07021d2921db7ff383e56084fd4ff649bb4fbb4fae3524479fd1bc7ce89f946b7f4a4c08a964dfec237fd00cd7dc5748649212d4271f70a28
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ### [0.1.2](https://www.github.com/openvitae-tech/scorm-package/compare/v0.1.1...v0.1.2) (2025-02-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * updated gemfile ([6ef33e9](https://www.github.com/openvitae-tech/scorm-package/commit/6ef33e9b6e74373a937e8d41073be9132c5961bc))
9
+ * updated version ([f8d1470](https://www.github.com/openvitae-tech/scorm-package/commit/f8d14701f84d009494b919eeebe325d05ced3e10))
10
+
11
+ ### [0.1.1](https://www.github.com/openvitae-tech/scorm-package/compare/v0.1.0...v0.1.1) (2025-02-10)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * test auto version upgrade ([fea7dd4](https://www.github.com/openvitae-tech/scorm-package/commit/fea7dd4c0a756179251f112032fe258d3278cf19))
17
+
18
+ ## 0.3.1 (2025-02-10)
19
+
20
+ ### Features
21
+
22
+ - Release 0.3.1 ([3b42b6c](https://www.github.com/openvitae-tech/scorm-package/commit/3b42b6ce908929776a69de67c159dc0a67388645))
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Scorm Packaging gem
2
2
 
3
- ## Local development with Host Application
3
+ ## Local development with the Host Application
4
4
 
5
5
  ### Installation
6
6
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ScormPackage
4
+ class BaseCourse
5
+ ABSTRACT_METHODS = %i[title description course_modules].freeze
6
+
7
+ def initialize
8
+ raise "Cannot initialize an abstract BaseCourse class" if instance_of?(BaseCourse)
9
+
10
+ missing_methods = ABSTRACT_METHODS.reject { |method| respond_to?(method) }
11
+ return if missing_methods.empty?
12
+
13
+ raise NotImplementedError, "#{self.class} must implement methods: #{missing_methods.join(", ")}"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ScormPackage
4
+ class BaseCourseModule
5
+ ABSTRACT_METHODS = %i[title lessons].freeze
6
+
7
+ def initialize
8
+ raise "Cannot initialize an abstract BaseCourseModule class" if instance_of?(BaseCourseModule)
9
+
10
+ missing_methods = ABSTRACT_METHODS.reject { |method| respond_to?(method) }
11
+ return if missing_methods.empty?
12
+
13
+ raise NotImplementedError, "#{self.class} must implement methods: #{missing_methods.join(", ")}"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ScormPackage
4
+ class BaseLesson
5
+ ABSTRACT_METHODS = %i[title videos].freeze
6
+
7
+ def initialize
8
+ raise "Cannot initialize an abstract BaseLesson class" if instance_of?(BaseLesson)
9
+
10
+ missing_methods = ABSTRACT_METHODS.reject { |method| respond_to?(method) }
11
+ return if missing_methods.empty?
12
+
13
+ raise NotImplementedError, "#{self.class} must implement methods: #{missing_methods.join(", ")}"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ScormPackage
4
+ class BaseVideo
5
+ ABSTRACT_METHODS = %i[id language video_url].freeze
6
+
7
+ def initialize
8
+ raise "Cannot initialize an abstract BaseVideo class" if instance_of?(BaseVideo)
9
+
10
+ missing_methods = ABSTRACT_METHODS.reject { |method| respond_to?(method) }
11
+ return if missing_methods.empty?
12
+
13
+ raise NotImplementedError, "#{self.class} must implement methods: #{missing_methods.join(", ")}"
14
+ end
15
+ end
16
+ end
@@ -4,15 +4,14 @@ require_relative "create_zip"
4
4
 
5
5
  module ScormPackage
6
6
  module Packaging
7
- class Generate
8
- attr_reader :course, :scorm_token
7
+ class Generator
8
+ attr_reader :course
9
9
 
10
- def initialize(course, scorm_token)
10
+ def initialize(course)
11
11
  @course = course
12
- @scorm_token = scorm_token
13
12
  end
14
13
 
15
- def process
14
+ def generate
16
15
  manifest = generate_manifest
17
16
  lessons_html = generate_lesson_contents
18
17
  ScormPackage::Packaging::CreateZip.new(manifest, lessons_html).process
@@ -84,6 +83,18 @@ module ScormPackage
84
83
  end.join
85
84
  end
86
85
 
86
+ def generate_lesson_contents
87
+ lessons_hash = {}
88
+
89
+ course.course_modules.each_with_index do |mod, mod_index|
90
+ mod.lessons.each_with_index do |lesson, lesson_index|
91
+ lesson_path = "content/module#{mod_index + 1}/lesson#{lesson_index + 1}.html"
92
+ lessons_hash[lesson_path] = generate_lesson_html(lesson)
93
+ end
94
+ end
95
+ lessons_hash
96
+ end
97
+
87
98
  def generate_lesson_html(lesson)
88
99
  <<~HTML
89
100
  <!DOCTYPE html>
@@ -94,50 +105,30 @@ module ScormPackage
94
105
  <script src="../../scormfunctions.js"></script>
95
106
  <title>#{lesson.title}</title>
96
107
  <style>
97
- .loader { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); }
108
+ .loader { display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); }
98
109
  iframe { display: none; width: 560px; height: 315px; border: none; }
99
110
  </style>
100
111
  </head>
101
112
  <body>
102
113
  <p>Lesson: #{lesson.title}</p>
103
- <ul>#{lesson.videos.map do |video|
104
- "<li>Language: #{video[:language]}<br>" \
105
- "<div id=\"loader-#{video[:id]}\" class=\"loader\">Loading...</div>" \
106
- "<iframe id=\"custom-iframe-#{video[:id]}\" data-video-url=\"#{video[:video_url]}\"></iframe></li>"
107
- end.join}</ul>
114
+ <ul>
115
+ #{lesson.videos.map do |video|
116
+ "<li>Language: #{video.language}<br>" \
117
+ "<div id=\"loader-#{video.id}\" class=\"loader\">Loading...</div>" \
118
+ "<iframe id=\"iframe-#{video.id}\" src=\"#{video.video_url}\" onload=\"hideLoader('#{video.id}')\"></iframe></li>"
119
+ end.join}
120
+ </ul>
121
+
108
122
  <script>
109
- const loadIframe = async (iframe) => {
110
- const loader = document.getElementById(`loader-${iframe.id.split('-').pop()}`);
111
- try {
112
- loader.style.display = 'block';
113
- const response = await fetch(iframe.dataset.videoUrl, {
114
- headers: { 'X-Scorm-Token': '#{scorm_token}' }
115
- });
116
- iframe.srcdoc = await response.text();
117
- iframe.style.display = 'block';
118
- } catch (error) { console.error(error); }
119
- finally { loader.style.display = 'none'; }
120
- };
121
- window.addEventListener('load', () =>
122
- document.querySelectorAll('iframe[data-video-url]').forEach(loadIframe)
123
- );
123
+ function hideLoader(videoId) {
124
+ document.getElementById('loader-' + videoId).style.display = 'none';
125
+ document.getElementById('iframe-' + videoId).style.display = 'block';
126
+ }
124
127
  </script>
125
128
  </body>
126
129
  </html>
127
130
  HTML
128
131
  end
129
-
130
- def generate_lesson_contents
131
- lessons_hash = {}
132
-
133
- course.course_modules.each_with_index do |mod, mod_index|
134
- mod.lessons.each_with_index do |lesson, lesson_index|
135
- lesson_path = "content/module#{mod_index + 1}/lesson#{lesson_index + 1}.html"
136
- lessons_hash[lesson_path] = generate_lesson_html(lesson)
137
- end
138
- end
139
- lessons_hash
140
- end
141
132
  end
142
133
  end
143
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ScormPackage
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/scorm_package.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "scorm_package/version"
4
- require_relative "scorm_package/abstract_course"
5
- require_relative "scorm_package/abstract_course_module"
6
- require_relative "scorm_package/abstract_lesson"
7
- require_relative "scorm_package/packaging/generate"
4
+ require_relative "scorm_package/base_course"
5
+ require_relative "scorm_package/base_course_module"
6
+ require_relative "scorm_package/base_lesson"
7
+ require_relative "scorm_package/base_video"
8
+ require_relative "scorm_package/packaging/generator"
8
9
 
9
10
  module ScormPackage
10
11
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scorm-package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Sojan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-29 00:00:00.000000000 Z
11
+ date: 2025-02-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -19,20 +19,22 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".rspec"
21
21
  - ".rubocop.yml"
22
+ - CHANGELOG.md
22
23
  - LICENSE.txt
23
24
  - README.md
24
25
  - Rakefile
25
26
  - lib/scorm_package.rb
26
- - lib/scorm_package/abstract_course.rb
27
- - lib/scorm_package/abstract_course_module.rb
28
- - lib/scorm_package/abstract_lesson.rb
27
+ - lib/scorm_package/base_course.rb
28
+ - lib/scorm_package/base_course_module.rb
29
+ - lib/scorm_package/base_lesson.rb
30
+ - lib/scorm_package/base_video.rb
29
31
  - lib/scorm_package/packaging/common/adlcp_rootv1p2.xsd
30
32
  - lib/scorm_package/packaging/common/ims_xml.xsd
31
33
  - lib/scorm_package/packaging/common/imscp_rootv1p1p2.xsd
32
34
  - lib/scorm_package/packaging/common/imsmd_rootv1p2p1.xsd
33
35
  - lib/scorm_package/packaging/common/scormfunctions.js
34
36
  - lib/scorm_package/packaging/create_zip.rb
35
- - lib/scorm_package/packaging/generate.rb
37
+ - lib/scorm_package/packaging/generator.rb
36
38
  - lib/scorm_package/version.rb
37
39
  - sig/scorm_package.rbs
38
40
  homepage: https://github.com/openvitae-tech/scorm-package
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScormPackage
4
- class AbstractCourse
5
- def initialize
6
- raise "Cannot initialize an abstract Course class"
7
- end
8
-
9
- def title
10
- raise NotImplementedError, "#{self.class} must implement abstract method 'title'"
11
- end
12
-
13
- def description
14
- raise NotImplementedError, "#{self.class} must implement abstract method 'description'"
15
- end
16
-
17
- def course_modules
18
- raise NotImplementedError, "#{self.class} must implement abstract method 'course_modules'"
19
- end
20
- end
21
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScormPackage
4
- class AbstractCourseModule
5
- def initialize
6
- raise "Cannot initialize an abstract CourseModule class"
7
- end
8
-
9
- def title
10
- raise NotImplementedError, "#{self.class} must implement abstract method 'title'"
11
- end
12
-
13
- def lessons
14
- raise NotImplementedError, "#{self.class} must implement abstract method 'lessons'"
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ScormPackage
4
- class AbstractLesson
5
- def initialize
6
- raise "Cannot initialize an abstract Lesson class"
7
- end
8
-
9
- def title
10
- raise NotImplementedError, "#{self.class} must implement abstract method 'title'"
11
- end
12
-
13
- def videos
14
- raise NotImplementedError, "#{self.class} must implement abstract method 'videos'"
15
- end
16
- end
17
- end