auditory
This commit is contained in:
parent
d675530480
commit
c186a04fa5
@ -57,6 +57,9 @@ type PublicationMakeRequestParams = {
|
|||||||
method: "POST";
|
method: "POST";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
const paudParam = urlParams.get("_paud");
|
||||||
|
|
||||||
export const publicationMakeRequest = ({ url, body }: PublicationMakeRequestParams) => {
|
export const publicationMakeRequest = ({ url, body }: PublicationMakeRequestParams) => {
|
||||||
return axios(url, {
|
return axios(url, {
|
||||||
data: body,
|
data: body,
|
||||||
@ -81,27 +84,27 @@ export async function getData({ quizId }: { quizId: string }): Promise<{
|
|||||||
isRecentlyCompleted: boolean;
|
isRecentlyCompleted: boolean;
|
||||||
error?: AxiosError;
|
error?: AxiosError;
|
||||||
}> {
|
}> {
|
||||||
|
const body = {
|
||||||
|
quiz_id: quizId,
|
||||||
|
limit: 100,
|
||||||
|
page: 0,
|
||||||
|
need_config: true,
|
||||||
|
} as any;
|
||||||
|
if (paudParam) body.auditory = Number(paudParam);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, headers } = await axios<GetQuizDataResponse>(
|
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, {
|
||||||
domain + `/answer/v1.0.0/settings${window.location.search}`,
|
method: "POST",
|
||||||
{
|
headers: {
|
||||||
method: "POST",
|
"X-Sessionkey": SESSIONS,
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
"X-Sessionkey": SESSIONS,
|
DeviceType: DeviceType,
|
||||||
"Content-Type": "application/json",
|
Device: Device,
|
||||||
DeviceType: DeviceType,
|
OS: OSDevice,
|
||||||
Device: Device,
|
Browser: userAgent,
|
||||||
OS: OSDevice,
|
},
|
||||||
Browser: userAgent,
|
data: body,
|
||||||
},
|
});
|
||||||
data: {
|
|
||||||
quiz_id: quizId,
|
|
||||||
limit: 100,
|
|
||||||
page: 0,
|
|
||||||
need_config: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const sessions = JSON.parse(localStorage.getItem("sessions") || "{}");
|
const sessions = JSON.parse(localStorage.getItem("sessions") || "{}");
|
||||||
|
|
||||||
//Тут ещё проверка на антифрод без парса конфига. Нам не интересно время если не нужно запрещать проходить чаще чем в сутки
|
//Тут ещё проверка на антифрод без парса конфига. Нам не интересно время если не нужно запрещать проходить чаще чем в сутки
|
||||||
@ -130,26 +133,23 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n
|
|||||||
try {
|
try {
|
||||||
// Первый запрос: 1 вопрос + конфиг
|
// Первый запрос: 1 вопрос + конфиг
|
||||||
if (isFirstRequest) {
|
if (isFirstRequest) {
|
||||||
const { data, headers } = await axios<GetQuizDataResponse>(
|
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, {
|
||||||
domain + `/answer/v1.0.0/settings${window.location.search}`,
|
method: "POST",
|
||||||
{
|
headers: {
|
||||||
method: "POST",
|
"X-Sessionkey": SESSIONS,
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
"X-Sessionkey": SESSIONS,
|
DeviceType: DeviceType,
|
||||||
"Content-Type": "application/json",
|
Device: Device,
|
||||||
DeviceType: DeviceType,
|
OS: OSDevice,
|
||||||
Device: Device,
|
Browser: userAgent,
|
||||||
OS: OSDevice,
|
},
|
||||||
Browser: userAgent,
|
data: {
|
||||||
},
|
quiz_id: quizId,
|
||||||
data: {
|
limit: 1,
|
||||||
quiz_id: quizId,
|
page: 0,
|
||||||
limit: 1,
|
need_config: true,
|
||||||
page: 0,
|
},
|
||||||
need_config: true,
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
globalStatus = data.settings.status;
|
globalStatus = data.settings.status;
|
||||||
isFirstRequest = false;
|
isFirstRequest = false;
|
||||||
@ -165,26 +165,23 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n
|
|||||||
|
|
||||||
// Если статус не AI - сразу делаем запрос за всеми вопросами
|
// Если статус не AI - сразу делаем запрос за всеми вопросами
|
||||||
if (globalStatus !== "ai") {
|
if (globalStatus !== "ai") {
|
||||||
const secondResponse = await axios<GetQuizDataResponse>(
|
const secondResponse = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, {
|
||||||
domain + `/answer/v1.0.0/settings${window.location.search}`,
|
method: "POST",
|
||||||
{
|
headers: {
|
||||||
method: "POST",
|
"X-Sessionkey": SESSIONS,
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
"X-Sessionkey": SESSIONS,
|
DeviceType: DeviceType,
|
||||||
"Content-Type": "application/json",
|
Device: Device,
|
||||||
DeviceType: DeviceType,
|
OS: OSDevice,
|
||||||
Device: Device,
|
Browser: userAgent,
|
||||||
OS: OSDevice,
|
},
|
||||||
Browser: userAgent,
|
data: {
|
||||||
},
|
quiz_id: quizId,
|
||||||
data: {
|
limit: 100,
|
||||||
quiz_id: quizId,
|
page: 0,
|
||||||
limit: 100,
|
need_config: false,
|
||||||
page: 0,
|
},
|
||||||
need_config: false,
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
data: { ...data, items: secondResponse.data.items },
|
data: { ...data, items: secondResponse.data.items },
|
||||||
isRecentlyCompleted: false,
|
isRecentlyCompleted: false,
|
||||||
@ -195,7 +192,7 @@ export async function getDataSingle({ quizId, page }: { quizId: string; page?: n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Последующие запросы
|
// Последующие запросы
|
||||||
const response = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings${window.location.search}`, {
|
const response = await axios<GetQuizDataResponse>(domain + `/answer/v1.0.0/settings`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"X-Sessionkey": SESSIONS,
|
"X-Sessionkey": SESSIONS,
|
||||||
|
Loading…
Reference in New Issue
Block a user