From 602fc440cd0f9069b23f9d99b570b5e94471c929 Mon Sep 17 00:00:00 2001 From: Jackson Howe Date: Thu, 16 Sep 2021 18:35:49 +0000 Subject: [PATCH] Revert "Remove New Quizzes Embedded Module Progression" This reverts commit a7f0ea277a8c924c080454b0d56ba9d9cc3da691. Reason for revert: the removal broke launching NQ on mobile Change-Id: I1f719ce9317cfb1f4477098fe25fd7eb558b0d09 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273543 Reviewed-by: Jeff Largent Tested-by: Service Cloud Jenkins QA-Review: Mark McDermott Product-Review: Jackson Howe --- app/controllers/application_controller.rb | 3 ++- app/models/lti/lti_outbound_adapter.rb | 4 +++- config/feature_flags/quizzes_release_flags.yml | 7 ++++++- gems/lti_outbound/lib/lti_outbound/tool_launch.rb | 7 +++++-- gems/lti_outbound/spec/lti_outbound/tool_launch_spec.rb | 5 +++-- spec/controllers/application_controller_spec.rb | 3 ++- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 184fb8eac24..6477b919e19 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1843,6 +1843,7 @@ class ApplicationController < ActionController::Base link_code: @opaque_id, overrides: {'resource_link_title' => @resource_title}, domain: HostUrl.context_host(@domain_root_account, request.host), + include_module_context: Account.site_admin.feature_enabled?(:new_quizzes_in_module_progression) } variable_expander = Lti::VariableExpander.new(@domain_root_account, @context, self,{ current_user: @current_user, @@ -1950,7 +1951,7 @@ class ApplicationController < ActionController::Base def external_tool_redirect_display_type if params['display'].present? params['display'] - elsif @assignment&.quiz_lti? && @module_tag + elsif Account.site_admin.feature_enabled?(:new_quizzes_in_module_progression) && @assignment&.quiz_lti? && @module_tag 'in_nav_context' else @tool&.extension_setting(:assignment_selection)&.dig('display_type') diff --git a/app/models/lti/lti_outbound_adapter.rb b/app/models/lti/lti_outbound_adapter.rb index 5ca064df83e..21f2879e709 100644 --- a/app/models/lti/lti_outbound_adapter.rb +++ b/app/models/lti/lti_outbound_adapter.rb @@ -53,6 +53,7 @@ module Lti link_code = opts[:link_code] || default_link_code @overrides = opts[:overrides] || {} link_params = opts[:link_params] || {} + include_module_context = opts[:include_module_context] || false lti_context = Lti::LtiContextCreator.new(@context, @tool).convert lti_user = Lti::LtiUserCreator.new(@user, @root_account, @tool, @context).convert if @user @@ -72,7 +73,8 @@ module Lti tool: lti_tool, account: lti_account, variable_expander: variable_expander, - link_params: link_params + link_params: link_params, + include_module_context: include_module_context } ) self diff --git a/config/feature_flags/quizzes_release_flags.yml b/config/feature_flags/quizzes_release_flags.yml index a58a0a208ee..219af971e38 100644 --- a/config/feature_flags/quizzes_release_flags.yml +++ b/config/feature_flags/quizzes_release_flags.yml @@ -48,6 +48,11 @@ new_quizzes_account_course_level_item_banks: state: hidden new_quizzes_skip_to_build_module_button: display_name: New Quizzes Build Button In Module Items - description: Provides a button which navigates straight to the Build screen in the kebab menu for New Quizzes items on the Modules page. + description: Provides a button which navigates straight to the Build screen in the kebab menu for New Quizzes items on the Modules page. + applies_to: SiteAdmin + state: hidden +new_quizzes_in_module_progression: + display_name: New Quizzes Embedded Module Progression + description: Improved support for taking New Quizzes from within Modules applies_to: SiteAdmin state: hidden diff --git a/gems/lti_outbound/lib/lti_outbound/tool_launch.rb b/gems/lti_outbound/lib/lti_outbound/tool_launch.rb index f0322af3471..d7cd7fbcfcf 100644 --- a/gems/lti_outbound/lib/lti_outbound/tool_launch.rb +++ b/gems/lti_outbound/lib/lti_outbound/tool_launch.rb @@ -40,6 +40,7 @@ module LtiOutbound @selected_html = options[:selected_html] @link_params = options[:link_params] || {} @consumer_instance = context.consumer_instance || raise('Consumer instance required for generating LTI content') + @include_module_context = options[:include_module_context] || false @variable_expander = options[:variable_expander] || raise('VariableExpander is required for generating LTI content') @hash = {} @@ -143,8 +144,10 @@ module LtiOutbound def add_assignment_substitutions!(assignment) if tool.public? hash['custom_canvas_assignment_id'] = '$Canvas.assignment.id' - hash['custom_canvas_module_id'] = '$Canvas.module.id' - hash['custom_canvas_module_item_id'] = '$Canvas.moduleItem.id' + if @include_module_context + hash['custom_canvas_module_id'] = '$Canvas.module.id' + hash['custom_canvas_module_item_id'] = '$Canvas.moduleItem.id' + end end hash['custom_canvas_assignment_title'] = '$Canvas.assignment.title' diff --git a/gems/lti_outbound/spec/lti_outbound/tool_launch_spec.rb b/gems/lti_outbound/spec/lti_outbound/tool_launch_spec.rb index 072c34d93a4..bd1b046be93 100644 --- a/gems/lti_outbound/spec/lti_outbound/tool_launch_spec.rb +++ b/gems/lti_outbound/spec/lti_outbound/tool_launch_spec.rb @@ -113,7 +113,8 @@ describe LtiOutbound::ToolLaunch do :link_code => '123456', :return_url => 'http://www.google.com', :outgoing_email_address => 'outgoing_email_address', - :variable_expander => variable_expander) + :variable_expander => variable_expander, + :include_module_context => true) end describe '#generate' do @@ -418,7 +419,7 @@ describe LtiOutbound::ToolLaunch do expect(hash['custom_canvas_assignment_points_possible']).to eq '$Canvas.assignment.pointsPossible' end - it 'includes module context info' do + it 'includes module context info when associated option is true' do tool_launch.for_assignment!(assignment, '/my/test/url', '/my/other/test/url', '/a/test/url') hash = tool_launch.generate diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 5ff360c0ac3..a132f847cd8 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -953,7 +953,8 @@ RSpec.describe ApplicationController do controller.send(:content_tag_redirect, course, content_tag, nil) end - it 'overrides the configured display_type for the quiz_lti in module context' do + it 'overrides the configured display_type for the quiz_lti in module context when feature flag is on' do + Account.site_admin.enable_feature!(:new_quizzes_in_module_progression) allow(content_tag.context).to receive(:quiz_lti?).and_return(true) module1 = course.context_modules.create!(name: 'Module 1') content_tag.context.context_module_tags.create!(context_module: module1, context: course, tag_type: 'context_module')