feat(exam): add SAT style testing component

This commit is contained in:
shafin-r
2026-01-28 15:22:19 +06:00
parent 61b7c5220e
commit 355ca0c0c4
17 changed files with 1136 additions and 267 deletions

View File

@ -1,3 +1,10 @@
import type {
SessionAnswerResponse,
SessionQuestionsResponse,
SessionRequest,
SessionResponse,
SubmitAnswer,
} from "../types/session";
import type { PracticeSheet } from "../types/sheet";
const API_URL = "https://ed-dev-api.omukk.dev";
@ -121,6 +128,60 @@ class ApiClient {
token,
);
}
}
async startSession(
token: string,
sessionData: SessionRequest,
): Promise<SessionResponse> {
return this.authenticatedRequest<SessionResponse>(`/sessions/`, token, {
method: "POST",
body: JSON.stringify(sessionData),
});
}
async fetchSessionQuestions(
token: string,
sessionId: string,
): Promise<SessionQuestionsResponse> {
return this.authenticatedRequest<SessionQuestionsResponse>(
`/sessions/${sessionId}/questions/`,
token,
);
}
async submitAnswer(
token: string,
sessionId: string,
answerSubmissionData: SubmitAnswer,
): Promise<SessionAnswerResponse> {
return this.authenticatedRequest<SessionAnswerResponse>(
`/sessions/${sessionId}/answer/`,
token,
{
method: "POST",
body: JSON.stringify(answerSubmissionData),
},
);
}
async fetchNextModule(token: string, sessionId: string): Promise<any> {
return this.authenticatedRequest<any>(
`/sessions/${sessionId}/next-module/`,
token,
{
method: "POST",
},
);
}
async fetchSessionStateById(
token: string,
sessionId: string,
): Promise<SessionResponse> {
return this.authenticatedRequest<SessionResponse>(
`/sessions/${sessionId}`,
token,
);
}
}
export const api = new ApiClient(API_URL);