fix(api): always use the same logic when saving challenges (#64553)

This commit is contained in:
Oliver Eyton-Williams
2025-12-15 12:22:19 +01:00
committed by GitHub
parent 6fc07e3561
commit 001f884e21
3 changed files with 17 additions and 11 deletions
+14 -2
View File
@@ -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);
});
+2 -5
View File
@@ -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
+1 -4
View File
@@ -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,