diff --git a/client/src/templates/Challenges/classic/editor.tsx b/client/src/templates/Challenges/classic/editor.tsx index 8f2fdaafcd6..1d397537af3 100644 --- a/client/src/templates/Challenges/classic/editor.tsx +++ b/client/src/templates/Challenges/classic/editor.tsx @@ -40,7 +40,10 @@ import { } from '../../../redux/prop-types'; import { editorToneOptions } from '../../../utils/tone/editor-config'; import { editorNotes } from '../../../utils/tone/editor-notes'; -import { challengeTypes, isProject } from '../../../../utils/challenge-types'; +import { + challengeTypes, + isFinalProject +} from '../../../../utils/challenge-types'; import { canFocusEditorSelector, challengeMetaSelector, @@ -430,7 +433,7 @@ const Editor = (props: EditorProps): JSX.Element => { /* eslint-disable no-bitwise */ keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter], run: () => { - if (props.usesMultifileEditor && !isProject(props.challengeType)) { + if (props.usesMultifileEditor && !isFinalProject(props.challengeType)) { if (challengeIsComplete()) { tryToSubmitChallenge(); } else { diff --git a/client/src/templates/Challenges/components/Hotkeys.tsx b/client/src/templates/Challenges/components/Hotkeys.tsx index cede24740e7..3a5b4f7ce1c 100644 --- a/client/src/templates/Challenges/components/Hotkeys.tsx +++ b/client/src/templates/Challenges/components/Hotkeys.tsx @@ -15,7 +15,7 @@ import { openModal } from '../redux'; import './hotkeys.css'; -import { isProject } from '../../../../utils/challenge-types'; +import { isFinalProject } from '../../../../utils/challenge-types'; const mapStateToProps = createSelector( canFocusEditorSelector, @@ -102,7 +102,7 @@ function Hotkeys({ if ( usesMultifileEditor && typeof challengeType == 'number' && - !isProject(challengeType) + !isFinalProject(challengeType) ) { if (testsArePassing) { submitChallenge(); diff --git a/client/src/templates/Challenges/components/completion-modal.tsx b/client/src/templates/Challenges/components/completion-modal.tsx index c86ee9e194f..6ba207e32d6 100644 --- a/client/src/templates/Challenges/components/completion-modal.tsx +++ b/client/src/templates/Challenges/components/completion-modal.tsx @@ -10,7 +10,7 @@ import { Dispatch } from 'redux'; import { createSelector } from 'reselect'; import { dasherize } from '../../../../../utils/slugs'; -import { isProject } from '../../../../utils/challenge-types'; +import { isFinalProject } from '../../../../utils/challenge-types'; import Login from '../../../components/Header/components/Login'; import { isSignedInSelector, @@ -284,7 +284,7 @@ export class CompletionModalInner extends Component< } interface Options { - isCertificationBlock: boolean; + isFinalProjectBlock: boolean; } interface CertificateNode { @@ -348,9 +348,7 @@ const useCurrentBlockIds = ( .filter(edge => edge.node.challenge.block === block) .map(edge => edge.node.challenge.id); - return options?.isCertificationBlock - ? currentCertificateIds - : currentBlockIds; + return options?.isFinalProjectBlock ? currentCertificateIds : currentBlockIds; }; const CompletionModal = (props: CompletionModalsProps) => { @@ -358,7 +356,7 @@ const CompletionModal = (props: CompletionModalsProps) => { props.block || '', props.certification || '', // eslint-disable-next-line @typescript-eslint/no-unsafe-call - { isCertificationBlock: isProject(props.challengeType) } + { isFinalProjectBlock: isFinalProject(props.challengeType) } ); return ; }; diff --git a/client/src/templates/Introduction/components/block.tsx b/client/src/templates/Introduction/components/block.tsx index a730e5624ca..81a3030b82b 100644 --- a/client/src/templates/Introduction/components/block.tsx +++ b/client/src/templates/Introduction/components/block.tsx @@ -18,6 +18,10 @@ import { ChallengeNode, CompletedChallenge } from '../../../redux/prop-types'; import { playTone } from '../../../utils/tone'; import { makeExpandedBlockSelector, toggleBlock } from '../redux'; import { isNewJsCert, isNewRespCert } from '../../../utils/is-a-cert'; +import { + isCodeAllyPractice, + isFinalProject +} from '../../../../utils/challenge-types'; import Challenges from './challenges'; import '../intro.css'; @@ -120,24 +124,12 @@ export class Block extends Component { }); const isProjectBlock = challenges.some(({ challenge }) => { - const isJsProject = - [3, 6, 10, 14, 17].includes(challenge.order) && - challenge.challengeType === 5 && - blockDashedName !== 'rosetta-code'; - - const isOtherProject = - challenge.challengeType === 3 || - challenge.challengeType === 4 || - challenge.challengeType === 10 || - challenge.challengeType === 12 || - challenge.challengeType === 13 || - challenge.challengeType === 14; - const isTakeHomeProject = blockDashedName === 'take-home-projects'; return ( - (isJsProject && !isTakeHomeProject) || - (isOtherProject && !isTakeHomeProject) + isFinalProject(challenge.challengeType) && + !isTakeHomeProject && + isCodeAllyPractice(challenge.challengeType) ); }); diff --git a/client/utils/challenge-types.js b/client/utils/challenge-types.js index 1a3b2f51227..586053194a6 100644 --- a/client/utils/challenge-types.js +++ b/client/utils/challenge-types.js @@ -41,18 +41,25 @@ exports.challengeTypes = { multifileCertProject }; -exports.isProject = challengeType => { +exports.isFinalProject = challengeType => { if (typeof challengeType !== 'number') throw Error('challengeType must be a number'); return ( challengeType === frontEndProject || challengeType === backEndProject || + challengeType === jsProject || challengeType === pythonProject || challengeType === codeAllyCert || challengeType === multifileCertProject ); }; +exports.isCodeAllyPractice = challengeType => { + if (typeof challengeType !== 'number') + throw Error('challengeType must be a number'); + return challengeType === codeAllyPractice; +}; + // turn challengeType to file ext exports.pathsMap = { [html]: 'html',