Enable a2 view for lti
flag=none closes EVAL-2546 refs INTEROP-8128 test plan - create an external tools assignment with a2 enabled with multiple attempts - as a student submit the assignment multiple times - go to the lti assignment and you should be able to see the tool Change-Id: I4f9c1f0d138f372f88fbaae03d7cd55727c3fe00 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/320840 Reviewed-by: Spencer Olson <solson@instructure.com> Reviewed-by: Samuel Lee <samuel.lee@instructure.com> QA-Review: Derek Williams <derek.williams@instructure.com> Product-Review: Ravi Koll <ravi.koll@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
c10f09ebe9
commit
663b58f0d9
|
@ -271,6 +271,13 @@ class AssignmentsController < ApplicationController
|
|||
@locked = @assignment.locked_for?(@current_user, check_policies: true, deep_check_if_needed: true)
|
||||
@unlocked = !@locked || @assignment.grants_right?(@current_user, session, :update)
|
||||
|
||||
if @assignment.submission_types == "external_tool" && Account.site_admin.feature_enabled?(:external_tools_for_a2) && @unlocked
|
||||
tag = @assignment.external_tool_tag
|
||||
@tool = ContextExternalTool.find_external_tool(tag.url, @context, tag.content_id)
|
||||
|
||||
js_env({ LTI_TOOL: "true" })
|
||||
end
|
||||
|
||||
unless @assignment.new_record? || (@locked && !@locked[:can_view])
|
||||
GuardRail.activate(:primary) do
|
||||
@assignment.context_module_action(@current_user, :read)
|
||||
|
|
|
@ -3925,7 +3925,9 @@ class Assignment < ActiveRecord::Base
|
|||
|
||||
def a2_enabled?
|
||||
return false unless course.feature_enabled?(:assignments_2_student)
|
||||
return false if external_tool? || quiz? || discussion_topic? || wiki_page? || (peer_reviews? && !course.feature_enabled?(:peer_reviews_for_a2))
|
||||
return false if quiz? || discussion_topic? || wiki_page?
|
||||
return false if peer_reviews? && !course.feature_enabled?(:peer_reviews_for_a2)
|
||||
return false if external_tool? && !Account.site_admin.feature_enabled?(:external_tools_for_a2)
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -302,3 +302,13 @@ default_account_grading_scheme:
|
|||
state: allowed_on # enable for automated testing builds and local testing
|
||||
development:
|
||||
state: allowed_on # enable for local development
|
||||
external_tools_for_a2:
|
||||
state: hidden
|
||||
display_name: External tools in Assignment Enhancements
|
||||
description: Allow for Assignment Enhancements to be used for external LTI tools
|
||||
applies_to: SiteAdmin
|
||||
environments:
|
||||
ci:
|
||||
state: allowed_on # enable for automated testing builds and local testing
|
||||
development:
|
||||
state: allowed_on # enable for local development
|
||||
|
|
|
@ -1736,11 +1736,32 @@ describe AssignmentsController do
|
|||
@assignment.save!
|
||||
end
|
||||
|
||||
it "renders the LTI tool launch associated with assignment" do
|
||||
user_session(@student)
|
||||
subject
|
||||
expect(response).to be_successful
|
||||
expect(assigns[:lti_launch]).to be_present
|
||||
context "with a2_enabled_tool feature flag enabled" do
|
||||
before do
|
||||
Account.site_admin.enable_feature!(:external_tools_for_a2)
|
||||
end
|
||||
|
||||
it "renders the LTI tool launch associated with assignment" do
|
||||
user_session(@student)
|
||||
subject
|
||||
expect(response).to be_successful
|
||||
expect(assigns[:lti_launch]).to be_present
|
||||
expect(assigns[:js_env][:LTI_TOOL]).to eq("true")
|
||||
end
|
||||
end
|
||||
|
||||
context "with a2_enabled_tool feature flag disabled" do
|
||||
before do
|
||||
Account.site_admin.disable_feature!(:external_tools_for_a2)
|
||||
end
|
||||
|
||||
it "renders the LTI tool launch associated with assignment" do
|
||||
user_session(@student)
|
||||
subject
|
||||
expect(response).to be_successful
|
||||
expect(assigns[:lti_launch]).to be_present
|
||||
expect(assigns[:js_env][:LTI_TOOL]).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8161,6 +8161,7 @@ describe Assignment do
|
|||
before do
|
||||
allow(@course).to receive(:feature_enabled?) { false }
|
||||
allow(@course).to receive(:feature_enabled?).with(:assignments_2_student) { true }
|
||||
Account.site_admin.disable_feature!(:external_tools_for_a2)
|
||||
end
|
||||
|
||||
let(:assignment) do
|
||||
|
@ -8205,6 +8206,17 @@ describe Assignment do
|
|||
end
|
||||
end
|
||||
|
||||
it "returns true if when LTI external tool feature flag is enabled" do
|
||||
Account.site_admin.enable_feature!(:external_tools_for_a2)
|
||||
|
||||
assignment.build_wiki_page
|
||||
assignment.build_discussion_topic
|
||||
assignment.build_quiz
|
||||
assignment.submission_types = "external_tool"
|
||||
|
||||
expect(assignment).to be_a2_enabled
|
||||
end
|
||||
|
||||
describe "peer reviews enabled" do
|
||||
before do
|
||||
allow(@course).to receive(:feature_enabled?).with(:peer_reviews_for_a2).and_return(true)
|
||||
|
|
|
@ -40,6 +40,8 @@ import {View} from '@instructure/ui-view'
|
|||
import UnpublishedModule from '../UnpublishedModule'
|
||||
import UnavailablePeerReview from '../UnavailablePeerReview'
|
||||
import VisualOnFocusMessage from './VisualOnFocusMessage'
|
||||
import ToolLaunchIframe from '@canvas/external-tools/react/components/ToolLaunchIframe'
|
||||
import iframeAllowances from '@canvas/external-apps/iframeAllowances'
|
||||
import {Flex} from '@instructure/ui-flex'
|
||||
|
||||
const I18n = useI18nScope('assignments_2_student_content')
|
||||
|
@ -153,6 +155,8 @@ function renderContentBaseOnAvailability(
|
|||
const onMarkAsDoneError = () =>
|
||||
alertContext.setOnFailure(I18n.t('Error updating status of module item'))
|
||||
|
||||
const launchURL = `/courses/${ENV.COURSE_ID}/assignments/${ENV.ASSIGNMENT_ID}/tool_launch`
|
||||
|
||||
return (
|
||||
<>
|
||||
<Flex alignItems="start">
|
||||
|
@ -195,6 +199,15 @@ function renderContentBaseOnAvailability(
|
|||
) : (
|
||||
<SubmissionlessFooter onMarkAsDoneError={onMarkAsDoneError} />
|
||||
)}
|
||||
|
||||
{ENV.LTI_TOOL === 'true' && (
|
||||
<ToolLaunchIframe
|
||||
allow={iframeAllowances()}
|
||||
src={launchURL}
|
||||
data-testid="lti-external-tool"
|
||||
title={I18n.t('Tool content')}
|
||||
/>
|
||||
)}
|
||||
{ENV.enrollment_state === 'completed' && <EnrollmentConcludedNotice />}
|
||||
</>
|
||||
)
|
||||
|
|
|
@ -223,6 +223,27 @@ describe('Assignment Student Content View', () => {
|
|||
expect(queryByTestId('assignment-2-student-content-tabs')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders LTI Launch Iframe when LTI_TOOL is true', async () => {
|
||||
window.ENV.LTI_TOOL = 'true'
|
||||
|
||||
const {getByTestId} = render(
|
||||
<MockedProvider>
|
||||
<StudentContent {...props} />
|
||||
</MockedProvider>
|
||||
)
|
||||
const lti_external_tool = getByTestId('lti-external-tool')
|
||||
expect(lti_external_tool).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('does not renders LTI Launch Iframe when LTI_TOOL is false', async () => {
|
||||
const {queryByTestId} = render(
|
||||
<MockedProvider>
|
||||
<StudentContent {...props} />
|
||||
</MockedProvider>
|
||||
)
|
||||
expect(queryByTestId('lti-external-tool')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders a "Mark as Done" button if the assignment is part of a module with a mark-as-done requirement', async () => {
|
||||
window.ENV.CONTEXT_MODULE_ITEM = {
|
||||
done: false,
|
||||
|
|
Loading…
Reference in New Issue