diff --git a/api/src/routes/protected/challenge.test.ts b/api/src/routes/protected/challenge.test.ts index b78eb875cee..2f30bd0480a 100644 --- a/api/src/routes/protected/challenge.test.ts +++ b/api/src/routes/protected/challenge.test.ts @@ -901,7 +901,13 @@ describe('challengeRoutes', () => { alreadyCompleted: false, points: 1, completedDate, - savedChallenges: [] + savedChallenges: [ + { + files: jsFiles, + id: JsProjectId, + lastSavedDate: expect.any(Number) + } + ] }); expect(response.statusCode).toBe(200); }); @@ -1089,7 +1095,13 @@ describe('challengeRoutes', () => { alreadyCompleted: false, points: 1, completedDate, - savedChallenges: [] + savedChallenges: [ + { + files: jsFiles, + id: JsProjectId, + lastSavedDate: expect.any(Number) + } + ] }); expect(response.statusCode).toBe(200); }); diff --git a/api/src/routes/protected/challenge.ts b/api/src/routes/protected/challenge.ts index 6e283a8fa01..9d43ceba97f 100644 --- a/api/src/routes/protected/challenge.ts +++ b/api/src/routes/protected/challenge.ts @@ -22,7 +22,7 @@ import { formatCoderoadChallengeCompletedValidation, formatProjectCompletedValidation } from '../../utils/error-formatting.js'; -import { challenges } from '../../utils/get-challenges.js'; +import { challenges, savableChallenges } from '../../utils/get-challenges.js'; import { ProgressTimestamp, getPoints } from '../../utils/progress.js'; import { validateExamFromDbSchema, @@ -1128,10 +1128,7 @@ async function postSaveChallenge( files }; - if ( - !multifileCertProjectIds.includes(challengeId) && - !multifilePythonCertProjectIds.includes(challengeId) - ) { + if (!savableChallenges.has(challengeId)) { logger.warn( { challengeId diff --git a/api/src/utils/common-challenge-functions.ts b/api/src/utils/common-challenge-functions.ts index dd331fcea05..57b438b8480 100644 --- a/api/src/utils/common-challenge-functions.ts +++ b/api/src/utils/common-challenge-functions.ts @@ -194,10 +194,7 @@ export async function updateUserChallengeData( ? [...progressTimestamps, newProgressTimeStamp] : progressTimestamps; - if ( - multifileCertProjectIds.includes(challengeId) || - multifilePythonCertProjectIds.includes(challengeId) - ) { + if (savableChallenges.has(challengeId)) { const challengeToSave: SavedChallenge = { id: challengeId, lastSavedDate: newProgressTimeStamp,