feat(api): add attempts routes to user (#61362)

Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com>
This commit is contained in:
Shaun Hamilton
2025-07-31 16:54:29 +02:00
committed by GitHub
parent 55fbe40152
commit 76c9fa9d48
2 changed files with 22 additions and 2 deletions

View File

@@ -812,7 +812,7 @@ async function getExams(
*
* If an attempt is completed, the result is included.
*/
async function getExamAttemptsHandler(
export async function getExamAttemptsHandler(
this: FastifyInstance,
req: UpdateReqType<typeof schemas.examEnvironmentGetExamAttempts>,
reply: FastifyReply
@@ -872,7 +872,7 @@ async function getExamAttemptsHandler(
*
* If the attempt is completed, the result is included.
*/
async function getExamAttemptHandler(
export async function getExamAttemptHandler(
this: FastifyInstance,
req: UpdateReqType<typeof schemas.examEnvironmentGetExamAttempt>,
reply: FastifyReply

View File

@@ -6,6 +6,7 @@ import jwt from 'jsonwebtoken';
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
import * as schemas from '../../schemas';
import * as examEnvironmentSchemas from '../../exam-environment/schemas';
import { createResetProperties } from '../../utils/create-user';
import { customNanoid } from '../../utils/ids';
import { encodeUserToken } from '../../utils/tokens';
@@ -27,6 +28,10 @@ import {
ProgressTimestamp
} from '../../utils/progress';
import { JWT_SECRET } from '../../utils/env';
import {
getExamAttemptHandler,
getExamAttemptsHandler
} from '../../exam-environment/routes/exam-environment';
/**
* Helper function to get the api url from the shared transcript link.
@@ -475,6 +480,21 @@ export const userRoutes: FastifyPluginCallbackTypebox = (
examEnvironmentTokenHandler
);
fastify.get(
'/user/exam-environment/exam/attempts',
{
schema: examEnvironmentSchemas.examEnvironmentGetExamAttempts
},
getExamAttemptsHandler
);
fastify.get(
'/user/exam-environment/exam/attempt/:attemptId',
{
schema: examEnvironmentSchemas.examEnvironmentGetExamAttempt
},
getExamAttemptHandler
);
done();
};