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

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

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

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

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

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

@ -138,8 +138,8 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
style={{ width: "100%", height: "100%", objectFit: "cover" }} style={{ width: "100%", height: "100%", objectFit: "cover" }}
alt="" 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", mb: "60px",
}} }}
> >
{quizes.map((quiz) => ( {quizes.map((quiz) => {
<QuizCard return <QuizCard
key={quiz.id} key={quiz.id}
quiz={quiz} quiz={quiz}
openCount={0} openCount={quiz.sessions_count}
applicationCount={0} applicationCount={quiz.passed_count}
conversionPercent={0} conversionPercent={quiz.sessions_count ? (quiz.passed_count/quiz.sessions_count * 100).toFixed(1) : 0}
/> />
))} })}
</Box> </Box>
{children} {children}
</SectionWrapper> </SectionWrapper>

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

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

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