Module: Bearcat::Client::OutcomeGroups

Included in:
Bearcat::Client
Defined in:
lib/bearcat/client/outcome_groups.rb

Instance Method Summary collapse

Instance Method Details

#create_outcome_in_group(outcome_group_id, params = {}) ⇒ Object



21
22
23
# File 'lib/bearcat/client/outcome_groups.rb', line 21

def create_outcome_in_group(outcome_group_id, params={})
  post("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes", params)
end

#create_subgroup(outcome_group_id, params = {}) ⇒ Object



37
38
39
# File 'lib/bearcat/client/outcome_groups.rb', line 37

def create_subgroup(outcome_group_id, params={})
  post("#{outcomes_context_slug(params)}#{outcome_group_id}/subgroups", params)
end

#delete_outcome_group(outcome_group_id, params = {}) ⇒ Object



13
14
15
# File 'lib/bearcat/client/outcome_groups.rb', line 13

def delete_outcome_group(outcome_group_id, params={})
  delete("#{outcomes_context_slug(params)}#{outcome_group_id}")
end

#import_outcome_group(outcome_group_id, params = {}) ⇒ Object



41
42
43
# File 'lib/bearcat/client/outcome_groups.rb', line 41

def import_outcome_group(outcome_group_id, params={})
  post("#{outcomes_context_slug(params)}#{outcome_group_id}/import", params)
end


25
26
27
# File 'lib/bearcat/client/outcome_groups.rb', line 25

def link_outcome(outcome_group_id, outcome_id, params={})
  put("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes/#{outcome_id}")
end

#list_linked_outcomes(outcome_group_id, params = {}) ⇒ Object



17
18
19
# File 'lib/bearcat/client/outcome_groups.rb', line 17

def list_linked_outcomes(outcome_group_id, params={})
  get("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes")
end

#list_subgroups(outcome_group_id, params = {}) ⇒ Object



33
34
35
# File 'lib/bearcat/client/outcome_groups.rb', line 33

def list_subgroups(outcome_group_id, params={})
  get("#{outcomes_context_slug(params)}#{outcome_group_id}/subgroups")
end

#outcomes_context_slug(params) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/bearcat/client/outcome_groups.rb', line 45

def outcomes_context_slug(params)
  context_hash = params.select { |k, _| k == "account" || k == "course" }

  if context_hash.keys.count > 1
    raise ArgumentError, "cannot have account and course in params"
  elsif context_hash.empty?
    return "#{global_slug}"
  else
    context_hash_key = context_hash.keys.first
    case context_hash_key
      when 'account'
        "#{(context_hash[context_hash_key])}"
      when 'course'
        "#{course_slug(context_hash[context_hash_key])}"
    end
  end
end

#show_outcome_group(outcome_group_id, params = {}) ⇒ Object



5
6
7
# File 'lib/bearcat/client/outcome_groups.rb', line 5

def show_outcome_group(outcome_group_id, params={})
  get("#{outcomes_context_slug(params)}#{outcome_group_id}")
end


29
30
31
# File 'lib/bearcat/client/outcome_groups.rb', line 29

def unlink_outcome(outcome_group_id, outcome_id, params={})
  delete("#{outcomes_context_slug(params)}#{outcome_group_id}/outcomes/#{outcome_id}")
end

#update_outcome_group(outcome_group_id, params = {}) ⇒ Object



9
10
11
# File 'lib/bearcat/client/outcome_groups.rb', line 9

def update_outcome_group(outcome_group_id, params={})
  put("#{outcomes_context_slug(params)}#{outcome_group_id}", params)
end