Class: ScormEngine::Models::Course
- Defined in:
- lib/scorm_engine/models/course.rb
Instance Attribute Summary collapse
-
#course_learning_standard ⇒ String
The course’s learning standard.
-
#description ⇒ String
The description of this course.
-
#id ⇒ String
The external identification of this course.
- #registration_count ⇒ Integer
-
#scaled_passing_score ⇒ Integer
The score required of a learner to pass this course.
-
#title ⇒ String
The title of this course.
- #updated ⇒ Time
-
#version ⇒ Integer
The version of this course.
-
#web_path ⇒ String
The web path at which the course’s contents is hosted.
Class Method Summary collapse
-
.get_scaled_passing_score_from_api(options = {}) ⇒ Integer
Extract and normalize the scaled passing score from the API options.
-
.get_title_from_api(options = {}) ⇒ String
Extract and sanitize the title from the API options.
- .new_from_api(options = {}) ⇒ Object
Methods inherited from Base
Instance Attribute Details
#course_learning_standard ⇒ String
The course’s learning standard.
44 45 46 |
# File 'lib/scorm_engine/models/course.rb', line 44 def course_learning_standard @course_learning_standard end |
#description ⇒ String
The description of this course.
34 35 36 |
# File 'lib/scorm_engine/models/course.rb', line 34 def description @description end |
#id ⇒ String
The external identification of this course.
9 10 11 |
# File 'lib/scorm_engine/models/course.rb', line 9 def id @id end |
#registration_count ⇒ Integer
24 25 26 |
# File 'lib/scorm_engine/models/course.rb', line 24 def registration_count @registration_count end |
#scaled_passing_score ⇒ Integer
The score required of a learner to pass this course.
39 40 41 |
# File 'lib/scorm_engine/models/course.rb', line 39 def scaled_passing_score @scaled_passing_score end |
#title ⇒ String
The title of this course.
19 20 21 |
# File 'lib/scorm_engine/models/course.rb', line 19 def title @title end |
#updated ⇒ Time
29 30 31 |
# File 'lib/scorm_engine/models/course.rb', line 29 def updated @updated end |
#version ⇒ Integer
The version of this course.
14 15 16 |
# File 'lib/scorm_engine/models/course.rb', line 14 def version @version end |
#web_path ⇒ String
The web path at which the course’s contents is hosted. For AICC courses, refer to the href proprety of the child activities as this value will not be available.
51 52 53 |
# File 'lib/scorm_engine/models/course.rb', line 51 def web_path @web_path end |
Class Method Details
.get_scaled_passing_score_from_api(options = {}) ⇒ Integer
Extract and normalize the scaled passing score from the API options.
96 97 98 99 100 101 102 103 |
# File 'lib/scorm_engine/models/course.rb', line 96 def self.get_scaled_passing_score_from_api( = {}) first_child = .fetch("rootActivity", {}).fetch("children", [{}]).first score = first_child.is_a?(Hash) ? first_child["scaledPassingScore"] : nil return if score.nil? score = score.to_f score *= 100 if score <= 1.0 score.to_i end |
.get_title_from_api(options = {}) ⇒ String
Extract and sanitize the title from the API options.
Special consideration is given to two commonly found, but useless titles which if found will result in a blank title.
81 82 83 84 85 |
# File 'lib/scorm_engine/models/course.rb', line 81 def self.get_title_from_api( = {}) title = ScormEngine::Utils.sanitized_text(["title"]) title = "" if ["Title", "Captivate E-Learning Course"].include?(title) title end |
.new_from_api(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/scorm_engine/models/course.rb', line 53 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] this.version = ["version"] this.title = get_title_from_api() this.registration_count = ["registrationCount"] this.updated = Time.parse(["updated"]) if .key?("updated") this.description = .fetch("metadata", {})["description"] this.scaled_passing_score = get_scaled_passing_score_from_api() this.course_learning_standard = ["courseLearningStandard"]&.upcase this.web_path = ["webPath"] this end |