mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-04 09:05:49 -05:00
feat(api): add multifile python projects to new api (#53931)
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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.';
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user