Class: ScormEngine::Models::CourseImport
- Defined in:
- lib/scorm_engine/models/course_import.rb
Instance Attribute Summary collapse
- #course ⇒ ScormEngine::Models::Course
-
#id ⇒ String
The ID of this course import (not the course id).
- #parser_warnings ⇒ Array<String>
-
#status ⇒ String
(RUNNING, COMPLETE, ERROR).
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Instance Attribute Details
#course ⇒ ScormEngine::Models::Course
23 24 25 |
# File 'lib/scorm_engine/models/course_import.rb', line 23 def course @course end |
#id ⇒ String
The ID of this course import (not the course id)
8 9 10 |
# File 'lib/scorm_engine/models/course_import.rb', line 8 def id @id end |
#parser_warnings ⇒ Array<String>
18 19 20 |
# File 'lib/scorm_engine/models/course_import.rb', line 18 def parser_warnings @parser_warnings end |
#status ⇒ String
Returns (RUNNING, COMPLETE, ERROR).
13 14 15 |
# File 'lib/scorm_engine/models/course_import.rb', line 13 def status @status end |
Class Method Details
.new_from_api(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/scorm_engine/models/course_import.rb', line 25 def self.new_from_api( = {}) this = new this. = .dup if .key?("importResult") # API v2 response import_result = ["importResult"] || {} this.id = ["jobId"] || ["result"] this.status = (["status"] || import_result["status"])&.upcase this.parser_warnings = import_result["parserWarnings"] this.course = Course.new_from_api(import_result["course"]) if import_result.key?("course") elsif .keys == ["result"] # Initial import response (legacy format: {"result" => "job-id"}) this.id = ["result"] this.status = "RUNNING" else # API v1 or full status response this.id = ["jobId"] this.status = ["status"]&.upcase this.parser_warnings = ["parserWarnings"] this.course = Course.new_from_api(["course"]) if .key?("course") end this end |
Instance Method Details
#complete? ⇒ Boolean
64 65 66 |
# File 'lib/scorm_engine/models/course_import.rb', line 64 def complete? status == "COMPLETE" end |
#completed? ⇒ Boolean
68 69 70 |
# File 'lib/scorm_engine/models/course_import.rb', line 68 def completed? status == "COMPLETED" end |
#error? ⇒ Boolean
60 61 62 |
# File 'lib/scorm_engine/models/course_import.rb', line 60 def error? status == "ERROR" end |
#running? ⇒ Boolean
56 57 58 |
# File 'lib/scorm_engine/models/course_import.rb', line 56 def running? status == "RUNNING" end |