diff --git a/src/App.jsx b/src/App.jsx index 81b65e69..8d9a9bd2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -5,13 +5,14 @@ import { Spinner } from '@edx/paragon'; import { useIsORAConfigLoaded, useIsPageDataLoaded } from 'data/services/lms/hooks/selectors'; -import AppContainer from 'views/AppContainer'; -import ModalContainer from 'views/ModalContainer'; import PeerAssessmentView from 'views/PeerAssessmentView'; import SelfAssessmentView from 'views/SelfAssessmentView'; import StudentTrainingView from 'views/StudentTrainingView'; import SubmissionView from 'views/SubmissionView'; import XBlockView from 'views/XBlockView'; + +import AppContainer from 'components/AppContainer'; +import ModalContainer from 'components/ModalContainer'; import PageDataProvider from 'components/PageDataProvider'; import messages from './messages'; diff --git a/src/views/AppContainer.jsx b/src/components/AppContainer.jsx similarity index 100% rename from src/views/AppContainer.jsx rename to src/components/AppContainer.jsx diff --git a/src/views/ModalContainer.jsx b/src/components/ModalContainer.jsx similarity index 100% rename from src/views/ModalContainer.jsx rename to src/components/ModalContainer.jsx diff --git a/src/views/SelfAssessmentView/AssessmentContent.test.jsx b/src/views/SelfAssessmentView/AssessmentContent.test.jsx deleted file mode 100644 index 7ec40eef..00000000 --- a/src/views/SelfAssessmentView/AssessmentContent.test.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import { shallow } from '@edx/react-unit-test-utils'; -import AssessmentContent from './AssessmentContent'; - -jest.mock('@edx/paragon/icons', () => ({ - CheckCircle: 'CheckCircle', -})); - -jest.mock('components/Prompt', () => 'Prompt'); -jest.mock('components/TextResponse', () => 'TextResponse'); -jest.mock('components/FileUpload', () => 'FileUpload'); - -describe('', () => { - const props = { - submission: { - response: { - textResponses: ['test'], - uploadedFiles: [{ - fileDescription: 'test', - }], - }, - }, - oraConfigData: { - prompts: ['

test

'], - submissionConfig: { - maxFileSize: 100, - }, - }, - }; - - describe('render', () => { - test('default', () => { - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); - - expect(wrapper.instance.findByType('Prompt')).toHaveLength(1); - }); - - test('no prompts', () => { - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); - - expect(wrapper.instance.findByType('Prompt')).toHaveLength(0); - }); - }); -}); diff --git a/src/views/SelfAssessmentView/AssessmentContentLayout.jsx b/src/views/SelfAssessmentView/AssessmentContentLayout.jsx deleted file mode 100644 index ebe97da4..00000000 --- a/src/views/SelfAssessmentView/AssessmentContentLayout.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { Col, Row } from '@edx/paragon'; - -import Rubric from 'components/Rubric'; -import AssessmentContent from './AssessmentContent'; -import AssessmentStatus from './AssessmentStatus'; -import { statefulStates } from 'components/StatefulStatus'; - -import './AssessmentContentLayout.scss'; - -const AssessmentContentLayout = ({ submission, oraConfigData }) => ( -
-
- - - { - statefulStates.map((status) => ( - - )) - } - - - - -
-
-); - -AssessmentContentLayout.propTypes = { - // eslint-disable-next-line react/forbid-prop-types - submission: PropTypes.any.isRequired, - // eslint-disable-next-line react/forbid-prop-types - oraConfigData: PropTypes.any.isRequired, -}; - -export default AssessmentContentLayout; diff --git a/src/views/SelfAssessmentView/AssessmentContentLayout.test.jsx b/src/views/SelfAssessmentView/AssessmentContentLayout.test.jsx deleted file mode 100644 index 66f546b7..00000000 --- a/src/views/SelfAssessmentView/AssessmentContentLayout.test.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import { shallow } from '@edx/react-unit-test-utils'; -import AssessmentContentLayout from './AssessmentContentLayout'; - -jest.mock('components/Rubric', () => 'Rubric'); -jest.mock('./AssessmentContent', () => 'AssessmentContent'); -jest.mock('./AssessmentStatus', () => 'AssessmentStatus'); - -describe('', () => { - const props = { - submission: 'submission', - oraConfigData: { - assessmentSteps: { - settings: { - self: { - endTime: 'endTime', - }, - }, - }, - }, - }; - - it('render', () => { - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); - - expect(wrapper.instance.findByType('Rubric')).toHaveLength(1); - }); -}); diff --git a/src/views/SelfAssessmentView/AssessmentStatus.jsx b/src/views/SelfAssessmentView/AssessmentStatus.jsx deleted file mode 100644 index 3b7b8ed5..00000000 --- a/src/views/SelfAssessmentView/AssessmentStatus.jsx +++ /dev/null @@ -1,99 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { Button, Alert, Icon } from '@edx/paragon'; -import { Edit } from '@edx/paragon/icons'; -import { useIntl } from '@edx/frontend-platform/i18n'; - -import StatefulStatus from 'components/StatefulStatus'; -import messages from './messages'; - -const AssessmentStatus = ({ status, dueDate }) => { - const { formatMessage } = useIntl(); - return ( - -

- {formatMessage(messages.instructions)}: {formatMessage(messages.inProgressText)} -

- - - - ), - }, - success: { - badgeText: formatMessage(messages.completedBadge), - headerText: formatMessage(messages.completedHeader), - content: ( -
-
- {formatMessage(messages.completedBodyHeader)} -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. - Nullam euismod, nisl eget ultricies aliquet, mauris quam - sodales -

-
- -
- ), - }, - error: { - badgeText: formatMessage(messages.errorBadge), - headerText: formatMessage(messages.errorHeader), - content: ( - <> - - {formatMessage(messages.errorBodyHeader)} - -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam - euismod, nisl eget ultricies aliquet, mauris quam sodales -

- - ), - }, - cancelled: { - badgeText: formatMessage(messages.cancelledBadge), - headerText: formatMessage(messages.cancelledHeader, { dueDate }), - content: ( - <> - {formatMessage(messages.cancelledBodyHeader)} -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam - euismod, nisl eget ultricies aliquet, mauris quam sodales -

- - ), - }, - }} - /> - ); -}; - -AssessmentStatus.propTypes = { - status: PropTypes.oneOf(['default', 'success', 'error', 'cancelled']) - .isRequired, - dueDate: PropTypes.string.isRequired, -}; - -export default AssessmentStatus; diff --git a/src/views/SelfAssessmentView/Content.jsx b/src/views/SelfAssessmentView/Content.jsx index ea33088f..315e11bb 100644 --- a/src/views/SelfAssessmentView/Content.jsx +++ b/src/views/SelfAssessmentView/Content.jsx @@ -1,10 +1,7 @@ import React from 'react'; -import { useIntl } from '@edx/frontend-platform/i18n'; - import { usePrompts, - useSubmissionConfig, useSubmissionResponse, } from 'data/services/lms/hooks/selectors'; @@ -12,33 +9,19 @@ import Prompt from 'components/Prompt'; import TextResponse from 'components/TextResponse'; import FileUpload from 'components/FileUpload'; -import messages from './messages'; - const AssessmentContent = () => { const prompts = usePrompts(); const response = useSubmissionResponse(); - const submissionConfig = useSubmissionConfig(); - const { formatMessage } = useIntl(); return (
-
-

{formatMessage(messages.yourResponse)}

-
-

- {formatMessage(messages.instructions)}: - {formatMessage(messages.instructionsText)} -

- {prompts.map((prompt, index) => ( - // eslint-disable-next-line react/no-array-index-key -
- - -
- ))} + {React.Children.toArray( + prompts.map((prompt, index) => ( +
+ + +
+ )), + )}
); diff --git a/src/views/SelfAssessmentView/__snapshots__/AssessmentContent.test.jsx.snap b/src/views/SelfAssessmentView/__snapshots__/AssessmentContent.test.jsx.snap deleted file mode 100644 index 01a70f7a..00000000 --- a/src/views/SelfAssessmentView/__snapshots__/AssessmentContent.test.jsx.snap +++ /dev/null @@ -1,85 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` render default 1`] = ` -
-
-

- Your response -

-
-

- - Instructions - : - - Create a response to the prompt below. - Progress will be saved automatically and you can return to complete your - progress at any time. After you submit your response, you cannot edit - it. -

-
- - -
- -
-`; - -exports[` render no prompts 1`] = ` -
-
-

- Your response -

-
-

- - Instructions - : - - Create a response to the prompt below. - Progress will be saved automatically and you can return to complete your - progress at any time. After you submit your response, you cannot edit - it. -

- -
-`; diff --git a/src/views/SelfAssessmentView/__snapshots__/AssessmentContentLayout.test.jsx.snap b/src/views/SelfAssessmentView/__snapshots__/AssessmentContentLayout.test.jsx.snap deleted file mode 100644 index f96726ba..00000000 --- a/src/views/SelfAssessmentView/__snapshots__/AssessmentContentLayout.test.jsx.snap +++ /dev/null @@ -1,57 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` render 1`] = ` -
-
- - - - - - - - - - -
-
-`; diff --git a/src/views/SelfAssessmentView/__snapshots__/index.test.jsx.snap b/src/views/SelfAssessmentView/__snapshots__/index.test.jsx.snap deleted file mode 100644 index 8cb7e67b..00000000 --- a/src/views/SelfAssessmentView/__snapshots__/index.test.jsx.snap +++ /dev/null @@ -1,11 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` renders 1`] = ` - - - - -`; diff --git a/src/views/SelfAssessmentView/hooks.js b/src/views/SelfAssessmentView/hooks.js deleted file mode 100644 index 35315795..00000000 --- a/src/views/SelfAssessmentView/hooks.js +++ /dev/null @@ -1,13 +0,0 @@ -import { useORAConfigData, usePageData } from 'data/services/lms/hooks/selectors'; - -const useAssessmentViewHooks = () => { - const pageData = usePageData(); - const oraConfigData = useORAConfigData(); - - return { - submission: pageData?.submission, - oraConfigData, - }; -}; - -export default useAssessmentViewHooks; diff --git a/src/views/SelfAssessmentView/index.jsx b/src/views/SelfAssessmentView/index.jsx index 5b9b14f7..dc39c62b 100644 --- a/src/views/SelfAssessmentView/index.jsx +++ b/src/views/SelfAssessmentView/index.jsx @@ -2,19 +2,27 @@ import React from 'react'; import { Button } from '@edx/paragon'; import { useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors'; + +import StatusAlert from 'views/StatusAlert/SelfAssessment'; import BaseAssessmentView from 'components/BaseAssessmentView'; import AssessmentContent from './Content'; -export const SelfAssessmentView = () => useIsORAConfigLoaded() && ( - Cancel, - , - ]} - submitAssessment={() => {}} - > - - -); +export const SelfAssessmentView = () => { + if (!useIsORAConfigLoaded()) { + return null; + } + return ( + Cancel, + , + ]} + submitAssessment={() => {}} + > + + + + ); +}; export default SelfAssessmentView; diff --git a/src/views/SelfAssessmentView/index.test.jsx b/src/views/SelfAssessmentView/index.test.jsx deleted file mode 100644 index 8667e5af..00000000 --- a/src/views/SelfAssessmentView/index.test.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import { shallow } from '@edx/react-unit-test-utils'; -import { AssessmentView } from '.'; - -jest.mock('./AssessmentContentLayout', () => 'AssessmentContentLayout'); - -jest.mock('./hooks', () => jest.fn().mockReturnValue({ - submission: 'submission', - oraConfigData: 'oraConfigData', -})); - -describe('', () => { - it('renders', () => { - const wrapper = shallow(); - expect(wrapper.snapshot).toMatchSnapshot(); - }); -}); diff --git a/src/views/SelfAssessmentView/messages.js b/src/views/SelfAssessmentView/messages.js deleted file mode 100644 index 2024f9c1..00000000 --- a/src/views/SelfAssessmentView/messages.js +++ /dev/null @@ -1,97 +0,0 @@ -import { defineMessages } from '@edx/frontend-platform/i18n'; - -const messages = defineMessages({ - yourResponse: { - id: 'ora-grading.AssessmentView.yourResponse', - defaultMessage: 'Your response', - description: 'Label for the response textarea', - }, - instructions: { - id: 'ora-grading.AssessmentView.instructions', - defaultMessage: 'Instructions', - description: 'Label for the instructions textarea', - }, - instructionsText: { - id: 'ora-grading.AssessmentView.instructionsText', - defaultMessage: `Create a response to the prompt below. - Progress will be saved automatically and you can return to complete your - progress at any time. After you submit your response, you cannot edit - it.`, - description: 'Description for the instructions textarea', - }, - inProgressBadge: { - id: 'ora-grading.AssessmentView.inProgressBadge', - defaultMessage: 'In Progress', - description: 'Label for the in progress badge', - }, - inProgressHeader: { - id: 'ora-grading.AssessmentView.inProgressHeader', - defaultMessage: 'Self-grading due by {dueDate}', - description: 'Header for the in progress badge', - }, - inProgressText: { - id: 'ora-grading.AssessmentView.inProgressBadgeText', - defaultMessage: `Assess your own response and give - yourself a grade. Progress will be saved automatically and you - can return to complete your self assessment at any time. After - you submit your grade, you cannot edit it.`, - description: 'Description for the in progress badge', - }, - inProgressButton: { - id: 'ora-grading.AssessmentView.inProgressButton', - defaultMessage: 'Begin self assessment', - description: 'Label for button to begin self assessment', - }, - completedBadge: { - id: 'ora-grading.AssessmentView.completedBadge', - defaultMessage: 'Completed', - description: 'Label for the completed badge', - }, - completedHeader: { - id: 'ora-grading.AssessmentView.completedHeader', - defaultMessage: 'Practice grading is complete!', - description: 'Header for the completed badge', - }, - completedBodyHeader: { - id: 'ora-grading.AssessmentView.completedBodyHeader', - defaultMessage: 'Practice grading complete', - description: 'Alert header for the completed badge', - }, - completedBodyButton: { - id: 'ora-grading.AssessmentView.completedBodyButton', - defaultMessage: 'Begin peer grading', - description: 'Label for button to view your grade', - }, - errorBadge: { - id: 'ora-grading.AssessmentView.errorBadge', - defaultMessage: 'Incomplete', - description: 'Label for the incomplete badge', - }, - errorHeader: { - id: 'ora-grading.AssessmentView.errorBadgeHeader', - defaultMessage: 'This step is past due!', - description: 'Header for the incomplete badge', - }, - errorBodyHeader: { - id: 'ora-grading.AssessmentView.errorBodyHeader', - defaultMessage: 'The due date for this step has passed', - description: 'Alert header for the incomplete badge', - }, - cancelledBadge: { - id: 'ora-grading.AssessmentView.cancelledBadge', - defaultMessage: 'Cancelled', - description: 'Label for the cancelled badge', - }, - cancelledHeader: { - id: 'ora-grading.AssessmentView.cancelledBadgeHeader', - defaultMessage: 'Self-grading Due by {dueDate}', - description: 'Header for the cancelled badge', - }, - cancelledBodyHeader: { - id: 'ora-grading.AssessmentView.cancelledBodyHeader', - defaultMessage: 'This step has been cancelled', - description: 'Alert header for the cancelled badge', - }, -}); - -export default messages; diff --git a/src/views/StudentTrainingView/Content.jsx b/src/views/StudentTrainingView/Content.jsx index b728625f..315e11bb 100644 --- a/src/views/StudentTrainingView/Content.jsx +++ b/src/views/StudentTrainingView/Content.jsx @@ -1,24 +1,28 @@ import React from 'react'; -import { useORAConfigData } from 'data/services/lms/hooks/selectors'; +import { + usePrompts, + useSubmissionResponse, +} from 'data/services/lms/hooks/selectors'; import Prompt from 'components/Prompt'; import TextResponse from 'components/TextResponse'; import FileUpload from 'components/FileUpload'; const AssessmentContent = () => { - const { prompts } = useORAConfigData(); + const prompts = usePrompts(); + const response = useSubmissionResponse(); return (
{React.Children.toArray( prompts.map((prompt, index) => (
- - + +
)), )} - +
); }; diff --git a/src/views/StudentTrainingView/index.jsx b/src/views/StudentTrainingView/index.jsx index 6eed6131..9f867432 100644 --- a/src/views/StudentTrainingView/index.jsx +++ b/src/views/StudentTrainingView/index.jsx @@ -5,11 +5,11 @@ import { useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors'; import BaseAssessmentView from 'components/BaseAssessmentView'; import AssessmentContent from './Content'; -export const PeerAssessmentView = () => useIsORAConfigLoaded() && ( +export const StudentTrainingView = () => useIsORAConfigLoaded() && ( Cancel, - , + , + , ]} submitAssessment={() => {}} > @@ -17,4 +17,4 @@ export const PeerAssessmentView = () => useIsORAConfigLoaded() && ( ); -export default PeerAssessmentView; +export default StudentTrainingView;