Commit 0f233d59 authored by Yechang's avatar Yechang
Browse files

fix: grade

parent c900123d
Loading
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -16,6 +16,14 @@ export const load = (async ({ params, locals }) => {
			groups: {
				orderBy: {
					index: 'asc'
				},
				include: {
					records: {
						where: {
							studentId: user.id
						},
						orderBy: { id: 'asc' }
					}
				}
			}
		}
@@ -26,14 +34,8 @@ export const load = (async ({ params, locals }) => {
			message: 'Not found'
		});
	}
	const groups = await Promise.all(grade.groups.map(async (group) => {
		const { strategy } = group;
		const records = await db.gradeRecord.findMany({
			where: {
				studentId: user.id,
				groupId: group.id
			}
		})
	const groups = grade.groups.map((group) => {
		const { strategy, records } = group;

		const strategyFn = {
			MAX: _.max<number>,
@@ -47,7 +49,7 @@ export const load = (async ({ params, locals }) => {
			...group,
			score
		};
	}));
	});

	const score = _.sum(
		groups.map(({ score, proportion }) => {