Skip to content

Commit 33f0842

Browse files
authored
feat(challenge types): add python lab challenge type (freeCodeCamp#59732)
1 parent 72f8b3d commit 33f0842

8 files changed

Lines changed: 29 additions & 14 deletions

File tree

client/src/templates/Challenges/classic/desktop-layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
231231
challengeType === challengeTypes.multifileCertProject ||
232232
challengeType === challengeTypes.multifilePythonCertProject ||
233233
challengeType === challengeTypes.lab ||
234-
challengeType === challengeTypes.jsLab;
234+
challengeType === challengeTypes.jsLab ||
235+
challengeType === challengeTypes.pyLab;
235236
const isProjectStyle = projectBasedChallenge || isMultifileProject;
236237
const displayPreviewPane = hasPreview && showPreviewPane;
237238
const displayPreviewPortal = hasPreview && showPreviewPortal;

client/src/templates/Challenges/classic/editor.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ const Editor = (props: EditorProps): JSX.Element => {
285285
guides: {
286286
highlightActiveIndentation:
287287
props.challengeType === challengeTypes.python ||
288-
props.challengeType === challengeTypes.multifilePythonCertProject
288+
props.challengeType === challengeTypes.multifilePythonCertProject ||
289+
props.challengeType === challengeTypes.pyLab
289290
},
290291
minimap: {
291292
enabled: false
@@ -307,7 +308,8 @@ const Editor = (props: EditorProps): JSX.Element => {
307308
},
308309
tabSize:
309310
props.challengeType !== challengeTypes.python &&
310-
props.challengeType !== challengeTypes.multifilePythonCertProject
311+
props.challengeType !== challengeTypes.multifilePythonCertProject &&
312+
props.challengeType !== challengeTypes.pyLab
311313
? 2
312314
: 4,
313315
dragAndDrop: true,

client/src/templates/Challenges/classic/show.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ const StepPreview = ({
172172
dimensions?: { width: number; height: number };
173173
}) => {
174174
return challengeType === challengeTypes.python ||
175-
challengeType === challengeTypes.multifilePythonCertProject ? (
175+
challengeType === challengeTypes.multifilePythonCertProject ||
176+
challengeType === challengeTypes.pyLab ? (
176177
<XtermTerminal dimensions={dimensions} xtermFitRef={xtermFitRef} />
177178
) : (
178179
<Preview disableIframe={disableIframe} previewMounted={previewMounted} />

client/src/templates/Challenges/redux/execute-challenge-saga.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ export function* previewChallengeSaga(action) {
291291
if (
292292
challengeData.challengeType === challengeTypes.python ||
293293
challengeData.challengeType ===
294-
challengeTypes.multifilePythonCertProject
294+
challengeTypes.multifilePythonCertProject ||
295+
challengeData.challengeType === challengeTypes.pyLab
295296
) {
296297
yield updatePython(challengeData);
297298
} else {
@@ -324,7 +325,8 @@ function* updatePreviewSaga(action) {
324325
const challengeData = yield select(challengeDataSelector);
325326
if (
326327
challengeData.challengeType === challengeTypes.python ||
327-
challengeData.challengeType === challengeTypes.multifilePythonCertProject
328+
challengeData.challengeType === challengeTypes.multifilePythonCertProject ||
329+
challengeData.challengeType === challengeTypes.pyLab
328330
) {
329331
yield updatePython(challengeData);
330332
} else {

client/src/templates/Challenges/redux/selectors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export const challengeDataSelector = state => {
9090
challengeType === challengeTypes.lab ||
9191
challengeType === challengeTypes.js ||
9292
challengeType === challengeTypes.jsProject ||
93-
challengeType === challengeTypes.jsLab
93+
challengeType === challengeTypes.jsLab ||
94+
challengeType === challengeTypes.pyLab
9495
) {
9596
const { required = [], template = '' } = challengeMetaSelector(state);
9697
challengeData = {

client/src/templates/Challenges/utils/build.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ export const buildFunctions = {
104104
[challengeTypes.python]: buildPythonChallenge,
105105
[challengeTypes.multifilePythonCertProject]: buildPythonChallenge,
106106
[challengeTypes.lab]: buildDOMChallenge,
107-
[challengeTypes.jsLab]: buildJSChallenge
107+
[challengeTypes.jsLab]: buildJSChallenge,
108+
[challengeTypes.pyLab]: buildPythonChallenge
108109
};
109110

110111
export function canBuildChallenge(challengeData: BuildChallengeData): boolean {
@@ -132,7 +133,8 @@ const testRunners = {
132133
[challengeTypes.python]: getPyTestRunner,
133134
[challengeTypes.multifileCertProject]: getDOMTestRunner,
134135
[challengeTypes.multifilePythonCertProject]: getPyTestRunner,
135-
[challengeTypes.lab]: getDOMTestRunner
136+
[challengeTypes.lab]: getDOMTestRunner,
137+
[challengeTypes.pyLab]: getPyTestRunner
136138
};
137139

138140
export function getTestRunner(
@@ -400,7 +402,8 @@ export function challengeHasPreview({
400402
challengeType === challengeTypes.multifileCertProject ||
401403
challengeType === challengeTypes.multifilePythonCertProject ||
402404
challengeType === challengeTypes.python ||
403-
challengeType === challengeTypes.lab
405+
challengeType === challengeTypes.lab ||
406+
challengeType === challengeTypes.pyLab
404407
);
405408
}
406409

client/src/utils/curriculum-layout.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const projectBasedChallengeTypes = [
1313
challengeTypes.codeAllyPractice,
1414
challengeTypes.multifilePythonCertProject,
1515
challengeTypes.lab,
16-
challengeTypes.jsLab
16+
challengeTypes.jsLab,
17+
challengeTypes.pyLab
1718
];
1819

1920
export const isProjectBased = (

shared/config/challenge-types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const multifilePythonCertProject = 23;
2626
const generic = 24;
2727
const lab = 25;
2828
const jsLab = 26;
29+
const pyLab = 27;
2930

3031
export const challengeTypes = {
3132
html,
@@ -55,7 +56,8 @@ export const challengeTypes = {
5556
multifilePythonCertProject,
5657
generic,
5758
lab,
58-
jsLab
59+
jsLab,
60+
pyLab
5961
};
6062

6163
export const hasNoSolution = (challengeType: number): boolean => {
@@ -111,7 +113,8 @@ export const viewTypes = {
111113
[multifilePythonCertProject]: 'classic',
112114
[generic]: 'generic',
113115
[lab]: 'classic',
114-
[jsLab]: 'classic'
116+
[jsLab]: 'classic',
117+
[pyLab]: 'classic'
115118
};
116119

117120
// determine the type of submit function to use for the challenge on completion
@@ -145,7 +148,8 @@ export const submitTypes = {
145148
[multifilePythonCertProject]: 'tests',
146149
[generic]: 'tests',
147150
[lab]: 'tests',
148-
[jsLab]: 'tests'
151+
[jsLab]: 'tests',
152+
[pyLab]: 'tests'
149153
};
150154

151155
export const canSaveToDB = (challengeType: number): boolean =>

0 commit comments

Comments
 (0)