mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-20 12:03:11 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user