Compare commits
7 Commits
main
...
1335275ed7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1335275ed7 | ||
| a144621365 | |||
| 2df7ed36de | |||
| c37b24ec38 | |||
| 7684b8d705 | |||
| 0b76fc69e5 | |||
| 4f8f033306 |
@@ -2,7 +2,7 @@ import NavBar from './components/Navbar'
|
|||||||
import Gallery from "./components/Gallery";
|
import Gallery from "./components/Gallery";
|
||||||
import Content from "./components/Content";
|
import Content from "./components/Content";
|
||||||
import CustomFooter from "./components/CustomFooter";
|
import CustomFooter from "./components/CustomFooter";
|
||||||
import Task from "./Task"
|
|
||||||
|
|
||||||
import './styles/App.css'
|
import './styles/App.css'
|
||||||
|
|
||||||
@@ -13,7 +13,6 @@ function App() {
|
|||||||
<Gallery/>
|
<Gallery/>
|
||||||
<Content/>
|
<Content/>
|
||||||
<CustomFooter/>
|
<CustomFooter/>
|
||||||
<Task/>
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { useState,useEffect } from "react"
|
|
||||||
import type {ReactElement} from "react"
|
|
||||||
const lines = [
|
|
||||||
"Ночь, улица, фонарь, аптека,",
|
|
||||||
"Бессмыссленный и тусклый свет.",
|
|
||||||
"Живи ещё хоть четверть века - ",
|
|
||||||
"Всё будет так. Исхода нет.",
|
|
||||||
"Умрёшь - начнёшь опять сначала",
|
|
||||||
"И повториться всё как встарь:",
|
|
||||||
"Ночь, ледяная рябь канала",
|
|
||||||
"Аптека, Улица, фонарь."
|
|
||||||
];
|
|
||||||
|
|
||||||
interface ComponentProps {
|
|
||||||
Inputinterval: number
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Task = ({Inputinterval}:ComponentProps): ReactElement =>{
|
|
||||||
const [interval, updateInterval] = useState<number>(Inputinterval);
|
|
||||||
const [lineIdx, updateLineIdx] = useState<number>(0);
|
|
||||||
const updateLine = ():void =>{
|
|
||||||
updateLineIdx((lineIdx+1)%lines.length);
|
|
||||||
}
|
|
||||||
useEffect(()=>{
|
|
||||||
const intervalId = setInterval(updateLine,Number(interval));
|
|
||||||
return ()=>{ clearInterval(intervalId)}
|
|
||||||
})
|
|
||||||
return(
|
|
||||||
<>
|
|
||||||
<input type="number" value={interval} onChange={(event)=>{updateInterval(Number(event.target.value))}}></input>
|
|
||||||
<div className="blackDiv">
|
|
||||||
<h2 className="bigWhite">{lines[lineIdx]}</h2>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default Task;
|
|
||||||
@@ -24,10 +24,8 @@ interface ComponentProps {
|
|||||||
|
|
||||||
|
|
||||||
function BuildCard({ building,cardNum} : ComponentProps) {
|
function BuildCard({ building,cardNum} : ComponentProps) {
|
||||||
const reverseModifier = cardNum % 2 == 0 ? "-reverse" : "";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card sx={{ display: 'flex', flexDirection:{xs:"column", sm:"row"+reverseModifier} }} >
|
<Card style={cardNum%2==0?{'flexDirection':'row-reverse'}:{}}sx={{ display: 'flex' }} >
|
||||||
<CardMedia
|
<CardMedia
|
||||||
component="img"
|
component="img"
|
||||||
alt={ building.title }
|
alt={ building.title }
|
||||||
|
|||||||
@@ -10,43 +10,21 @@ type GroupProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function GroupChart({ data }: GroupProps) {
|
function GroupChart({ data }: GroupProps) {
|
||||||
const [isBar, setIsBar] = useState(true);
|
const [isBar, setIsBar] = useState(true);
|
||||||
const [doStack, setDoStack] = useState(false);
|
|
||||||
const [series, setSeries] = useState({
|
const [series, setSeries] = useState({
|
||||||
'min': false,
|
|
||||||
'mean': false,
|
|
||||||
'max': true,
|
'max': true,
|
||||||
|
'mean': false,
|
||||||
|
'min': false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const deltas = data.map((val) => {
|
|
||||||
const out = { ...val };
|
|
||||||
const deltaMinMean = (val["mean"] - (Number(series["min"])?val["min"]:0));
|
|
||||||
const deltaMeanMax = (val["max"] - (Number(series["mean"])?val["mean"]:(series["min"]?val["min"]:0)));
|
|
||||||
out["mean"] = deltaMinMean;
|
|
||||||
out["max"] = deltaMeanMax;
|
|
||||||
return out;
|
|
||||||
})
|
|
||||||
const formatLabel = (key:string)=>(value:number,didx:{dataIndex:number}):number => {
|
|
||||||
const idx= didx["dataIndex"]
|
|
||||||
return String(data[idx][key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedSeries = Object.entries(series).filter(item => item[1] === true);
|
const selectedSeries = Object.entries(series).filter(item => item[1] === true);
|
||||||
|
|
||||||
let seriesY = selectedSeries.map(item => {
|
let seriesY = selectedSeries.map(item => {
|
||||||
return {
|
return {
|
||||||
dataKey: item[0],
|
dataKey: item[0],
|
||||||
label: item[0],
|
label: item[0],
|
||||||
barLabel: (selectedSeries.length === 1) && (data.length < 20) ? ('value' as const) : undefined,
|
barLabel: selectedSeries.length === 1 ? ('value' as const) : undefined,
|
||||||
stack: doStack && isBar ? 'prices' : undefined,
|
|
||||||
valueFormatter: (doStack && isBar)? formatLabel(item[0]):(v:number)=>String(v)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(seriesY)
|
|
||||||
console.log(doStack)
|
|
||||||
const chartSetting = {
|
const chartSetting = {
|
||||||
yAxis: [{ label: 'Price ($)' }],
|
yAxis: [{ label: 'Price ($)' }],
|
||||||
height: 400,
|
height: 400,
|
||||||
@@ -55,7 +33,7 @@ function GroupChart({ data }: GroupProps) {
|
|||||||
return (
|
return (
|
||||||
<Container maxWidth="lg">
|
<Container maxWidth="lg">
|
||||||
{isBar && <BarChart
|
{isBar && <BarChart
|
||||||
dataset={doStack ? deltas : data}
|
dataset={data}
|
||||||
xAxis={[{ scaleType: 'band', dataKey: 'group' }]}
|
xAxis={[{ scaleType: 'band', dataKey: 'group' }]}
|
||||||
series={seriesY}
|
series={seriesY}
|
||||||
slotProps={{
|
slotProps={{
|
||||||
@@ -65,7 +43,7 @@ function GroupChart({ data }: GroupProps) {
|
|||||||
}}
|
}}
|
||||||
{...chartSetting}
|
{...chartSetting}
|
||||||
/>}
|
/>}
|
||||||
{!isBar && <LineChart
|
{!isBar &&<LineChart
|
||||||
dataset={data}
|
dataset={data}
|
||||||
xAxis={[{ scaleType: 'band', dataKey: 'group' }]}
|
xAxis={[{ scaleType: 'band', dataKey: 'group' }]}
|
||||||
series={seriesY}
|
series={seriesY}
|
||||||
@@ -76,7 +54,7 @@ function GroupChart({ data }: GroupProps) {
|
|||||||
}}
|
}}
|
||||||
{...chartSetting}
|
{...chartSetting}
|
||||||
/>}
|
/>}
|
||||||
<SettingChart series={series} setSeries={setSeries} isBar={isBar} setIsBar={setIsBar} doStack={doStack} setDoStack={setDoStack} />
|
<SettingChart series={series} setSeries={setSeries} isBar={isBar} setIsBar={setIsBar} />
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import Stack from '@mui/material/Stack';
|
|||||||
import Divider from '@mui/material/Divider';
|
import Divider from '@mui/material/Divider';
|
||||||
import RadioGroup from '@mui/material/RadioGroup';
|
import RadioGroup from '@mui/material/RadioGroup';
|
||||||
import Radio from '@mui/material/Radio';
|
import Radio from '@mui/material/Radio';
|
||||||
import Switch from '@mui/material/Switch';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type tSeries = {
|
type tSeries = {
|
||||||
@@ -21,12 +19,9 @@ type CheckboxProps = {
|
|||||||
setSeries: React.Dispatch<React.SetStateAction<tSeries>>;
|
setSeries: React.Dispatch<React.SetStateAction<tSeries>>;
|
||||||
isBar: boolean;
|
isBar: boolean;
|
||||||
setIsBar: React.Dispatch<React.SetStateAction<boolean>>
|
setIsBar: React.Dispatch<React.SetStateAction<boolean>>
|
||||||
doStack: boolean;
|
|
||||||
setDoStack: React.Dispatch<React.SetStateAction<boolean>>
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function SettingChart({ series, setSeries, isBar, setIsBar, doStack, setDoStack }: CheckboxProps) {
|
function SettingChart({ series, setSeries, isBar, setIsBar }: CheckboxProps) {
|
||||||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setSeries({
|
setSeries({
|
||||||
...series,
|
...series,
|
||||||
@@ -34,10 +29,6 @@ function SettingChart({ series, setSeries, isBar, setIsBar, doStack, setDoStack
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeDoStack =(event:React.ChangeEvent<HTMLInputElement>)=>{
|
|
||||||
setDoStack(event.target.checked)
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleRadioButtonChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleRadioButtonChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setIsBar(event.target.value === "bar");
|
setIsBar(event.target.value === "bar");
|
||||||
};
|
};
|
||||||
@@ -98,17 +89,6 @@ function SettingChart({ series, setSeries, isBar, setIsBar, doStack, setDoStack
|
|||||||
}
|
}
|
||||||
label="Min price"
|
label="Min price"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Switch
|
|
||||||
checked={doStack}
|
|
||||||
onChange={changeDoStack}
|
|
||||||
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="Do Stack"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Stack>
|
</Stack>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ type GroupedRamPrice =Array<{
|
|||||||
id: number;
|
id: number;
|
||||||
group: string | number;
|
group: string | number;
|
||||||
min:number;
|
min:number;
|
||||||
mean:number;
|
|
||||||
max:number;
|
max:number;
|
||||||
|
mean:number;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
const gropuedPrices = groupBycolumns.map((col) => {
|
const gropuedPrices = groupBycolumns.map((col) => {
|
||||||
@@ -184,10 +184,9 @@ const gropuedPrices = groupBycolumns.map((col) => {
|
|||||||
out.push({
|
out.push({
|
||||||
id: out.length + 1,
|
id: out.length + 1,
|
||||||
group: key,
|
group: key,
|
||||||
mean: Math.round((d3.mean(prices) ?? 0)*1000)/1000,
|
|
||||||
max: d3.max(prices) ?? 0,
|
|
||||||
min: d3.min(prices) ?? 0,
|
min: d3.min(prices) ?? 0,
|
||||||
|
max: d3.max(prices) ?? 0,
|
||||||
|
mean: Math.round((d3.mean(prices) ?? 0)*1000)/1000,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function Gallery() {
|
|||||||
sx={{
|
sx={{
|
||||||
columnCount: {
|
columnCount: {
|
||||||
xs: '1 !important',
|
xs: '1 !important',
|
||||||
sm: '1 !important',
|
sm: '3 !important',
|
||||||
md: '3 !important',
|
md: '3 !important',
|
||||||
lg: '3 !important',
|
lg: '3 !important',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export function SortableItem({ item ,isDisabled}: SortableItemProps) {
|
|||||||
sx={{
|
sx={{
|
||||||
border: '1px solid gray',
|
border: '1px solid gray',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
height:"4.4em"
|
|
||||||
}}>
|
}}>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<DragIndicatorIcon />
|
<DragIndicatorIcon />
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
import { Grid, List, ListItem, ListItemButton, ListItemText } from '@mui/material';
|
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
|
||||||
import type { tTasks } from "../quizData"
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
import { addList, mixUp } from './quizSlice';
|
|
||||||
import Checkbox from '@mui/material/Checkbox';
|
|
||||||
import type { RootState } from '../../store';
|
|
||||||
import type { ChangeEvent } from 'react';
|
|
||||||
import { setCheckedItems } from './quizSlice';
|
|
||||||
|
|
||||||
|
|
||||||
interface ComponentProps {
|
|
||||||
tasks: tTasks;
|
|
||||||
index: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Matching({ tasks, index }: ComponentProps) {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const answers: boolean[] = tasks.map((item) => Boolean(item.answer));
|
|
||||||
const items: string[] = tasks.map((item) => String(item.answer));
|
|
||||||
const arr = useSelector((state: RootState) => state.quiz.userAnswers[index]);
|
|
||||||
// const correctAnswers = useSelector((state: RootState) => state.quiz.correctAnswers[index]);
|
|
||||||
const questions = useSelector((state: RootState) => state.quiz.questions[index]);
|
|
||||||
const isDisabled = useSelector((state: RootState) => state.quiz.isTestingDone);
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(addList({ index, items: items,questions:tasks.map((item) => String(item.question)), answers: answers, quizType: "M" }));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(mixUp());
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
|
||||||
const handleCheckboxAction = (checkboxIndex: number) => (_: ChangeEvent<HTMLInputElement, Element>, checked: boolean) => {
|
|
||||||
let answersCopy = arr.map((x)=>(Boolean(x)));
|
|
||||||
answersCopy[checkboxIndex] = checked;
|
|
||||||
dispatch(setCheckedItems({ index, items: answersCopy }));
|
|
||||||
};
|
|
||||||
|
|
||||||
// console.log(arr);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid container spacing={2}>
|
|
||||||
<Grid size={12}>
|
|
||||||
<List>
|
|
||||||
{tasks.map((_, itemIndex) => (
|
|
||||||
<ListItem key={itemIndex}>
|
|
||||||
<ListItemButton
|
|
||||||
sx={{
|
|
||||||
border: '1px solid gray',
|
|
||||||
borderRadius: '5px',
|
|
||||||
textAlign: 'right',
|
|
||||||
}}>
|
|
||||||
<ListItemText primary={arr == undefined ? "loading": questions[itemIndex]} />
|
|
||||||
<Checkbox
|
|
||||||
onChange={isDisabled ? (..._) => { _ } : handleCheckboxAction(itemIndex)}
|
|
||||||
checked={Boolean(arr == undefined ? false : arr[itemIndex])}
|
|
||||||
sx={{ '& .MuiSvgIcon-root': { fontSize: 28 } }}
|
|
||||||
/>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
))}
|
|
||||||
</List>
|
|
||||||
</Grid>
|
|
||||||
<Grid size={12}>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Matching
|
|
||||||
@@ -1,52 +1,51 @@
|
|||||||
import { Grid, List, ListItem, ListItemButton, ListItemText } from '@mui/material';
|
import { Grid, List, ListItem, ListItemButton, ListItemText } from '@mui/material';
|
||||||
import type { tTasks } from "../quizData"
|
import type {tTasks} from "../quizData"
|
||||||
import SortableList from '../features/SortableList';
|
import SortableList from '../features/SortableList';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { addList, mixUp } from './quizSlice';
|
import { addList,mixUp } from './quizSlice';
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
tasks: tTasks;
|
tasks: tTasks;
|
||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Matching({ tasks, index }: ComponentProps) {
|
function Matching({tasks,index}: ComponentProps) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const answers: string[] = tasks.map((item) => String(item.answer));
|
|
||||||
// Добавляем список ответов очередного задания в хранилище
|
// Добавляем список ответов очередного задания в хранилище
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(addList({ index, items: answers, answers:answers, questions:tasks.map((item) => String(item.question)), quizType: "M" }));
|
dispatch(addList({ index, items: answers }));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(mixUp());
|
dispatch(mixUp());
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
const answers: string[] = tasks.map((item) => String(item.answer));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container spacing={2}>
|
<Grid container spacing={2}>
|
||||||
<Grid size={6}>
|
<Grid size={6}>
|
||||||
<List>
|
<List>
|
||||||
{tasks.map((item, index) => (
|
{tasks.map((item, index) => (
|
||||||
<ListItem key={index}>
|
<ListItem key={index}>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
sx={{
|
sx={{
|
||||||
border: '1px solid gray',
|
border: '1px solid gray',
|
||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
textAlign: 'right',
|
textAlign: 'right',
|
||||||
height:"4.4em"
|
}}>
|
||||||
}}>
|
<ListItemText primary={item.question} />
|
||||||
<ListItemText primary={item.question} />
|
</ListItemButton>
|
||||||
</ListItemButton>
|
</ListItem>
|
||||||
</ListItem>
|
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid size={6}>
|
<Grid size={6}>
|
||||||
<SortableList index={index} answers={answers} />
|
<SortableList index={index} answers={answers}/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +1,35 @@
|
|||||||
import { Box, Button, Container, Typography } from '@mui/material';
|
import { Box, Button, Container, Typography } from '@mui/material';
|
||||||
import { quiz } from "../quizData";
|
import { quiz } from "../quizData";
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { useState } from 'react';
|
import {useState } from 'react';
|
||||||
import Matching from './Matching';
|
import Matching from './Matching';
|
||||||
import Sorting from './Sorting';
|
|
||||||
import Choosing from './Choosing';
|
|
||||||
import type { RootState } from '../../store';
|
import type { RootState } from '../../store';
|
||||||
import store from '../../store';
|
import store from '../../store';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { mixUp, startTesting, stopTesting } from './quizSlice';
|
import { mixUp, startTesting, stopTesting } from './quizSlice';
|
||||||
|
|
||||||
function QuizStats() {
|
function QuizStats() {
|
||||||
let correctAnswers = useSelector((state: RootState) => state.quiz.correctAnswers);
|
|
||||||
const userAnswers = useSelector((state: RootState) => state.quiz.userAnswers);
|
|
||||||
|
|
||||||
const correctCount = (index: number): number => {
|
const correctCount = (index: number):number => {
|
||||||
|
let quiz = useSelector((state: RootState) => state.quiz);
|
||||||
let state = store.getState();
|
let state = store.getState();
|
||||||
if (state.quiz.correctAnswers.length <= index) {
|
if (state.quiz.correctAnswers.length <= index) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return userAnswers[index].reduce((prev, answ, i) => prev + Number(correctAnswers[index][i] === answ), 0);
|
return quiz.userAnswers[index].reduce((prev, answ, i) => prev + Number(quiz.correctAnswers[index][i] === answ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const counts = userAnswers.map((_,index)=>correctCount(index));
|
const quizPartText = (counter:number, len:number):string=>{
|
||||||
const questionCounts = userAnswers.map((answers)=>answers.length);
|
|
||||||
|
|
||||||
const total= counts.reduce((x,c)=>c+x,0);
|
|
||||||
const totalQuestionCount= questionCounts.reduce((x,c)=>c+x,0);
|
|
||||||
|
|
||||||
const donePercentage = Math.round(total/totalQuestionCount*100*100)/100;
|
|
||||||
|
|
||||||
const quizPartText = (counter: number, len: number, taskIndex:number) => {
|
|
||||||
if (counter == len) {
|
if (counter == len) {
|
||||||
return <Typography key={taskIndex}>Task {taskIndex+1}: everethyng is correct</Typography>
|
return "все ответы верные"
|
||||||
}
|
}
|
||||||
return <Typography key={taskIndex}>Task {taskIndex+1}: correct {counter}/{len}</Typography>
|
return `верно ${counter}/${len}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container sx={{ margin: "auto", d:"flex",flexDirection:"column" }}>
|
<Container sx={{ margin: "auto" }}>
|
||||||
<h2>Результаты теста</h2>
|
<h3>Результаты теста</h3>
|
||||||
{
|
{/* <Typography>Задание 1: {checkTask(0)}</Typography> */}
|
||||||
counts.map((count,idx)=>quizPartText(count,questionCounts[idx],idx))
|
{/* <Typography>Задание 2: {checkTask(1)}</Typography> */}
|
||||||
}
|
|
||||||
<h3>Итого {donePercentage}% Верно</h3>
|
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -68,27 +53,18 @@ function Quiz() {
|
|||||||
return (
|
return (
|
||||||
<Container maxWidth="md">
|
<Container maxWidth="md">
|
||||||
{quiz.map((item, index) => (
|
{quiz.map((item, index) => (
|
||||||
<Box key={item.id} component="section" sx={{ m: 2, p: 2}}>
|
<Box key={item.id} component="section" sx={{ m: 2, p: 2 }}>
|
||||||
<Typography variant="h5" gutterBottom>
|
<Typography variant="h5" gutterBottom>
|
||||||
{index + 1}. {item.title}
|
{index + 1}. {item.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
{[
|
{[<Matching index={index} tasks={item.tasks} />,<>S</>,<>c</>][(["M","S","C"].indexOf(item.type))]}
|
||||||
|
|
||||||
<Matching index={index} tasks={item.tasks} key={index}/>,
|
|
||||||
|
|
||||||
<Sorting index={index} tasks={item.tasks} key={index}/>,
|
|
||||||
|
|
||||||
<Choosing index={index} tasks={item.tasks} key={index}/>
|
|
||||||
|
|
||||||
][(["M", "S", "C"].indexOf(item.type))]}
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
))}
|
))}
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-around' }}>
|
|
||||||
<Button onClick={checkQuiz} variant="contained">Check</Button>
|
|
||||||
<Button onClick={resetQuiz} variant="contained">Reset</Button>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-around' }}>
|
||||||
|
<Button onClick={checkQuiz} variant="contained">Проверить</Button>
|
||||||
|
<Button onClick={resetQuiz} variant="contained">Начать снова</Button>
|
||||||
|
</Box>
|
||||||
{displayingResults && <QuizStats />}
|
{displayingResults && <QuizStats />}
|
||||||
|
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { useDispatch, useSelector } from 'react-redux';
|
|||||||
import { setDraggedItems } from './quizSlice';
|
import { setDraggedItems } from './quizSlice';
|
||||||
import type { RootState } from '../../store';
|
import type { RootState } from '../../store';
|
||||||
import List from '@mui/material/List';
|
import List from '@mui/material/List';
|
||||||
import { SortableItem } from '../components/SortableItem';
|
import { SortableItem } from '../components/SortableItem'
|
||||||
|
|
||||||
interface ComponentProps {
|
interface ComponentProps {
|
||||||
index: number;
|
index: number;
|
||||||
answers: string[];
|
answers: string[];
|
||||||
@@ -33,7 +34,7 @@ function SortableList({ index}: ComponentProps) {
|
|||||||
strategy={verticalListSortingStrategy}>
|
strategy={verticalListSortingStrategy}>
|
||||||
<List>
|
<List>
|
||||||
{draggedItems.map((item) => (
|
{draggedItems.map((item) => (
|
||||||
<SortableItem key={String(item)} item={String(item)} id={String(item)} isDisabled={isDisabled} />
|
<SortableItem key={String(item)} item={String(item)} id={String(item)} isDisabled={isDisabled}/>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
</SortableContext>
|
</SortableContext>
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
import { Grid} from '@mui/material';
|
|
||||||
import type { tTasks } from "../quizData"
|
|
||||||
import SortableList from '../features/SortableList';
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
import { useDispatch } from 'react-redux';
|
|
||||||
import { addList, mixUp } from './quizSlice';
|
|
||||||
interface ComponentProps {
|
|
||||||
tasks: tTasks;
|
|
||||||
index: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Matching({ tasks, index }: ComponentProps) {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const answers: string[] = tasks.map((item) => String(item.answer));
|
|
||||||
// Добавляем список ответов очередного задания в хранилище
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(addList({ index, items: answers, answers:answers,questions:tasks.map((item) => String(item.question)), quizType: "M" }));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(mixUp());
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid container spacing={2}>
|
|
||||||
<Grid size={12}>
|
|
||||||
<SortableList index={index} answers={answers} />
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Matching
|
|
||||||
@@ -20,7 +20,6 @@ function shuffle<T>(array: Array<T>): Array<T> {
|
|||||||
|
|
||||||
interface QuizState {
|
interface QuizState {
|
||||||
userAnswers: (string | boolean)[][]; // хранит перемещаемые элементы каждого списка ответов
|
userAnswers: (string | boolean)[][]; // хранит перемещаемые элементы каждого списка ответов
|
||||||
questions: string[][];
|
|
||||||
correctAnswers: (string | boolean)[][];// ответы для вопрсов, в случае с matching просто правильная последоавтельность, для sorting аналогично, для choosе последоватеьность boolean
|
correctAnswers: (string | boolean)[][];// ответы для вопрсов, в случае с matching просто правильная последоавтельность, для sorting аналогично, для choosе последоватеьность boolean
|
||||||
quizTypes: Array<"M" | "S" | "C">;
|
quizTypes: Array<"M" | "S" | "C">;
|
||||||
isTestingDone: boolean// запрет на взаимодействие с квизом после окончания тестирования, чтобю юзер не наглел
|
isTestingDone: boolean// запрет на взаимодействие с квизом после окончания тестирования, чтобю юзер не наглел
|
||||||
@@ -30,7 +29,6 @@ const initialState: QuizState = {
|
|||||||
userAnswers: [],
|
userAnswers: [],
|
||||||
correctAnswers: [],
|
correctAnswers: [],
|
||||||
quizTypes: [],
|
quizTypes: [],
|
||||||
questions:[],
|
|
||||||
isTestingDone: false,
|
isTestingDone: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,9 +36,8 @@ const listsSlice = createSlice({
|
|||||||
name: 'lists',
|
name: 'lists',
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
addList: (state, action: PayloadAction<{ index: number; items: string[]; questions: string[]; answers: (string|boolean)[]; quizType : "S" | "M" | "C"}>) => {
|
addList: (state, action: PayloadAction<{ index: number; items: string[]; answers: (string|boolean)[]; quizType : "S" | "M" | "C"}>) => {
|
||||||
const { index, items,questions,answers,quizType} = action.payload;
|
const { index, items,answers,quizType} = action.payload;
|
||||||
state.questions.splice(index, 1, questions);
|
|
||||||
state.userAnswers.splice(index, 1, items); // с нулём создаётся по 2 экземпляра, видно в отладке
|
state.userAnswers.splice(index, 1, items); // с нулём создаётся по 2 экземпляра, видно в отладке
|
||||||
state.quizTypes.splice(index, 1, quizType); //
|
state.quizTypes.splice(index, 1, quizType); //
|
||||||
state.correctAnswers.splice(index, 1, answers);
|
state.correctAnswers.splice(index, 1, answers);
|
||||||
@@ -52,20 +49,16 @@ const listsSlice = createSlice({
|
|||||||
state.userAnswers[index] = items; // обновляем конкретный список
|
state.userAnswers[index] = items; // обновляем конкретный список
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCheckedItems: (state, action: PayloadAction<{ index: number; items: boolean[] }>) => {
|
setCheckedItems: (state, action: PayloadAction<{ index: number; items: (string|boolean)[] }>) => {
|
||||||
const { index, items } = action.payload;
|
const { index, items } = action.payload;
|
||||||
if (index >= 0 && index < state.userAnswers.length) {
|
if (index >= 0 && index < state.userAnswers.length) {
|
||||||
state.userAnswers[index] = items; // обновляем конкретный список
|
state.userAnswers[index] = items; // обновляем конкретный список
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mixUp: (state) => {
|
mixUp: (state) => {
|
||||||
state.userAnswers = state.userAnswers.map((list,index) => {
|
state.userAnswers = state.userAnswers.map((list) => {
|
||||||
if(typeof(state.correctAnswers[index][0])==="boolean"){
|
if(typeof(list[0])==="boolean"){
|
||||||
list.map(()=>false);
|
return list.map(()=>false);
|
||||||
let indexes = shuffle( list.map((_,idx)=>idx));
|
|
||||||
state.correctAnswers[index]=state.correctAnswers[index].map((_,i,arr)=>arr[indexes[i]])
|
|
||||||
state.questions[index]=state.questions[index].map((_,i,arr)=>arr[indexes[i]])
|
|
||||||
return list.map(()=>false)
|
|
||||||
}
|
}
|
||||||
return shuffle<string|boolean>(list);
|
return shuffle<string|boolean>(list);
|
||||||
})
|
})
|
||||||
@@ -80,6 +73,6 @@ const listsSlice = createSlice({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Экспортируем действия и редьюсер
|
// Экспортируем действия и редьюсер
|
||||||
export const { addList, setDraggedItems,setCheckedItems, mixUp, startTesting, stopTesting } = listsSlice.actions;
|
export const { addList, setDraggedItems, mixUp, startTesting, stopTesting } = listsSlice.actions;
|
||||||
export type { QuizState }
|
export type { QuizState }
|
||||||
export default listsSlice.reducer;
|
export default listsSlice.reducer;
|
||||||
@@ -11,142 +11,82 @@ export type tQuizzes = {
|
|||||||
}[];
|
}[];
|
||||||
|
|
||||||
export const quiz: tQuizzes = [
|
export const quiz: tQuizzes = [
|
||||||
{
|
|
||||||
"id": 0,
|
|
||||||
"type": "C",
|
|
||||||
"title": "RAM price jump: pick true statements",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"question": "AI server demand pushed DRAM contracts up in 2024-2025",
|
|
||||||
"answer": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "Laptop DDR5 demand was the main global driver",
|
|
||||||
"answer": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "HBM supply limits affected overall memory pricing",
|
|
||||||
"answer": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "Memory prices stayed flat through 2025",
|
|
||||||
"answer": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"type": "M",
|
"type": "M",
|
||||||
"title": "Match RAM market terms",
|
"title": "вопросй",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"question": "HBM",
|
"question": "адын?",
|
||||||
"answer": "High Bandwidth Memory"
|
"answer": "адын"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "DRAM",
|
"question": "2",
|
||||||
"answer": "Dynamic Random Access Memory"
|
"answer": "2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "NAND",
|
"question": "3",
|
||||||
"answer": "Flash storage memory"
|
"answer": "3"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "Contract price",
|
"question": "4",
|
||||||
"answer": "Long-term negotiated memory price"
|
"answer": "4"
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"type": "S",
|
"type": "S",
|
||||||
"title": "Sort AI stack by deployment flow",
|
"title": "Вопрос 2 СОРТИРУЙ",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"question": "1",
|
"question": "1",
|
||||||
"answer": "Collect and clean data"
|
"answer": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "2",
|
"question": "22",
|
||||||
"answer": "Train model"
|
"answer": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "3",
|
"question": "333",
|
||||||
"answer": "Optimize for inference"
|
"answer": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "4",
|
"question": "4444",
|
||||||
"answer": "Deploy and monitor"
|
"answer": 4
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"question": "5555",
|
||||||
|
"answer": 5
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
|
,
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"type": "C",
|
"type": "C",
|
||||||
"title": "AI trends: choose true",
|
"title": "Вопрос 3 Выбирай!",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"question": "Edge AI adoption grew in 2024-2026",
|
"question": "да",
|
||||||
"answer": true
|
"answer": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "LLMs removed the need for GPUs",
|
"question": "нет",
|
||||||
"answer": false
|
"answer": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "Smaller task-specific models are still widely used",
|
"question": "и снова да",
|
||||||
"answer": true
|
"answer": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "AI inference always runs only in cloud",
|
"question": "нет",
|
||||||
"answer": false
|
"answer": false
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 4,
|
|
||||||
"type": "M",
|
|
||||||
"title": "Match low-energy embedded methods",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"question": "Sleep mode",
|
|
||||||
"answer": "Turns off CPU blocks between events"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"question": "DVFS",
|
"question": "дааа",
|
||||||
"answer": "Adjusts voltage and frequency to save power"
|
"answer": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"question": "Interrupt wakeup",
|
|
||||||
"answer": "Wakes MCU only on external/internal trigger"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "Duty cycling",
|
|
||||||
"answer": "Runs sensors and radio in short active bursts"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 5,
|
|
||||||
"type": "S",
|
|
||||||
"title": "Sort low-energy embedded design steps",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"question": "1",
|
|
||||||
"answer": "Measure baseline current"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "2",
|
|
||||||
"answer": "Set sleep and wake strategy"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "3",
|
|
||||||
"answer": "Tune radio and sensor duty cycle"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"question": "4",
|
|
||||||
"answer": "Validate battery-life target"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user