feat: unify curriculum layout (#53336)

This commit is contained in:
Sem Bauke
2024-01-27 17:10:18 +05:30
committed by GitHub
parent 714bd347a9
commit f66e4dcf96
7 changed files with 59 additions and 70 deletions
+47
View File
@@ -0,0 +1,47 @@
import { challengeTypes } from '../../../shared/config/challenge-types';
import { SuperBlocks } from '../../../shared/config/superblocks';
// Show a grid layout on the superblock level
const gridBasedSuperBlocks = [
SuperBlocks.RespWebDesignNew,
SuperBlocks.JsAlgoDataStructNew,
SuperBlocks.SciCompPy
];
export const isGridBased = (
superBlock: SuperBlocks,
challengeType: unknown = null
) => {
// Python projects should not be displayed as a grid, but should be displayed
// as a list of projects. Otherwise, if we do not do this the project will be
// shown as a single certificaton project, which is not what we want.
if (challengeType === 10) return false;
return gridBasedSuperBlocks.includes(superBlock);
};
// Show a single project in a certification layout
const projectBasedChallengeTypes = [
challengeTypes.frontEndProject,
challengeTypes.backEndProject,
challengeTypes.jsProject,
challengeTypes.pythonProject,
challengeTypes.codeAllyCert,
challengeTypes.multifileCertProject,
challengeTypes.exam,
challengeTypes.codeAllyPractice
];
export const isProjectBased = (
challengeType: number,
blockDashedName: unknown = null
) => {
// Is project based but should be collapsable, this differs from the
// other projects which are not collapsable.
if (blockDashedName === 'take-home-projects') return false;
return projectBasedChallengeTypes.includes(challengeType);
};
@@ -1,5 +1,5 @@
import { AllChallengesInfo } from '../redux/prop-types';
import { isFinalProject } from '../../../shared/config/challenge-types';
import { isProjectBased } from './curriculum-layout';
export function getCompletedPercentage(
completedChallengesIds: string[] = [],
@@ -48,7 +48,7 @@ export const getCurrentBlockIds = (
.filter(edge => edge.node.challenge.block === block)
.map(edge => edge.node.challenge.id);
return isFinalProject(challengeType)
return isProjectBased(challengeType)
? currentCertificateIds
: currentBlockIds;
};
-16
View File
@@ -1,25 +1,9 @@
import { SuperBlocks } from '../../../shared/config/superblocks';
export function isNewRespCert(superBlock: string): boolean {
return superBlock === String(SuperBlocks.RespWebDesignNew);
}
export function isOldRespCert(superBlock: string): boolean {
return superBlock === String(SuperBlocks.RespWebDesign);
}
export function isNewJsCert(superBlock: string): boolean {
return superBlock === String(SuperBlocks.JsAlgoDataStructNew);
}
export function isRelationalDbCert(superBlock: string): boolean {
return superBlock === String(SuperBlocks.RelationalDb);
}
export function isCollegeAlgebraPyCert(superBlock: string): boolean {
return superBlock === String(SuperBlocks.CollegeAlgebraPy);
}
export function isSciCompPyCert(superBlock: string): boolean {
return superBlock === String(SuperBlocks.SciCompPy);
}