Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' of github.com:tekdi/shiksha-admin into n…
Browse files Browse the repository at this point in the history
…otification
  • Loading branch information
shreyas1434shinde committed Nov 26, 2024
2 parents c538df0 + 3d153bd commit 8fbba9b
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 99 deletions.
15 changes: 5 additions & 10 deletions public/Sample.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
name,externalId,description,type,hasAParentTask,parentTaskOperator,parentTaskValue,parentTaskId,isDeletable,learningResources1-name,learningResources1-link,learningResources1-app,learningResources1-type,learningResources1-id,learningResources2-name,learningResources2-link,learningResources2-app,learningResources2-type,minNoOfSubmissionsRequired,sequenceNumber,startDate,endDate,solutionType,solutionSubType,solutionId
Maths-Chapter 1,1,,content,NO,,,,FALSE,,,,,,,,,,,1,09-01-2024,10/31/24,,,
Arithmetic,2,,content,YES,EQUALS,started,1,FALSE,Chemical reaction,https://www.youtube.com/watch?v=TStjgUmL1RQ,Youtube,postrequisite,,,https://www.youtube.com/watch?v=CqN-XIPhMpo,,,subTask1,2,09-01-2024,10/31/24,,,
Polynomials,3,,content,YES,EQUALS,started,1,FALSE,Acid and Base,https://www.youtube.com/watch?v=ja7p_tzTTEA,Youtube,postrequisite,,,https://www.youtube.com/watch?v=rDjWrNRKfvg,,,subTask1,4,09-01-2024,10/31/24,,,
Coordinate geometry,4,,content,YES,EQUALS,started,1,FALSE,Equation of Motion,https://www.youtube.com/watch?v=80gApHJd3iY,Youtube,prerequisite,,,,,,subTask1,3,09-01-2024,10/31/24,,,
Maths-Chapter 2,5,,content,NO,,,,FALSE,,,,,,,,,,,5,09-01-2024,10/31/24,,,
Circles,6,,content,YES,EQUALS,started,5,FALSE,Human Organs,https://www.youtube.com/watch?v=YE2peDF4Zqg,Youtube,prerequisite,,,,,,subTask1,6,09-01-2024,10/31/24,,,
Trigonometry,7,,content,YES,EQUALS,started,5,FALSE,CardioVascular,https://www.youtube.com/watch?v=Vi1JK6IYVt8,Youtube,prerequisite,,,,,,subTask1,7,09-01-2024,10/31/24,,,
Statistics,8,,content,YES,EQUALS,started,5,FALSE,Liver and Kidney,https://www.youtube.com/watch?v=rDjWrNRKfvg,Youtube,postrequisite,,,,,,subTask1,8,09-01-2024,10/31/24,,,
Quadratic Equation,9,,content,YES,EQUALS,started,5,FALSE,Kaade Kess Resource,https://www.youtube.com/watch?v=CqN-XIPhMpo,Youtube,postrequisite,,,https://www.youtube.com/watch?v=CqN-XIPhMpo,,,subTask1,9,09-01-2024,10/31/24,,,
name,externalId,type,hasAParentTask,parentTaskId,learningResources1-name,learningResources1-type,learningResources1-id,learningResources2-name,learningResources2-type,learningResources2-id,startDate,endDate
Chapter 1: Real Numbers Clas 6,1,content,,,,,,,,,10-02-2025,11-02-2025
Introduction to Real Numbers,2,content,YES,1,Real Numbers – Video,prerequisite,do_2141830551647928321130,Real Numbers – Assessment,postrequisite,do_2141829595245281281142,07-02-2025,11-02-2025
Euclid’s Division Lemma,3,content,YES,1,Euclids Formula – Youtube,prerequisite,do_2141830572373852161134,Euclids Formula – EPUB,postrequisite,do_2141830562205204481132,10-02-2025,11-02-2025
The Fundamental Theorem of Arithmetic,4,content,YES,1,Fundamental Therom – PDF,facilitator-requisite,do_2141830485434695681127,,facilitator-requisite,,10-02-2025,11-02-2025
3 changes: 3 additions & 0 deletions src/pages/stateDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ const StateDetails = () => {

const handleBoardClick = (board: string, boardName: string) => {
setBoard(boardName);
localStorage.removeItem("selectedGrade");
localStorage.removeItem("selectedMedium");
localStorage.removeItem("selectedType");
router.push({
pathname: "/subjectDetails",
query: { boardDetails: board, boardName: boardName },
Expand Down
208 changes: 119 additions & 89 deletions src/pages/subjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from "@/utils/Helper";
import { TelemetryEventType } from "@/utils/app.constant";
import { telemetryFactory } from "@/utils/telemetry";
import theme from "@/components/theme/theme";

// Define Card interface
interface Card {
Expand Down Expand Up @@ -261,6 +262,88 @@ const SubjectDetails = () => {
setType(commonType3Data);
};

const fetchAndSetSubData = (type: any) => {
const typeAssociations = getAssociationsByCodeNew(typeOptions, type);
setTypeAssociations(typeAssociations);
const subject = getOptionsByCategory(store?.framedata, "subject");

console.log(subject);

const commonTypeInState = filterAndMapAssociations(
"subject",
subject,
store?.stateassociations,
"code"
);
const commonTypeInBoard = filterAndMapAssociations(
"subject",
type,
boardAssociations,
"code"
);
const commonTypeInMedium = filterAndMapAssociations(
"subject",
subject,
mediumAssociations,
"code"
);
const commonTypeInGrade = filterAndMapAssociations(
"subject",
subject,
gradeAssociations,
"code"
);
const commonTypeInType = filterAndMapAssociations(
"subject",
subject,
typeAssociations,
"code"
);

const findCommonAssociations = (array1: any[], array2: any[]) => {
return array1.filter((item1: { code: any }) =>
array2.some((item2: { code: any }) => item1.code === item2.code)
);
};

const findOverallCommonSubjects = (arrays: any[]) => {
const nonEmptyArrays = arrays.filter(
(array: string | any[]) => array && array.length > 0
);

if (nonEmptyArrays.length === 0) return [];

let commonSubjects = nonEmptyArrays[0];

for (let i = 1; i < nonEmptyArrays.length; i++) {
commonSubjects = findCommonAssociations(
commonSubjects,
nonEmptyArrays[i]
);

if (commonSubjects.length === 0) return [];
}

return commonSubjects;
};

const arrays = [
commonTypeInState,
commonTypeInBoard,
commonTypeInMedium,
commonTypeInGrade,
commonTypeInType,
];

const overallCommonSubjects = findOverallCommonSubjects(arrays);

setSubject(overallCommonSubjects);
localStorage.setItem(
"overallCommonSubjects",
JSON.stringify(overallCommonSubjects)
);
};

useEffect(() => {
if (selectedmedium) {
fetchAndSetGradeData(selectedmedium);
Expand All @@ -273,17 +356,20 @@ const SubjectDetails = () => {
}
}, [selectedgrade]);

// useEffect(() => {
// if (selectedtype) {
// fetchAndSetSubData(selectedtype);
// }
// }, [selectedtype]);
useEffect(() => {
if (selectedtype) {
fetchAndSetSubData(selectedtype);
}
}, [selectedtype]);

if (loading) {
return <Loader showBackdrop={true} loadingText="Loading..." />;
}

const handleBackClick = () => {
localStorage.removeItem("selectedGrade");
localStorage.removeItem("selectedMedium");
localStorage.removeItem("selectedType");
router.back();
};

Expand All @@ -301,9 +387,9 @@ const SubjectDetails = () => {
const medium = event.target.value;
setSelectedmedium(medium);
setTaxonomyMedium(medium);
setSelectedgrade([null]);
setSelectedtype([null]);
setSubject([null]);
// setSelectedgrade([null]);
// setSelectedtype([null]);
// setSubject([null]);

const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, "");
Expand Down Expand Up @@ -357,87 +443,6 @@ const SubjectDetails = () => {
setTaxonomyType(type);
setSelectedtype(type);

if (type) {
const typeAssociations = getAssociationsByCodeNew(typeOptions, type);
setTypeAssociations(typeAssociations);
const subject = getOptionsByCategory(store?.framedata, "subject");

console.log(subject);

const commonTypeInState = filterAndMapAssociations(
"subject",
subject,
store?.stateassociations,
"code"
);
const commonTypeInBoard = filterAndMapAssociations(
"subject",
type,
boardAssociations,
"code"
);
const commonTypeInMedium = filterAndMapAssociations(
"subject",
subject,
mediumAssociations,
"code"
);
const commonTypeInGrade = filterAndMapAssociations(
"subject",
subject,
gradeAssociations,
"code"
);
const commonTypeInType = filterAndMapAssociations(
"subject",
subject,
typeAssociations,
"code"
);

const findCommonAssociations = (array1: any[], array2: any[]) => {
return array1.filter((item1: { code: any }) =>
array2.some((item2: { code: any }) => item1.code === item2.code)
);
};

const findOverallCommonSubjects = (arrays: any[]) => {
const nonEmptyArrays = arrays.filter(
(array: string | any[]) => array && array.length > 0
);

if (nonEmptyArrays.length === 0) return [];

let commonSubjects = nonEmptyArrays[0];

for (let i = 1; i < nonEmptyArrays.length; i++) {
commonSubjects = findCommonAssociations(
commonSubjects,
nonEmptyArrays[i]
);

if (commonSubjects.length === 0) return [];
}

return commonSubjects;
};

const arrays = [
commonTypeInState,
commonTypeInBoard,
commonTypeInMedium,
commonTypeInGrade,
commonTypeInType,
];

const overallCommonSubjects = findOverallCommonSubjects(arrays);

setSubject(overallCommonSubjects);
localStorage.setItem(
"overallCommonSubjects",
JSON.stringify(overallCommonSubjects)
);
}
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, "");
const env = cleanedUrl.split("/")[0];
Expand All @@ -458,6 +463,13 @@ const SubjectDetails = () => {
telemetryFactory.interact(telemetryInteract);
};

const handleReset = () => {
setSelectedmedium("");
setSelectedgrade("");
setSelectedtype("");
setSubject("");
};

return (
<Box>
<Box sx={{ display: "flex", flexDirection: "row", marginTop: "20px" }}>
Expand Down Expand Up @@ -554,6 +566,24 @@ const SubjectDetails = () => {
))}
</Select>
</Box>
<Box>
<Button
onClick={handleReset}
sx={{
height: 40,
width: "80px",
backgroundColor: "#4D4639",
color: "#FFFFFF",
borderRadius: "8px",
marginLeft: "16px",
"&:hover": {
backgroundColor: "black",
},
}}
>
Reset
</Button>
</Box>
</Box>

<Box
Expand Down

0 comments on commit 8fbba9b

Please sign in to comment.