вопросы отправляют текст ответов а не ид. при отмене выбора отправляется пустая строка
This commit is contained in:
parent
b91cc475fe
commit
15431912ae
@ -431,6 +431,8 @@ function QuizPreviewLayoutByType({
|
|||||||
sx={{
|
sx={{
|
||||||
width: "60%",
|
width: "60%",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{backgroundBlock}
|
{backgroundBlock}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ const QID =
|
|||||||
process.env.NODE_ENV === "production" ?
|
process.env.NODE_ENV === "production" ?
|
||||||
window.location.pathname.replace(/\//g, '')
|
window.location.pathname.replace(/\//g, '')
|
||||||
:
|
:
|
||||||
"6955f170-f0f8-4b04-9be1-b8e3906fca5c"
|
"6e96e958-d30e-49f6-aa85-32aaef975733"
|
||||||
|
|
||||||
|
|
||||||
export const ViewPage = () => {
|
export const ViewPage = () => {
|
||||||
|
|||||||
@ -56,7 +56,6 @@ export const Date = ({ currentQuestion }: DateProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await sendAnswer({
|
await sendAnswer({
|
||||||
questionId: currentQuestion.id,
|
questionId: currentQuestion.id,
|
||||||
body: new window.Date(date.toDate()).toLocaleDateString("ru-RU", {
|
body: new window.Date(date.toDate()).toLocaleDateString("ru-RU", {
|
||||||
|
|||||||
@ -44,12 +44,14 @@ export const Emoji = ({ currentQuestion }: EmojiProps) => {
|
|||||||
value={currentQuestion.content.variants.findIndex(
|
value={currentQuestion.content.variants.findIndex(
|
||||||
({ id }) => answer === id
|
({ id }) => answer === id
|
||||||
)}
|
)}
|
||||||
onChange={({ target }) =>
|
onChange={({ target }) =>{
|
||||||
|
console.log(currentQuestion.content.variants[Number(target.value)])
|
||||||
updateAnswer(
|
updateAnswer(
|
||||||
currentQuestion.id,
|
currentQuestion.id,
|
||||||
currentQuestion.content.variants[Number(target.value)].id
|
currentQuestion.content.variants[Number(target.value)].answer
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
@ -104,18 +106,46 @@ export const Emoji = ({ currentQuestion }: EmojiProps) => {
|
|||||||
gap: "10px",
|
gap: "10px",
|
||||||
}}
|
}}
|
||||||
value={index}
|
value={index}
|
||||||
onClick={(event) => {
|
onClick={async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
updateAnswer(
|
try {
|
||||||
currentQuestion.id,
|
|
||||||
currentQuestion.content.variants[index].id
|
await sendAnswer({
|
||||||
);
|
questionId: currentQuestion.id,
|
||||||
|
body: currentQuestion.content.variants[index].answer,
|
||||||
|
//@ts-ignore
|
||||||
|
qid: settings.qid
|
||||||
|
})
|
||||||
|
|
||||||
|
updateAnswer(
|
||||||
|
currentQuestion.id,
|
||||||
|
currentQuestion.content.variants[index].id
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (answer === currentQuestion.content.variants[index].id) {
|
if (answer === currentQuestion.content.variants[index].id) {
|
||||||
deleteAnswer(currentQuestion.id);
|
deleteAnswer(currentQuestion.id);
|
||||||
|
try {
|
||||||
|
|
||||||
|
await sendAnswer({
|
||||||
|
questionId: currentQuestion.id,
|
||||||
|
body: "",
|
||||||
|
//@ts-ignore
|
||||||
|
qid: settings.qid
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
control={
|
control={
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
<Radio checkedIcon={<RadioCheck color={theme.palette.primary.main}/>} icon={<RadioIcon />} />
|
<Radio checkedIcon={<RadioCheck color={theme.palette.primary.main}/>} icon={<RadioIcon />} />
|
||||||
|
|||||||
@ -69,30 +69,42 @@ export const Images = ({ currentQuestion }: ImagesProps) => {
|
|||||||
border: `1px solid`,
|
border: `1px solid`,
|
||||||
borderColor: answer === variant.id ? theme.palette.primary.main : "#9A9AAF",
|
borderColor: answer === variant.id ? theme.palette.primary.main : "#9A9AAF",
|
||||||
}}
|
}}
|
||||||
onClick={async(event) => {
|
onClick={async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await sendAnswer({
|
await sendAnswer({
|
||||||
questionId: currentQuestion.id,
|
questionId: currentQuestion.id,
|
||||||
body: currentQuestion.content.variants[index].id,
|
body: currentQuestion.content.variants[index].answer,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
qid: settings.qid
|
qid: settings.qid
|
||||||
})
|
})
|
||||||
|
|
||||||
updateAnswer(
|
updateAnswer(
|
||||||
currentQuestion.id,
|
currentQuestion.id,
|
||||||
currentQuestion.content.variants[index].id
|
currentQuestion.content.variants[index].id
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
enqueueSnackbar("ответ не был засчитан")
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (answer === currentQuestion.content.variants[index].id) {
|
if (answer === currentQuestion.content.variants[index].id) {
|
||||||
deleteAnswer(currentQuestion.id);
|
deleteAnswer(currentQuestion.id);
|
||||||
|
try {
|
||||||
|
|
||||||
|
await sendAnswer({
|
||||||
|
questionId: currentQuestion.id,
|
||||||
|
body: "",
|
||||||
|
//@ts-ignore
|
||||||
|
qid: settings.qid
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -123,7 +135,7 @@ export const Images = ({ currentQuestion }: ImagesProps) => {
|
|||||||
value={index}
|
value={index}
|
||||||
control={
|
control={
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
<Radio checkedIcon={<RadioCheck color={theme.palette.primary.main}/>} icon={<RadioIcon />} />
|
<Radio checkedIcon={<RadioCheck color={theme.palette.primary.main} />} icon={<RadioIcon />} />
|
||||||
}
|
}
|
||||||
label={variant.answer}
|
label={variant.answer}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -45,15 +45,26 @@ export const Select = ({ currentQuestion }: SelectProps) => {
|
|||||||
onChange={async(_, value) => {
|
onChange={async(_, value) => {
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
deleteAnswer(currentQuestion.id);
|
deleteAnswer(currentQuestion.id);
|
||||||
|
try {
|
||||||
|
|
||||||
|
await sendAnswer({
|
||||||
|
questionId: currentQuestion.id,
|
||||||
|
body: "",
|
||||||
|
//@ts-ignore
|
||||||
|
qid: settings.qid
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await sendAnswer({
|
await sendAnswer({
|
||||||
questionId: currentQuestion.id,
|
questionId: currentQuestion.id,
|
||||||
body: String(value),
|
body: String(currentQuestion.content.variants[Number(value)].answer),
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
qid: settings.qid
|
qid: settings.qid
|
||||||
})
|
})
|
||||||
|
|||||||
@ -165,14 +165,14 @@ const VariantItem = ({
|
|||||||
checkedIcon={<CheckboxIcon checked color={theme.palette.primary.main} />}
|
checkedIcon={<CheckboxIcon checked color={theme.palette.primary.main} />}
|
||||||
icon={<CheckboxIcon />}
|
icon={<CheckboxIcon />}
|
||||||
/>
|
/>
|
||||||
) :
|
) :
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
(<Radio checkedIcon={<RadioCheck color={theme.palette.primary.main}/>} icon={<RadioIcon />} />
|
(<Radio checkedIcon={<RadioCheck color={theme.palette.primary.main} />} icon={<RadioIcon />} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
label={own ? <TextField label="Другое..." /> : variant.answer}
|
label={own ? <TextField label="Другое..." /> : variant.answer}
|
||||||
onClick={async(event) => {
|
onClick={async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const variantId = currentQuestion.content.variants[index].id;
|
const variantId = currentQuestion.content.variants[index].id;
|
||||||
|
|
||||||
@ -184,8 +184,8 @@ const VariantItem = ({
|
|||||||
await sendAnswer({
|
await sendAnswer({
|
||||||
questionId: currentQuestion.id,
|
questionId: currentQuestion.id,
|
||||||
body: currentAnswer.includes(variantId)
|
body: currentAnswer.includes(variantId)
|
||||||
? currentAnswer?.filter((item) => item !== variantId)
|
? currentAnswer?.filter((item) => item !== variantId)
|
||||||
: [...currentAnswer, variantId],
|
: [...currentAnswer, variantId],
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
qid: settings.qid
|
qid: settings.qid
|
||||||
})
|
})
|
||||||
@ -209,7 +209,7 @@ const VariantItem = ({
|
|||||||
|
|
||||||
await sendAnswer({
|
await sendAnswer({
|
||||||
questionId: currentQuestion.id,
|
questionId: currentQuestion.id,
|
||||||
body: variantId,
|
body: currentQuestion.content.variants[index].answer,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
qid: settings.qid
|
qid: settings.qid
|
||||||
})
|
})
|
||||||
@ -221,6 +221,18 @@ const VariantItem = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (answer === variantId) {
|
if (answer === variantId) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
await sendAnswer({
|
||||||
|
questionId: currentQuestion.id,
|
||||||
|
body: "",
|
||||||
|
//@ts-ignore
|
||||||
|
qid: settings.qid
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
|
}
|
||||||
deleteAnswer(currentQuestion.id);
|
deleteAnswer(currentQuestion.id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
|
|||||||
|
|
||||||
await sendAnswer({
|
await sendAnswer({
|
||||||
questionId: currentQuestion.id,
|
questionId: currentQuestion.id,
|
||||||
body: currentQuestion.content.variants[index].id,
|
body: currentQuestion.content.variants[index].answer,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
qid: settings.qid
|
qid: settings.qid
|
||||||
})
|
})
|
||||||
@ -103,6 +103,18 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
|
|||||||
|
|
||||||
|
|
||||||
if (answer === currentQuestion.content.variants[index].id) {
|
if (answer === currentQuestion.content.variants[index].id) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
await sendAnswer({
|
||||||
|
questionId: currentQuestion.id,
|
||||||
|
body: "",
|
||||||
|
//@ts-ignore
|
||||||
|
qid: settings.qid
|
||||||
|
})
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
enqueueSnackbar("ответ не был засчитан")
|
||||||
|
}
|
||||||
deleteAnswer(currentQuestion.id);
|
deleteAnswer(currentQuestion.id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user