Class: CanvasFactory::Assignment

Inherits:
Object
  • Object
show all
Defined in:
lib/japanda/canvas_factory/assignment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(course_id, assignment_config = CanvasFactory::AssignmentConfig.new) ⇒ Assignment

Returns a new instance of Assignment.



6
7
8
9
10
# File 'lib/japanda/canvas_factory/assignment.rb', line 6

def initialize(course_id, assignment_config = CanvasFactory::AssignmentConfig.new)
  fail 'invalid course_id' if course_id.nil?
  @course_id = course_id
  create_assignment course_id, assignment_config
end

Instance Attribute Details

#course_idObject (readonly)

Returns the value of attribute course_id.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def course_id
  @course_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def created_at
  @created_at
end

#due_atObject (readonly)

Returns the value of attribute due_at.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def due_at
  @due_at
end

#grading_typeObject (readonly)

Returns the value of attribute grading_type.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def grading_type
  @grading_type
end

#html_urlObject (readonly)

Returns the value of attribute html_url.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def html_url
  @html_url
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def name
  @name
end

#publishedObject (readonly)

Returns the value of attribute published.



4
5
6
# File 'lib/japanda/canvas_factory/assignment.rb', line 4

def published
  @published
end

Instance Method Details

#create_assignment(course_id, assignment_config) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/japanda/canvas_factory/assignment.rb', line 12

def create_assignment(course_id, assignment_config)
  assign_end_point = "#{CANVAS_API_V1}/courses/#{course_id}/assignments"
  response = CanvasFactory.perform_post(assign_end_point, assignment_config.request_body)
  @id = response['id']
  @name = response['name']
  @html_url = response['html_url']
  @grading_type = response['grading_type']
  @published = response['published']
  @created_at = response['created_at']
  @due_at = response['due_at']
  self
end