Merge branch 'dev' into 'main'

Dev

See merge request frontend/squiz!114
This commit is contained in:
Nastya 2024-01-06 20:24:59 +00:00
commit 066d519175
11 changed files with 31 additions and 26 deletions

@ -50,6 +50,7 @@ export interface Quiz {
question_cnt: number;
/** count passings */
passed_count: number;
sessions_count: number;
/** average time of passing */
average_time: number;
/** set true if squiz realize group functionality */
@ -108,6 +109,7 @@ export interface RawQuiz {
question_cnt: number;
/** count passings */
passed_count: number;
sessions_count: number;
/** average time of passing */
average_time: number;
/** set true if squiz realize group functionality */

@ -42,7 +42,7 @@ export default function QuestionsPage({
const { openedModalSettingsId } = useUiTools();
const isMobile = useMediaQuery(theme.breakpoints.down(660));
const quiz = useCurrentQuiz();
const navigate = useNavigate()
const navigate = useNavigate();
const { questions } = useQuestionsStore();
useLayoutEffect(() => {
updateEditSomeQuestion();
@ -51,8 +51,6 @@ export default function QuestionsPage({
const ref = useRef();
if (!quiz) return null;
return (
<>
<Box

@ -18,7 +18,11 @@ import { ResultCard, checkEmptyData } from "./cards/ResultCard";
import { EmailSettingsCard } from "./cards/EmailSettingsCard";
import { useCurrentQuiz } from "@root/quizes/hooks";
import { useQuestionsStore } from "@root/questions/store";
import { createResult, deleteQuestion, setQuestions } from "@root/questions/actions";
import {
createResult,
deleteQuestion,
setQuestions,
} from "@root/questions/actions";
import { QuizQuestionResult } from "@model/questionTypes/result";
import IconPlus from "@icons/IconPlus";
@ -31,7 +35,7 @@ import { questionApi } from "@api/question";
export const ResultSettings = () => {
const { questions } = useQuestionsStore();
const quiz = useCurrentQuiz();
const navigate = useNavigate()
const navigate = useNavigate();
const results = useQuestionsStore().questions.filter(
(q): q is QuizQuestionResult => q.type === "result",
);
@ -59,7 +63,6 @@ export const ResultSettings = () => {
[results],
);
const cnsl = results.filter((q) => q.content.usage);
const shouldBlock = true; // Replace this

@ -116,6 +116,7 @@ export const Footer = ({
}
const isEmpty = checkEmptyData({ resultData: nextQuestion });
console.log("isEmpty", isEmpty)
if (nextQuestion) {
if (nextQuestion && quiz?.config.resultInfo.when === "before") {
if (isEmpty) {
@ -221,7 +222,7 @@ export const Footer = ({
const questionIndex = questions.findIndex(({ id }) => id === question.id);
const previousQuestion = questions[questionIndex - 1];
followPreviousStep
followPreviousStep;
if (previousQuestion) {
setCurrentQuestion(previousQuestion);
}

@ -122,7 +122,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
onChange={({ target }) => {
updateAnswer(
currentQuestion.content.id,
window.Number(target.value.replace (/\D/, '')) > max
window.Number(target.value.replace(/\D/, "")) > max
? String(max)
: window.Number(target.value) < min
? String(min)
@ -155,7 +155,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
placeholder="0"
value={minRange}
onChange={({ target }) => {
setMinRange(target.value.replace (/\D/, ''));
setMinRange(target.value.replace(/\D/, ""));
if (window.Number(target.value) >= window.Number(maxRange)) {
updateMinRangeDebounced(`${maxRange}${maxRange}`, true);
@ -181,7 +181,7 @@ export const Number = ({ currentQuestion }: NumberProps) => {
placeholder="0"
value={maxRange}
onChange={({ target }) => {
setMaxRange(target.value.replace (/\D/, ''));
setMaxRange(target.value.replace(/\D/, ""));
if (window.Number(target.value) <= window.Number(minRange)) {
updateMaxRangeDebounced(`${minRange}${minRange}`, true);

@ -117,11 +117,11 @@ export const Variant = ({ currentQuestion }: VariantProps) => {
)}
</Box>
</Group>
{currentQuestion.content.back && (
{currentQuestion.content.back && currentQuestion.content.back !== " " && (
<Box sx={{ maxWidth: "400px", width: "100%", height: "300px" }}>
<img
src={currentQuestion.content.back}
style={{ width: "100%", height: "100%", objectFit: "cover" }}
style={{ width: "100%", height: "100%", objectFit: "cover", margin: "10px" }}
alt=""
/>
</Box>

@ -138,8 +138,8 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
style={{ width: "100%", height: "100%", objectFit: "cover" }}
alt=""
/>
) : variant?.extendedText || isMobile ? (
"Выберите вариант ответа ниже"
) : (currentQuestion.content.replText !== " " && currentQuestion.content.replText.length > 0) ? currentQuestion.content.replText : variant?.extendedText || isMobile ? (
"Выберите вариант ответа ниже"
) : (
"Выберите вариант ответа слева"
)}

@ -75,15 +75,15 @@ export default function MyQuizzesFull({
mb: "60px",
}}
>
{quizes.map((quiz) => (
<QuizCard
{quizes.map((quiz) => {
return <QuizCard
key={quiz.id}
quiz={quiz}
openCount={0}
applicationCount={0}
conversionPercent={0}
openCount={quiz.sessions_count}
applicationCount={quiz.passed_count}
conversionPercent={quiz.sessions_count ? (quiz.passed_count/quiz.sessions_count * 100).toFixed(1) : 0}
/>
))}
})}
</Box>
{children}
</SectionWrapper>

@ -98,8 +98,8 @@ export default function QuizCard({
>
{quiz.name.length === 0 || quiz.name === " "
? quiz.config.type === "form"
? "Анкета " + questionCount.current
: "Квиз " + questionCount.current
? "Form " + quiz.backendId
: "Quiz " + quiz.backendId
: quiz.name}
</Typography>
<Box

@ -107,6 +107,7 @@ export default function EditPage({
const isConditionMet =
[1].includes(currentStep) && quizConfig.type !== "form";
console.log(quiz)
return (
<>
<Box

@ -138,8 +138,8 @@ export default function Varimg({ question, widthPreview }: Props) {
<Box
sx={{
border: "1px solid #E3E3E3",
maxWidth: "400px",
height: "400px",
width: widthPreview < 650 ? "300px" : "400px",
height: widthPreview < 650 ? "300px" : "400px",
display: "flex",
justifyContent: "center",
alignItems: "center",
@ -165,8 +165,8 @@ export default function Varimg({ question, widthPreview }: Props) {
<Typography p={2}>
{selectedVariantIndex === -1
? widthPreview < 650
? "Выберите вариант ниже"
: "Выберите вариант"
? question?.content.replText || "Выберите вариант ниже"
: question?.content.replText || "Выберите вариант"
: "Картинка отсутствует"}
</Typography>
)}