do not allow submissions from not current attempts
in a2, we should not allow the user to submit a valid attempt unless they are viewing the current attempt Test Plan: * as a student in a2, navigate to any submission type * create and submit an attempt * click the button to create a new attempt * add a draft to this attempt but do not submit it * confirm that the submit button is visible * click the previous attempt button * confirm that the submit button is no longer visible flag=assignments_2_student fixes KNO-158 Change-Id: Icc29c3378e72382b39ee512a9f8ebf3cacc33466 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/218025 Reviewed-by: Matthew Lemon <mlemon@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Steven Burnett <sburnett@instructure.com> Product-Review: Steven Burnett <sburnett@instructure.com>
This commit is contained in:
parent
83171083e0
commit
5556288416
|
@ -29,6 +29,7 @@ import {Mutation} from 'react-apollo'
|
|||
import PropTypes from 'prop-types'
|
||||
import React, {Component} from 'react'
|
||||
import {STUDENT_VIEW_QUERY, SUBMISSION_HISTORIES_QUERY} from '../graphqlData/Queries'
|
||||
import StudentViewContext from './Context'
|
||||
import {Submission} from '../graphqlData/Submission'
|
||||
import theme from '@instructure/canvas-theme'
|
||||
|
||||
|
@ -200,7 +201,7 @@ export default class SubmissionManager extends Component {
|
|||
this.setState({submittingAssignment: false})
|
||||
}
|
||||
|
||||
shouldRenderSubmit = () => {
|
||||
shouldRenderSubmit(context) {
|
||||
let activeTypeMeetsCriteria = false
|
||||
switch (this.state.activeSubmissionType) {
|
||||
case 'media_recording':
|
||||
|
@ -221,7 +222,8 @@ export default class SubmissionManager extends Component {
|
|||
this.props.submission.submissionDraft &&
|
||||
activeTypeMeetsCriteria &&
|
||||
!this.state.uploadingFiles &&
|
||||
!this.state.editingDraft
|
||||
!this.state.editingDraft &&
|
||||
!context.nextButtonEnabled
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -387,7 +389,11 @@ export default class SubmissionManager extends Component {
|
|||
return (
|
||||
<>
|
||||
{this.state.submittingAssignment ? <LoadingIndicator /> : this.renderAttemptTab()}
|
||||
{this.shouldRenderSubmit() && this.renderSubmitButton()}
|
||||
<StudentViewContext.Consumer>
|
||||
{context => {
|
||||
return this.shouldRenderSubmit(context) ? this.renderSubmitButton() : null
|
||||
}}
|
||||
</StudentViewContext.Consumer>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import {fireEvent, render} from '@testing-library/react'
|
|||
import {mockAssignmentAndSubmission, mockQuery} from '../../mocks'
|
||||
import {MockedProvider} from '@apollo/react-testing'
|
||||
import React from 'react'
|
||||
import StudentViewContext from '../Context'
|
||||
import SubmissionManager from '../SubmissionManager'
|
||||
import {SubmissionMocks} from '../../graphqlData/Submission'
|
||||
|
||||
|
@ -79,6 +80,21 @@ describe('SubmissionManager', () => {
|
|||
expect(queryByText('Submit')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('does not render the submit button if we are not on the latest submission', async () => {
|
||||
const props = await mockAssignmentAndSubmission({
|
||||
Submission: SubmissionMocks.onlineUploadReadyToSubmit
|
||||
})
|
||||
const {queryByText} = render(
|
||||
<StudentViewContext.Provider value={{nextButtonEnabled: true}}>
|
||||
<MockedProvider>
|
||||
<SubmissionManager {...props} />
|
||||
</MockedProvider>
|
||||
</StudentViewContext.Provider>
|
||||
)
|
||||
|
||||
expect(queryByText('Submit')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('disables the submit button after it is pressed', async () => {
|
||||
const props = await mockAssignmentAndSubmission({
|
||||
Submission: SubmissionMocks.onlineUploadReadyToSubmit
|
||||
|
|
Loading…
Reference in New Issue