feat(api): add multifile python projects to new api (#53931)

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
Tom
2024-03-11 09:58:09 -05:00
committed by GitHub
parent 242290a1a0
commit 2183ae4d89
3 changed files with 20 additions and 7 deletions

View File

@@ -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,

View File

@@ -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.';
}

View File

@@ -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,