diff --git a/api/src/routes/challenge.test.ts b/api/src/routes/challenge.test.ts index eb4f2d4e92f..239c023695d 100644 --- a/api/src/routes/challenge.test.ts +++ b/api/src/routes/challenge.test.ts @@ -775,7 +775,7 @@ describe('challengeRoutes', () => { challengeType: multiFileCertProjectBody.challengeType, files: testFiles, completedDate: expect.any(Number), - isManuallyApproved: true + isManuallyApproved: false } ], savedChallenges: [ @@ -839,7 +839,7 @@ describe('challengeRoutes', () => { challengeType: updatedMultiFileCertProjectBody.challengeType, files: testFiles, completedDate: expect.any(Number), - isManuallyApproved: true + isManuallyApproved: false }, { id: HtmlChallengeId, diff --git a/api/src/routes/challenge.ts b/api/src/routes/challenge.ts index 412884aa6bc..f596f8eee0c 100644 --- a/api/src/routes/challenge.ts +++ b/api/src/routes/challenge.ts @@ -8,6 +8,7 @@ import { schemas } from '../schemas'; import { jsCertProjectIds, multifileCertProjectIds, + multifilePythonCertProjectIds, updateUserChallengeData, type CompletedChallenge, saveUserChallengeData, @@ -348,13 +349,14 @@ export const challengeRoutes: FastifyPluginCallbackTypebox = ( }; if (challengeType === challengeTypes.multifileCertProject) { - completedChallenge.isManuallyApproved = true; + completedChallenge.isManuallyApproved = false; user.needsModeration = true; } if ( jsCertProjectIds.includes(id) || - multifileCertProjectIds.includes(id) + multifileCertProjectIds.includes(id) || + multifilePythonCertProjectIds.includes(id) ) { completedChallenge.challengeType = challengeType; } @@ -404,7 +406,10 @@ export const challengeRoutes: FastifyPluginCallbackTypebox = ( files }; - if (!multifileCertProjectIds.includes(challengeId)) { + if ( + !multifileCertProjectIds.includes(challengeId) && + !multifilePythonCertProjectIds.includes(challengeId) + ) { void reply.code(403); return 'That challenge type is not saveable.'; } diff --git a/api/src/utils/common-challenge-functions.ts b/api/src/utils/common-challenge-functions.ts index 0613c810c7d..e41e24c8cdf 100644 --- a/api/src/utils/common-challenge-functions.ts +++ b/api/src/utils/common-challenge-functions.ts @@ -16,6 +16,10 @@ export const multifileCertProjectIds = getChallenges() .filter(c => c.challengeType === challengeTypes.multifileCertProject) .map(c => c.id); +export const multifilePythonCertProjectIds = getChallenges() + .filter(c => c.challengeType === challengeTypes.multifilePythonCertProject) + .map(c => c.id); + export const msTrophyChallenges = getChallenges() .filter(challenge => challenge.challengeType === challengeTypes.msTrophy) .map(({ id, msTrophyId }) => ({ id, msTrophyId })); @@ -124,7 +128,8 @@ export async function updateUserChallengeData( if ( jsCertProjectIds.includes(challengeId) || - multifileCertProjectIds.includes(challengeId) + multifileCertProjectIds.includes(challengeId) || + multifilePythonCertProjectIds.includes(challengeId) ) { completedChallenge = { ..._completedChallenge, @@ -186,7 +191,10 @@ export async function updateUserChallengeData( userCompletedChallenges.push(finalChallenge); } - if (multifileCertProjectIds.includes(challengeId)) { + if ( + multifileCertProjectIds.includes(challengeId) || + multifilePythonCertProjectIds.includes(challengeId) + ) { const challengeToSave: SavedChallenge = { id: challengeId, lastSavedDate: newProgressTimeStamp,