Open hammadsaedi opened 1 month ago
Due you have any clue of why the students are not showing in the reports? They are fine in the students tab. Did you try using useFocus so it always repaints and reloads the data?
Can you push some dummy data for the marks history of students ? This would take so little do develop the functionality.
@farehiqbal I double-checked we're using useFocus
. That was not a delay. It was an oversight as newly added student got inserted at the 5th or 6th line due to our custom sorting algorithm. I hope it resolves 1
.
@farehiqbal I'll populate marks history data tonight with updated schema. Ty.
P.S: I'll make sure, there will be minimal change in existing database schema / UI.
I've pushed data in the existing schema for marks history.
const classes = ['Nursery', 'Prep', '1', '2', '3', '4', '5', '6', '7', '8'];
(async function pushMarksHistory() {
try {
const batch = writeBatch(db);
const marksSnapshot = await getDocs(collection(db, "marks"));
for (const marksDoc of marksSnapshot.docs) {
const marksData = marksDoc.data();
const className = (typeof marksData.class === 'string') ? marksData.class : marksData.class.toString();
const classIndex = classes.indexOf(className);
if (classIndex === -1) {
console.error(`Class name ${className} not found in the predefined classes list.`);
continue;
}
for (let index = classIndex - 1; index >= 0; index--) {
const historyRef = doc(db, "marks", marksDoc.id, "history", classes[index]);
const classRef = doc(db, "classes", classes[index]);
const classDoc = await getDoc(classRef);
if (!classDoc.exists()) {
console.error(`Class document for ${classes[index]} not found.`);
continue;
}
const classData = classDoc.data();
const marks = {
"regNo": marksDoc.id.toString(),
"class": classDoc.id.toString(),
"first": {},
"mid": {},
"final": {}
};
delete classData.id;
delete classData.timetable;
Object.keys(classData).forEach(key => {
if (key === "Computer") {
marks["first"][key] = [Math.floor(Math.random() * (35 - 15 + 1)) + 15, Math.floor(Math.random() * (15 - 10 + 1)) + 10];
marks["mid"][key] = [Math.floor(Math.random() * (35 - 15 + 1)) + 15, Math.floor(Math.random() * (15 - 10 + 1)) + 10];
marks["final"][key] = [Math.floor(Math.random() * (70 - 35 + 1)) + 35, Math.floor(Math.random() * (30 - 15 + 1)) + 15];
} else {
marks["first"][key] = Math.floor(Math.random() * (50 - 25 + 1)) + 25;
marks["mid"][key] = Math.floor(Math.random() * (50 - 25 + 1)) + 25;
marks["final"][key] = Math.floor(Math.random() * (100 - 50 + 1)) + 50;
}
});
batch.set(historyRef, marks);
console.log(`Updated document ${marksDoc.id} with history for class ${classes[index]}`);
}
}
await batch.commit();
console.log("All documents added successfully!");
} catch (e) {
console.error("Error getting students with associated classes: ", e);
}
})();
I've added history button in right side of header.
REVISIONS