uodate: return to the previous concept of getAnswers endpoint in assessments because formatted resulted will be handled in the frontend

This commit is contained in:
falendikategar 2024-11-07 11:57:14 +07:00
parent cb97b8618f
commit 4984925dd8

View File

@ -417,16 +417,8 @@ const assessmentsRoute = new Hono<HonoEnv>()
.offset(page * limit) .offset(page * limit)
.limit(limit); .limit(limit);
// Format the result to return an object where questionId is the key and optionId is the value
const formattedResult = result.reduce((acc, item) => {
if (item.questionId != null && item.optionId != null) {
acc[item.questionId] = item.optionId;
}
return acc;
}, {} as Record<string, string>); // Type assertion to ensure the accumulator is an object with string keys and values
return c.json({ return c.json({
data: formattedResult, data: result.map((d) => ({ ...d, fullCount: undefined })),
_metadata: { _metadata: {
currentPage: page, currentPage: page,
totalPages: Math.ceil( totalPages: Math.ceil(