diff --git a/build/assets/games/billboard1.png b/build/assets/games/billboard1.png new file mode 100644 index 0000000..73d5be3 Binary files /dev/null and b/build/assets/games/billboard1.png differ diff --git a/build/assets/games/cloud.png b/build/assets/games/cloud.png new file mode 100644 index 0000000..85f6d3d Binary files /dev/null and b/build/assets/games/cloud.png differ diff --git a/build/assets/games/lawn.png b/build/assets/games/lawn.png new file mode 100644 index 0000000..26c54d9 Binary files /dev/null and b/build/assets/games/lawn.png differ diff --git a/build/assets/games/stands.png b/build/assets/games/stands.png new file mode 100644 index 0000000..f46730e Binary files /dev/null and b/build/assets/games/stands.png differ diff --git a/build/assets/menu/building.svg b/build/assets/menu/building.svg new file mode 100644 index 0000000..e9bc7d0 --- /dev/null +++ b/build/assets/menu/building.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/build/assets/menu/department.svg b/build/assets/menu/department.svg new file mode 100644 index 0000000..f2daca2 --- /dev/null +++ b/build/assets/menu/department.svg @@ -0,0 +1 @@ + diff --git a/build/assets/menu/release.svg b/build/assets/menu/release.svg new file mode 100644 index 0000000..8224fce --- /dev/null +++ b/build/assets/menu/release.svg @@ -0,0 +1 @@ + diff --git a/public/assets/games/billboard1.png b/public/assets/games/billboard1.png new file mode 100644 index 0000000..73d5be3 Binary files /dev/null and b/public/assets/games/billboard1.png differ diff --git a/public/assets/games/cloud.png b/public/assets/games/cloud.png new file mode 100644 index 0000000..85f6d3d Binary files /dev/null and b/public/assets/games/cloud.png differ diff --git a/public/assets/games/lawn.png b/public/assets/games/lawn.png new file mode 100644 index 0000000..26c54d9 Binary files /dev/null and b/public/assets/games/lawn.png differ diff --git a/public/assets/games/stands.png b/public/assets/games/stands.png new file mode 100644 index 0000000..f46730e Binary files /dev/null and b/public/assets/games/stands.png differ diff --git a/public/assets/menu/building.svg b/public/assets/menu/building.svg new file mode 100644 index 0000000..e9bc7d0 --- /dev/null +++ b/public/assets/menu/building.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/assets/menu/release.svg b/public/assets/menu/release.svg new file mode 100644 index 0000000..8224fce --- /dev/null +++ b/public/assets/menu/release.svg @@ -0,0 +1 @@ + diff --git a/src/ts/components/BillBoard/index.module.scss b/src/ts/components/BillBoard/index.module.scss new file mode 100644 index 0000000..91072a5 --- /dev/null +++ b/src/ts/components/BillBoard/index.module.scss @@ -0,0 +1,57 @@ +@import 'src/styles/variables'; + +.billboard { + display: block; + width: 100%; + padding: 0; + margin: 0 auto -44px; + text-align: center; + + background-repeat: repeat-x; + background-size: auto 100%; + background-position: bottom left; + + &_box { + position: relative; + + display: inline-block; + width: 400px; + height: 160px; + margin: 0 auto; + + background-repeat: no-repeat; + background-size: 100% auto; + background-position: top left; + } + + &_title { + font-family: monospace; + font-size: 22px; + font-weight: 100; + + display: flex; + justify-content: center; + align-items: center; + height: 92px; + padding: var(--space-m); + margin: 0 auto; + + line-height: 1.3; + text-align: center; + box-sizing: border-box; + text-shadow: 1px 1px 1px #FEFEFE; + color: #4E3C3B; + } + + &_cloud { + padding-top: 50px; + background-color: #F0AE7A; + background-size: auto 56%; + } + + &_green { + padding-top: 12px; + background-color: #557D4B; + } +} + diff --git a/src/ts/components/BillBoard/index.tsx b/src/ts/components/BillBoard/index.tsx new file mode 100644 index 0000000..fd9dc90 --- /dev/null +++ b/src/ts/components/BillBoard/index.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; + +import style from './index.module.scss'; + +interface BillBoardProps { + title: string; + type: string; +} + +function BillBoard({ + title, + type, +}: BillBoardProps): React.ReactElement | null { + const { t } = useTranslation(); + if (!title) return null; + + const className = type === 'cloud' + ? style.billboard_cloud + : style.billboard_green; + + const icon = type === 'cloud' + ? './assets/games/cloud.png' + : './assets/games/lawn.png'; + + return ( +
+
+
+ {t(title || '')} +
+
+
+ ); +} + +export default BillBoard; diff --git a/src/ts/components/Quiz/helpers/getQuestion.ts b/src/ts/components/Quiz/helpers/getQuestion.ts new file mode 100644 index 0000000..9eb0388 --- /dev/null +++ b/src/ts/components/Quiz/helpers/getQuestion.ts @@ -0,0 +1,14 @@ +export default function getQuestion( + question: string, + answers: string[], + rightAnswer: number, +) { + return { + title: question, + index: 0, + answers: answers.map((title: string, index: number) => ({ + title, + score: rightAnswer === index ? 1 : 0, + })), + }; +} diff --git a/src/ts/components/Quiz/helpers/getQuestions.ts b/src/ts/components/Quiz/helpers/getQuestions.ts new file mode 100644 index 0000000..60da1d1 --- /dev/null +++ b/src/ts/components/Quiz/helpers/getQuestions.ts @@ -0,0 +1,91 @@ +import dataGripStore from 'ts/store/DataGrip'; +import { getRandom, shuffle } from 'ts/helpers/random'; + +import IQuiz from '../interfaces/Quiz'; +import getQuestion from './getQuestion'; + +function getQuestionByList( + authors: any[], + question: string, + getValue: Function, + rightIndex?: number, +) { + const answers = authors + .sort((a, b) => getValue(b) - getValue(a)) + .slice(0, 3) + .map((data) => data.author); + const rightAnswer = answers[rightIndex || 0]; + const formattedAnswers = shuffle(answers); + return getQuestion(question, formattedAnswers, formattedAnswers.indexOf(rightAnswer)); +} + +function getQuestionByNumber(question: string, rightAnswer: number) { + let a, b; + if (rightAnswer < 3) { + a = rightAnswer + 1; + b = rightAnswer + 2; + } else { + a = rightAnswer + (getRandom(rightAnswer) * (Math.random() > 0.5 ? 1 : -1)); + b = rightAnswer + (getRandom(rightAnswer) * (Math.random() > 0.5 ? 1 : -1)); + if (a === b) return null; + } + const answers = shuffle([rightAnswer, a, b]); + return getQuestion(question, answers, answers.indexOf(rightAnswer)); +} + +function getHowTaskInDay(user: any) { + if (!user) return null; + const question = `Сколько максимум задач в день делал ${user.author}?`; + const byTimestamp = dataGripStore.dataGrip.timestamp.statisticByAuthor[user.author]; + const rightAnswer = byTimestamp.tasksByTimestampCounter.max; + return getQuestionByNumber(question, rightAnswer); +} + +export default function getQuizQuestions(): IQuiz { + const authorsWithStaff = [...dataGripStore.dataGrip.author.statistic]; + const authors = authorsWithStaff.filter((data) => !data.isStaff); + const dismissed = dataGripStore.dataGrip.author.employment.dismissed.length; + const staff = dataGripStore.dataGrip.author.employment.staff.length; + // const types = shuffle(dataGripStore.dataGrip.type.list.slice(2)).slice(0, 3); + const randomUsers = shuffle([...authors]).slice(0, 3); + + // сколько в среднем работают на проекте + // во сколько чаще всего комитят + // Кто устроился на работу в __Янаваре + // Кто первый стал коммитить ночью + // Задач какого типа больше + + const questions = [ + getQuestionByList(authorsWithStaff, 'Кто сделал первый коммит?', (s: any) => s.firstCommit.milliseconds), + getQuestionByList(authors, 'Кто закрыл больше задач?', (s: any) => s.tasks.length), + getQuestionByList(authors, 'Кто быстрее всех делает задачи?', (s: any) => s.taskInDay), + getQuestionByList(authors, 'Кто дольше всех работал на проекте?', (s: any) => s.daysAll), + getQuestionByList(authors, 'Кто меньше всех работал на проекте?', (s: any) => s.daysAll, 2), + getQuestionByList(authors, 'Кто чаще коммитит?', (s: any) => s.commits / s.daysWorked), + getQuestionByList(authors, 'Кто реже коммитит?', (s: any) => s.commits / s.daysWorked, 2), + getQuestionByList(authors, 'У кого саммые длинные подписи коммитов?', (s: any) => s.middleMessageLength), + getQuestionByList(authors, 'У кого саммые короткие подписи коммитов?', (s: any) => s.middleMessageLength, 2), + getQuestionByList(authors, 'У кого больше всего дней без коммитов?', (s: any) => s.daysLosses / s.daysWorked, 2), + getQuestionByNumber('Сколько человек уволилось?', dismissed), + getQuestionByNumber('Сколько человек помогало проекту?', staff), + getHowTaskInDay(randomUsers[0]), + getHowTaskInDay(randomUsers[1]), + getHowTaskInDay(randomUsers[2]), + ] + .filter((question) => question) + .map((question, i: number) => ({ ...question, index: i + 1 })); + + return { + title: '', + description: 'Насколько хорошо ты знаешь команду?', + questions: shuffle(questions), + results: [ + { + title: 'Поздравляем, пытка окончена', + description: 'Вы протестировали этот квиз и готовы написать на него отзыв длинной два или три предложения.', + min: 0, + max: 60, + }, + ], + }; +}