feat(exam): add SAT style testing component
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user