Updated the grading system to work based on entities
This commit is contained in:
@@ -78,6 +78,7 @@ export default function Statistical({ user, students, entities, assignments, ses
|
||||
const [startDate, setStartDate] = useState<Date>(new Date());
|
||||
const [endDate, setEndDate] = useState<Date | null>(moment().add(1, 'month').toDate());
|
||||
const [selectedEntities, setSelectedEntities] = useState<string[]>([])
|
||||
const [isDownloading, setIsDownloading] = useState(false)
|
||||
|
||||
const resetDateRange = () => {
|
||||
const orderedAssignments = orderBy(assignments, ['startDate'], ['asc'])
|
||||
@@ -137,6 +138,8 @@ export default function Statistical({ user, students, entities, assignments, ses
|
||||
}), [data])
|
||||
|
||||
const downloadExcel = async () => {
|
||||
setIsDownloading(true)
|
||||
|
||||
const request = await axios.post("/api/statistical", {
|
||||
entities: entities.filter(e => selectedEntities.includes(e.id)),
|
||||
items: data,
|
||||
@@ -156,6 +159,8 @@ export default function Statistical({ user, students, entities, assignments, ses
|
||||
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(href);
|
||||
|
||||
setIsDownloading(false)
|
||||
}
|
||||
|
||||
const columns = [
|
||||
@@ -189,17 +194,7 @@ export default function Statistical({ user, students, entities, assignments, ses
|
||||
{capitalize(session.exam?.module || "")} Module, Part {session.partIndex + 1}, Exercise {session.exerciseIndex + 1}
|
||||
</span>
|
||||
},
|
||||
}),
|
||||
columnHelper.accessor("result", {
|
||||
header: "Score",
|
||||
cell: (info) => {
|
||||
if (!info.getValue()) return null
|
||||
const correct = info.getValue()!.stats.filter(x => !x.isPractice).reduce((acc, curr) => acc + curr.score.correct, 0)
|
||||
const total = info.getValue()!.stats.filter(x => !x.isPractice).reduce((acc, curr) => acc + curr.score.total, 0)
|
||||
|
||||
return `${correct} / ${total}`
|
||||
},
|
||||
}),
|
||||
})
|
||||
]
|
||||
|
||||
return (
|
||||
@@ -290,6 +285,7 @@ export default function Statistical({ user, students, entities, assignments, ses
|
||||
searchFields={[["student", "name"], ["student", "email"], ["student", "studentID"], ["exams", "id"], ["assignment", "name"]]}
|
||||
searchPlaceholder="Search by student, assignment or exam..."
|
||||
onDownload={downloadExcel}
|
||||
isDownloadLoading={isDownloading}
|
||||
/>
|
||||
)}
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user