feat(challenge types): add python lab challenge type (#59732)

This commit is contained in:
Tom
2025-04-16 10:42:59 -05:00
committed by GitHub
parent 72f8b3db9a
commit 33f0842fc1
8 changed files with 29 additions and 14 deletions

View File

@@ -231,7 +231,8 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
challengeType === challengeTypes.multifileCertProject ||
challengeType === challengeTypes.multifilePythonCertProject ||
challengeType === challengeTypes.lab ||
challengeType === challengeTypes.jsLab;
challengeType === challengeTypes.jsLab ||
challengeType === challengeTypes.pyLab;
const isProjectStyle = projectBasedChallenge || isMultifileProject;
const displayPreviewPane = hasPreview && showPreviewPane;
const displayPreviewPortal = hasPreview && showPreviewPortal;

View File

@@ -285,7 +285,8 @@ const Editor = (props: EditorProps): JSX.Element => {
guides: {
highlightActiveIndentation:
props.challengeType === challengeTypes.python ||
props.challengeType === challengeTypes.multifilePythonCertProject
props.challengeType === challengeTypes.multifilePythonCertProject ||
props.challengeType === challengeTypes.pyLab
},
minimap: {
enabled: false
@@ -307,7 +308,8 @@ const Editor = (props: EditorProps): JSX.Element => {
},
tabSize:
props.challengeType !== challengeTypes.python &&
props.challengeType !== challengeTypes.multifilePythonCertProject
props.challengeType !== challengeTypes.multifilePythonCertProject &&
props.challengeType !== challengeTypes.pyLab
? 2
: 4,
dragAndDrop: true,

View File

@@ -172,7 +172,8 @@ const StepPreview = ({
dimensions?: { width: number; height: number };
}) => {
return challengeType === challengeTypes.python ||
challengeType === challengeTypes.multifilePythonCertProject ? (
challengeType === challengeTypes.multifilePythonCertProject ||
challengeType === challengeTypes.pyLab ? (
<XtermTerminal dimensions={dimensions} xtermFitRef={xtermFitRef} />
) : (
<Preview disableIframe={disableIframe} previewMounted={previewMounted} />

View File

@@ -291,7 +291,8 @@ export function* previewChallengeSaga(action) {
if (
challengeData.challengeType === challengeTypes.python ||
challengeData.challengeType ===
challengeTypes.multifilePythonCertProject
challengeTypes.multifilePythonCertProject ||
challengeData.challengeType === challengeTypes.pyLab
) {
yield updatePython(challengeData);
} else {
@@ -324,7 +325,8 @@ function* updatePreviewSaga(action) {
const challengeData = yield select(challengeDataSelector);
if (
challengeData.challengeType === challengeTypes.python ||
challengeData.challengeType === challengeTypes.multifilePythonCertProject
challengeData.challengeType === challengeTypes.multifilePythonCertProject ||
challengeData.challengeType === challengeTypes.pyLab
) {
yield updatePython(challengeData);
} else {

View File

@@ -90,7 +90,8 @@ export const challengeDataSelector = state => {
challengeType === challengeTypes.lab ||
challengeType === challengeTypes.js ||
challengeType === challengeTypes.jsProject ||
challengeType === challengeTypes.jsLab
challengeType === challengeTypes.jsLab ||
challengeType === challengeTypes.pyLab
) {
const { required = [], template = '' } = challengeMetaSelector(state);
challengeData = {

View File

@@ -104,7 +104,8 @@ export const buildFunctions = {
[challengeTypes.python]: buildPythonChallenge,
[challengeTypes.multifilePythonCertProject]: buildPythonChallenge,
[challengeTypes.lab]: buildDOMChallenge,
[challengeTypes.jsLab]: buildJSChallenge
[challengeTypes.jsLab]: buildJSChallenge,
[challengeTypes.pyLab]: buildPythonChallenge
};
export function canBuildChallenge(challengeData: BuildChallengeData): boolean {
@@ -132,7 +133,8 @@ const testRunners = {
[challengeTypes.python]: getPyTestRunner,
[challengeTypes.multifileCertProject]: getDOMTestRunner,
[challengeTypes.multifilePythonCertProject]: getPyTestRunner,
[challengeTypes.lab]: getDOMTestRunner
[challengeTypes.lab]: getDOMTestRunner,
[challengeTypes.pyLab]: getPyTestRunner
};
export function getTestRunner(
@@ -400,7 +402,8 @@ export function challengeHasPreview({
challengeType === challengeTypes.multifileCertProject ||
challengeType === challengeTypes.multifilePythonCertProject ||
challengeType === challengeTypes.python ||
challengeType === challengeTypes.lab
challengeType === challengeTypes.lab ||
challengeType === challengeTypes.pyLab
);
}

View File

@@ -13,7 +13,8 @@ const projectBasedChallengeTypes = [
challengeTypes.codeAllyPractice,
challengeTypes.multifilePythonCertProject,
challengeTypes.lab,
challengeTypes.jsLab
challengeTypes.jsLab,
challengeTypes.pyLab
];
export const isProjectBased = (

View File

@@ -26,6 +26,7 @@ const multifilePythonCertProject = 23;
const generic = 24;
const lab = 25;
const jsLab = 26;
const pyLab = 27;
export const challengeTypes = {
html,
@@ -55,7 +56,8 @@ export const challengeTypes = {
multifilePythonCertProject,
generic,
lab,
jsLab
jsLab,
pyLab
};
export const hasNoSolution = (challengeType: number): boolean => {
@@ -111,7 +113,8 @@ export const viewTypes = {
[multifilePythonCertProject]: 'classic',
[generic]: 'generic',
[lab]: 'classic',
[jsLab]: 'classic'
[jsLab]: 'classic',
[pyLab]: 'classic'
};
// determine the type of submit function to use for the challenge on completion
@@ -145,7 +148,8 @@ export const submitTypes = {
[multifilePythonCertProject]: 'tests',
[generic]: 'tests',
[lab]: 'tests',
[jsLab]: 'tests'
[jsLab]: 'tests',
[pyLab]: 'tests'
};
export const canSaveToDB = (challengeType: number): boolean =>