From d8045897e42965c0ade069fcd0081fd5258f3e94 Mon Sep 17 00:00:00 2001 From: Mark Severson Date: Mon, 26 Oct 2015 10:48:15 -0600 Subject: [PATCH] fix post grades placement for lti 2 test plan: * install a post grades lti 2 tool * the post grades placement should be shown for the tool * the tool should be shown on the gradebook page for posting grades fixes SKYW-106 Change-Id: I25f26c09017d8967799b3692a2aeb15986a4c322 Reviewed-on: https://gerrit.instructure.com/57576 Reviewed-by: Nathan Mills Tested-by: Jenkins QA-Review: Steven Shepherd Product-Review: Mark Severson --- app/controllers/gradebooks_controller.rb | 2 +- app/models/lti/resource_placement.rb | 14 ++++++++------ app/models/lti/tool_consumer_profile_creator.rb | 1 + lib/lti/app_launch_collator.rb | 6 +++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/gradebooks_controller.rb b/app/controllers/gradebooks_controller.rb index daca4a47c07..758a6543f80 100644 --- a/app/controllers/gradebooks_controller.rb +++ b/app/controllers/gradebooks_controller.rb @@ -211,7 +211,7 @@ class GradebooksController < ApplicationController case launch_definition[:definition_type] when 'ContextExternalTool' url = external_tool_url_for_lti1(launch_definition) - when 'MessageHandler' + when 'Lti::MessageHandler' url = external_tool_url_for_lti2(launch_definition) end launch_definition[:placements][:post_grades][:canvas_launch_url] = url diff --git a/app/models/lti/resource_placement.rb b/app/models/lti/resource_placement.rb index 25e1a01ae23..a8b12ef2734 100644 --- a/app/models/lti/resource_placement.rb +++ b/app/models/lti/resource_placement.rb @@ -19,19 +19,21 @@ module Lti class ResourcePlacement < ActiveRecord::Base - RESOURCE_SELECTION = 'resource_selection' - ASSIGNMENT_SELECTION = 'assignment_selection' - LINK_SELECTION = 'link_selection' ACCOUNT_NAVIGATION = 'account_navigation' + ASSIGNMENT_SELECTION = 'assignment_selection' COURSE_NAVIGATION = 'course_navigation' + LINK_SELECTION = 'link_selection' + POST_GRADES = 'post_grades' + RESOURCE_SELECTION = 'resource_selection' - DEFAULT_PLACEMENTS = [ASSIGNMENT_SELECTION, LINK_SELECTION] + DEFAULT_PLACEMENTS = [ASSIGNMENT_SELECTION, LINK_SELECTION].freeze PLACEMENT_LOOKUP = { 'Canvas.placements.accountNavigation' => ACCOUNT_NAVIGATION, + 'Canvas.placements.assignmentSelection' => ASSIGNMENT_SELECTION, 'Canvas.placements.courseNavigation' => COURSE_NAVIGATION, 'Canvas.placements.linkSelection' => LINK_SELECTION, - 'Canvas.placements.assignmentSelection' => ASSIGNMENT_SELECTION, + 'Canvas.placements.postGrades' => POST_GRADES, }.freeze attr_accessible :placement, :message_handler, :resource_handler @@ -43,4 +45,4 @@ module Lti validates_inclusion_of :placement, :in => PLACEMENT_LOOKUP.values end -end \ No newline at end of file +end diff --git a/app/models/lti/tool_consumer_profile_creator.rb b/app/models/lti/tool_consumer_profile_creator.rb index 97c7ab4a6be..6a8361c2678 100644 --- a/app/models/lti/tool_consumer_profile_creator.rb +++ b/app/models/lti/tool_consumer_profile_creator.rb @@ -14,6 +14,7 @@ module Lti Canvas.placements.courseNavigation Canvas.placements.assignmentSelection Canvas.placements.linkSelection + Canvas.placements.postGrades User.username Person.email.primary Person.name.given diff --git a/lib/lti/app_launch_collator.rb b/lib/lti/app_launch_collator.rb index 46953cbbafe..90841d0a7af 100644 --- a/lib/lti/app_launch_collator.rb +++ b/lib/lti/app_launch_collator.rb @@ -90,7 +90,11 @@ module Lti def self.lti2_placements(message_handler, placements) resource_placements = message_handler.placements.pluck(:placement) - valid_placements = resource_placements.present? ? resource_placements & placements : ResourcePlacement::DEFAULT_PLACEMENTS + if resource_placements.present? + valid_placements = resource_placements & placements.map(&:to_s) + else + valid_placements = ResourcePlacement::DEFAULT_PLACEMENTS + end valid_placements.each_with_object({}) { |p, hsh| hsh[p.to_sym] = lti2_placement(message_handler) } end