feat(api): add attempt id and exam id to response (#61637)

This commit is contained in:
Shaun Hamilton
2025-08-04 18:12:46 +02:00
committed by GitHub
parent e41fd9ed13
commit 143565ce63
3 changed files with 21 additions and 3 deletions

View File

@@ -849,6 +849,8 @@ describe('/exam-environment/', () => {
);
const examEnvironmentExamAttempt = {
id: attempt.id,
examId: mock.exam.id,
result: null,
startTimeInMS: attempt.startTimeInMS,
questionSets: attempt.questionSets
@@ -887,6 +889,8 @@ describe('/exam-environment/', () => {
);
const examEnvironmentExamAttempt = {
id: attempt.id,
examId: mock.exam.id,
result: null,
startTimeInMS: attempt.startTimeInMS,
questionSets: attempt.questionSets
@@ -919,6 +923,8 @@ describe('/exam-environment/', () => {
);
const examEnvironmentExamAttempt = {
id: attempt.id,
examId: mock.exam.id,
result: {
score: 25,
passingPercent: 80
@@ -975,6 +981,8 @@ describe('/exam-environment/', () => {
);
const examEnvironmentExamAttempt = {
id: attempt.id,
examId: mock.exam.id,
result: null,
startTimeInMS: attempt.startTimeInMS,
questionSets: attempt.questionSets
@@ -1003,6 +1011,8 @@ describe('/exam-environment/', () => {
);
const examEnvironmentExamAttempt = {
id: attempt.id,
examId: mock.exam.id,
result: null,
startTimeInMS: attempt.startTimeInMS,
questionSets: attempt.questionSets
@@ -1033,6 +1043,8 @@ describe('/exam-environment/', () => {
);
const examEnvironmentExamAttempt = {
id: attempt.id,
examId: mock.exam.id,
result: {
score: 25,
passingPercent: 80

View File

@@ -27,6 +27,8 @@ export const examEnvironmentPostExamAttempt = {
};
const examEnvAttempt = Type.Object({
id: Type.String(),
examId: Type.String(),
startTimeInMS: Type.Number(),
questionSets: Type.Array(
Type.Object({
@@ -51,7 +53,9 @@ const examEnvAttempt = Type.Object({
export const examEnvironmentGetExamAttempts = {
headers: Type.Object({
'exam-environment-authorization-token': Type.String()
// Optional, because the handler is used in both the `/user/` base and `/exam-environment/` base
// If it is missing, auth will catch.
'exam-environment-authorization-token': Type.Optional(Type.String())
}),
response: {
200: Type.Array(examEnvAttempt),
@@ -64,7 +68,9 @@ export const examEnvironmentGetExamAttempt = {
attemptId: Type.String({ format: 'objectid' })
}),
headers: Type.Object({
'exam-environment-authorization-token': Type.String()
// Optional, because the handler is used in both the `/user/` base and `/exam-environment/` base.
// If it is missing, auth will catch.
'exam-environment-authorization-token': Type.Optional(Type.String())
}),
response: {
200: examEnvAttempt,

View File

@@ -932,5 +932,5 @@ export async function constructEnvExamAttempt(
}
function omitAttemptReferenceIds(attempt: ExamEnvironmentExamAttempt) {
return omit(attempt, ['examId', 'id', 'generatedExamId', 'userId']);
return omit(attempt, ['generatedExamId', 'userId']);
}