Pull Request branch dev-clone to main #1

Merged
gitea merged 429 commits from dev-clone into main 2024-12-23 09:31:34 +00:00
Showing only changes of commit f86b69769d - Show all commits

View File

@ -214,6 +214,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
questionText: string | null; questionText: string | null;
optionId: string; optionId: string;
optionText: string; optionText: string;
needFile: boolean | null;
optionScore: number; optionScore: number;
fullCount?: number; fullCount?: number;
}; };
@ -238,6 +239,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
questionText: questions.question, questionText: questions.question,
optionId: options.id, optionId: options.id,
optionText: options.text, optionText: options.text,
needFile: questions.needFile,
optionScore: options.score, optionScore: options.score,
fullCount: totalCountQuery, fullCount: totalCountQuery,
}) })
@ -251,6 +253,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
type GroupedQuestion = { type GroupedQuestion = {
questionId: string | null; questionId: string | null;
questionText: string | null; questionText: string | null;
needFile: boolean | null;
aspectsId: string | null; aspectsId: string | null;
aspectsName: string | null; aspectsName: string | null;
subAspectId: string | null; subAspectId: string | null;
@ -264,7 +267,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
// Mengelompokkan berdasarkan questionId // Mengelompokkan berdasarkan questionId
const groupedResult: GroupedQuestion[] = result.reduce((acc, current) => { const groupedResult: GroupedQuestion[] = result.reduce((acc, current) => {
const { questionId, questionText, aspectsId, aspectsName, subAspectId, subAspectName, optionId, optionText, optionScore } = current; const { questionId, questionText, needFile, aspectsId, aspectsName, subAspectId, subAspectName, optionId, optionText, optionScore } = current;
// Cek apakah questionId sudah ada dalam accumulator // Cek apakah questionId sudah ada dalam accumulator
const existingQuestion = acc.find(q => q.questionId === questionId); const existingQuestion = acc.find(q => q.questionId === questionId);
@ -281,6 +284,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
acc.push({ acc.push({
questionId, questionId,
questionText, questionText,
needFile,
aspectsId, aspectsId,
aspectsName, aspectsName,
subAspectId, subAspectId,
@ -632,6 +636,7 @@ const assessmentsRoute = new Hono<HonoEnv>()
const averageScores = await db const averageScores = await db
.select({ .select({
aspectId: subAspects.aspectId,
subAspectId: subAspects.id, subAspectId: subAspects.id,
subAspectName: subAspects.name, subAspectName: subAspects.name,
average: sql`AVG(options.score)` average: sql`AVG(options.score)`
@ -649,7 +654,8 @@ const assessmentsRoute = new Hono<HonoEnv>()
subAspects: averageScores.map(score => ({ subAspects: averageScores.map(score => ({
subAspectId: score.subAspectId, subAspectId: score.subAspectId,
subAspectName: score.subAspectName, subAspectName: score.subAspectName,
averageScore: score.average averageScore: score.average,
aspectId: score.aspectId
})) }))
}); });
} }