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

#courseObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def course
  @course
end

#idObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def id
  @id
end

#parser_warningsObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def parser_warnings
  @parser_warnings
end

#statusObject

TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.



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

def status
  @status
end

Class Method Details

.new_from_api(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scorm_engine/models/course_import.rb', line 9

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"]
    this.parser_warnings = options.fetch("importResult", {})["parserWarnings"]
  else
    this.id = options["jobId"]
    this.status = options["status"]
    this.course = Course.new_from_api(options["course"]) if options.key?("course") # unavailable in error states
  end

  this
end

Instance Method Details

#complete?Boolean



34
35
36
# File 'lib/scorm_engine/models/course_import.rb', line 34

def complete?
  status == "COMPLETE"
end

#error?Boolean



30
31
32
# File 'lib/scorm_engine/models/course_import.rb', line 30

def error?
  status == "ERROR"
end

#running?Boolean



26
27
28
# File 'lib/scorm_engine/models/course_import.rb', line 26

def running?
  status == "RUNNING"
end