From 378a7cd26a7105e7702f98bf5896c54dc475aacf Mon Sep 17 00:00:00 2001 From: Nastya Date: Wed, 4 Jun 2025 18:07:55 +0300 Subject: [PATCH] auditory --- lib/api/quizRelase.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index 9c1caf8..472bb6e 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -57,6 +57,9 @@ type PublicationMakeRequestParams = { method: "POST"; }; +const urlParams = new URLSearchParams(window.location.search); +const paudParam = urlParams.get("_paud"); + export const publicationMakeRequest = ({ url, body }: PublicationMakeRequestParams) => { return axios(url, { data: body, @@ -81,9 +84,17 @@ export async function getData({ quizId }: { quizId: string }): Promise<{ isRecentlyCompleted: boolean; error?: AxiosError; }> { + const body = { + quiz_id: quizId, + limit: 100, + page: 0, + need_config: true, + } as any; + if (paudParam) body.auditory = Number(paudParam); + try { const { data, headers } = await axios( - domain + `/answer/v1.0.0/settings${window.location.search}`, + domain + `/answer/v1.0.0/settings${window.location.pathname}`, { method: "POST", headers: { @@ -94,12 +105,7 @@ export async function getData({ quizId }: { quizId: string }): Promise<{ OS: OSDevice, Browser: userAgent, }, - data: { - quiz_id: quizId, - limit: 100, - page: 0, - need_config: true, - }, + data: body, } ); const sessions = JSON.parse(localStorage.getItem("sessions") || "{}"); @@ -131,7 +137,7 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n // Первый запрос: 1 вопрос + конфиг if (isFirstRequest) { const { data, headers } = await axios( - domain + `/answer/v1.0.0/settings${window.location.search}`, + domain + `/answer/v1.0.0/settings${window.location.pathname}`, { method: "POST", headers: { @@ -166,7 +172,7 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n // Если статус не AI - сразу делаем запрос за всеми вопросами if (globalStatus !== "ai") { const secondResponse = await axios( - domain + `/answer/v1.0.0/settings${window.location.search}`, + domain + `/answer/v1.0.0/settings${window.location.pathname}`, { method: "POST", headers: { @@ -195,7 +201,7 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n } // Последующие запросы - const response = await axios(domain + `/answer/v1.0.0/settings${window.location.search}`, { + const response = await axios(domain + `/answer/v1.0.0/settings${window.location.pathname}`, { method: "POST", headers: { "X-Sessionkey": SESSIONS,