Class: ScormEngine::Models::CourseImport

Inherits:
Base
  • Object
show all
Defined in:
lib/scorm_engine/models/course_import.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_hash

Instance Attribute Details

#courseScormEngine::Models::Course



23
24
25
# File 'lib/scorm_engine/models/course_import.rb', line 23

def course
  @course
end

#idString

The ID of this course import (not the course id)

Returns:

  • (String)


8
9
10
# File 'lib/scorm_engine/models/course_import.rb', line 8

def id
  @id
end

#parser_warningsArray<String>

Returns:

  • (Array<String>)


18
19
20
# File 'lib/scorm_engine/models/course_import.rb', line 18

def parser_warnings
  @parser_warnings
end

#statusString

Returns (RUNNING, COMPLETE, ERROR).

Returns:

  • (String)

    (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
# File 'lib/scorm_engine/models/course_import.rb', line 25

def self.new_from_api(options = {})
  this = new
  this.options = options.dup

  if options.key?("importResult")
    this.id = options["result"]
    this.status = options.fetch("importResult", {})["status"]&.upcase
    this.parser_warnings = options.fetch("importResult", {})["parserWarnings"]
  else
    this.id = options["jobId"]
    this.status = options["status"]&.upcase
    this.course = Course.new_from_api(options["course"]) if options.key?("course") # unavailable in error states
  end

  this
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/scorm_engine/models/course_import.rb', line 50

def complete?
  status == "COMPLETE"
end

#error?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/scorm_engine/models/course_import.rb', line 46

def error?
  status == "ERROR"
end

#running?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/scorm_engine/models/course_import.rb', line 42

def running?
  status == "RUNNING"
end