class Canvas::Workflow::Tags::AssignmentTag

Public Class Methods

new(tag_name, text, tokens) click to toggle source
Calls superclass method
# File lib/canvas/workflow/tags/assignment.rb, line 5
def initialize(tag_name, text, tokens)
  super
end

Public Instance Methods

render(context) click to toggle source
# File lib/canvas/workflow/tags/assignment.rb, line 9
def render(context)
  config = context.registers[:site].config['canvas']
  title  = context.environments.first['page']['title']
  course = config['course']
  client = Canvas::Workflow::Client.new(config)

  assignments = client.list_assignments(course, :search_term => title).to_a

  raise ArgumentError.new("Assignment does not exist") if assignments.empty?

  # return the first, which /should/ be the shortest length string, so
  # first lexicographically
  assignments.first[:id]
end