Class: Moodle2CC::CanvasCC::Models::Course

Inherits:
Object
  • Object
show all
Defined in:
lib/moodle2cc/canvas_cc/models/course.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCourse

Returns a new instance of Course.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 7

def initialize
  @settings = {}
  @resources = []
  @canvas_modules = []
  @files = []
  @pages = []
  @discussions = []
  @assignments = []
  @assessments = []
  @question_banks = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 32

def method_missing(m, *args, &block)
  method = m.to_s
  if method[-1, 1] == '='
    method.chomp!('=')
    @settings[method.to_sym] = args.first
  end
  @settings[method.to_sym]
end

Instance Attribute Details

#assessmentsObject

Returns the value of attribute assessments.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def assessments
  @assessments
end

#assignmentsObject

Returns the value of attribute assignments.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def assignments
  @assignments
end

#canvas_modulesObject

Returns the value of attribute canvas_modules.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def canvas_modules
  @canvas_modules
end

Returns the value of attribute copyright.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def copyright
  @copyright
end

#discussionsObject

Returns the value of attribute discussions.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def discussions
  @discussions
end

#filesObject

Returns the value of attribute files.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def files
  @files
end

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def format
  @format
end

#identifierObject

Returns the value of attribute identifier.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def identifier
  @identifier
end

#pagesObject

Returns the value of attribute pages.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def pages
  @pages
end

#question_banksObject

Returns the value of attribute question_banks.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def question_banks
  @question_banks
end

#resourcesObject

Returns the value of attribute resources.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def resources
  @resources
end

#settingsObject

Returns the value of attribute settings.



4
5
6
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 4

def settings
  @settings
end

Instance Method Details

#all_resourcesObject



28
29
30
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 28

def all_resources
  @resources + @files + @pages + @discussions.map(&:resources).flatten + @assignments.map(&:resources).flatten + @assessments.map(&:resources).flatten
end

#conclude_atObject



24
25
26
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 24

def conclude_at
  Moodle2CC::CC::CCHelper.ims_datetime(@settings[:conclude_at]) if @settings[:conclude_at]
end

#mute_assignments!Object



46
47
48
49
50
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 46

def mute_assignments!
  @assignments.each do |assignment|
    assignment.muted = true
  end
end

#resolve_question_references!Object



41
42
43
44
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 41

def resolve_question_references!
  return unless @assessments && @question_banks
  @assessments.each{|a| a.resolve_question_references!(@question_banks)}
end

#start_atObject



19
20
21
# File 'lib/moodle2cc/canvas_cc/models/course.rb', line 19

def start_at
  Moodle2CC::CC::CCHelper.ims_datetime(@settings[:start_at]) if @settings[:start_at]
end