Class: CanvasFactory::Module
- Inherits:
-
Object
- Object
- CanvasFactory::Module
- Defined in:
- lib/japanda/canvas_factory/module.rb
Instance Attribute Summary collapse
-
#assignments ⇒ Object
readonly
Returns the value of attribute assignments.
-
#course_id ⇒ Object
readonly
Returns the value of attribute course_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items_count ⇒ Object
readonly
Returns the value of attribute items_count.
-
#items_url ⇒ Object
readonly
Returns the value of attribute items_url.
-
#module ⇒ Object
readonly
Returns the value of attribute module.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#prerequisite_module_ids ⇒ Object
readonly
Returns the value of attribute prerequisite_module_ids.
-
#publish_final_grade ⇒ Object
readonly
Returns the value of attribute publish_final_grade.
-
#published ⇒ Object
readonly
Returns the value of attribute published.
-
#require_sequential_progress ⇒ Object
readonly
Returns the value of attribute require_sequential_progress.
-
#unlock_at ⇒ Object
readonly
Returns the value of attribute unlock_at.
Instance Method Summary collapse
- #add_assignment(title = 'module_assignment', assignment_config = CanvasFactory::AssignmentConfig.new) ⇒ Object
- #add_module_item(module_item_request) ⇒ Object
- #create_module(course_id, module_config) ⇒ Object
-
#initialize(course_id, module_config = CanvasFactory::ModuleConfig.new) ⇒ Module
constructor
A new instance of Module.
- #publish_module ⇒ Object
Constructor Details
#initialize(course_id, module_config = CanvasFactory::ModuleConfig.new) ⇒ Module
Returns a new instance of Module.
8 9 10 11 12 |
# File 'lib/japanda/canvas_factory/module.rb', line 8 def initialize(course_id, module_config = CanvasFactory::ModuleConfig.new) @assignments = [] create_module course_id, module_config publish_module end |
Instance Attribute Details
#assignments ⇒ Object (readonly)
Returns the value of attribute assignments.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def assignments @assignments end |
#course_id ⇒ Object (readonly)
Returns the value of attribute course_id.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def course_id @course_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def id @id end |
#items_count ⇒ Object (readonly)
Returns the value of attribute items_count.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def items_count @items_count end |
#items_url ⇒ Object (readonly)
Returns the value of attribute items_url.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def items_url @items_url end |
#module ⇒ Object (readonly)
Returns the value of attribute module.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def module @module end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def name @name end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def position @position end |
#prerequisite_module_ids ⇒ Object (readonly)
Returns the value of attribute prerequisite_module_ids.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def prerequisite_module_ids @prerequisite_module_ids end |
#publish_final_grade ⇒ Object (readonly)
Returns the value of attribute publish_final_grade.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def publish_final_grade @publish_final_grade end |
#published ⇒ Object (readonly)
Returns the value of attribute published.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def published @published end |
#require_sequential_progress ⇒ Object (readonly)
Returns the value of attribute require_sequential_progress.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def require_sequential_progress @require_sequential_progress end |
#unlock_at ⇒ Object (readonly)
Returns the value of attribute unlock_at.
4 5 6 |
# File 'lib/japanda/canvas_factory/module.rb', line 4 def unlock_at @unlock_at end |
Instance Method Details
#add_assignment(title = 'module_assignment', assignment_config = CanvasFactory::AssignmentConfig.new) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/japanda/canvas_factory/module.rb', line 47 def add_assignment(title = 'module_assignment', assignment_config = CanvasFactory::AssignmentConfig.new) assignment = CanvasFactory::Assignment.new(@course_id, assignment_config) module_item_config = CanvasFactory::ModuleItemConfig.new(module_item_type: 'Assignment', completion_type: 'must_view') module_item_config.content_id = assignment.id module_item_config.title = title add_module_item(module_item_config.request_body) @assignments << assignment assignment end |
#add_module_item(module_item_request) ⇒ Object
41 42 43 44 45 |
# File 'lib/japanda/canvas_factory/module.rb', line 41 def add_module_item(module_item_request) item_end_point = "#{CANVAS_API_V1}/courses/#{@course_id}/modules/#{@id}/items" CanvasFactory.perform_post(item_end_point, module_item_request) publish_module end |
#create_module(course_id, module_config) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/japanda/canvas_factory/module.rb', line 14 def create_module(course_id, module_config) m_item_end_point = "#{CANVAS_API_V1}/courses/#{course_id}/modules" response = CanvasFactory.perform_post(m_item_end_point, module_config.request_body) @course_id = course_id @id = response['id'] @name = response['name'] @position = response['position'] @unlock_at = response['unlock_at'] @require_sequential_progress = response['require_sequential_progress'] @publish_final_grade = response['publish_final_grade'] @prerequisite_module_ids = response['prerequisite_module_ids'] @published = response['published'] @items_count = response['items_count'] @items_url = response['items_url'] end |
#publish_module ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/japanda/canvas_factory/module.rb', line 30 def publish_module body = { module: { published: true } } m_p_end_point = "#{CANVAS_API_V1}/courses/#{@course_id}/modules/#{@id}" response = CanvasFactory.perform_put(m_p_end_point, body) @published = response['published'] end |