diff --git a/src/utils/constants.jsx b/src/utils/constants.jsx index e69de29b..6d280d18 100644 --- a/src/utils/constants.jsx +++ b/src/utils/constants.jsx @@ -0,0 +1,3544 @@ +import confetti from "canvas-confetti"; +import * as React from "react"; + +export const getLocalData = (item) => { + return localStorage.getItem(item); +}; + +export const setLocalData = (item, value) => { + return localStorage.setItem(item, value); +}; + +export function replaceAll(string, search, replace) { + return string.split(search).join(replace); +} + +export function compareArrays(arr1, arr2) { + let words_result = []; + + // Iterate over each element and compare + for (var k in arr1) { + if (arr2[k] === "" || arr2[k] === undefined) { + // Element not available on the same key + words_result.push("-1"); + } else if (arr1[k] === arr2[k]) { + // Elements match on the same key + words_result.push("1"); + } else { + // Element does not match on the same key + words_result.push("0"); + } + } + if (arr1.length < arr2.length) { + for (let i = arr1.length; i < arr2.length; i++) { + words_result.push("-1"); + } + } + return words_result; +} + +export const questionsList = [ + { + question: + "One day, a dog was passing by a river. He had a bone in his mouth.", + type: "sentence", + }, + { + question: "He looked into the water and saw his own reflection in it.", + type: "sentence", + }, + { + question: "He started barking bow-wow, and bone fell into the water.", + type: "sentence", + }, + { question: "River", type: "word" }, + { question: "Water", type: "word" }, + { question: "Barking", type: "word" }, + { + question: + "There are many different kinds of animals that live in China. Tigers and leopards are animals that live in China's forests in the north.", + type: "paragraph", + }, + { + question: + "Bali and Lombok are neighbouring islands both are part of the Indonesian archipelago. It is easy to appreciate each island as an attractive tourist destination.", + type: "paragraph", + }, + { + question: + "Martin Luther led many demonstrations against racism. He delivered his message in a non-violent manner. The jail sentence he received was four months.", + type: "paragraph", + }, +]; + +export const NextButton = (props) => { + return ( + + + + + + + + + + + + + + + + + ); +}; + +export const ListenButton = (props) => { + return ( + + + + + + + + + + + + + + + + + + ); +}; + +export const SpeakButton = (props) => ( + + + + + + + + + + + + + + + + +); + +export const StopButton = (props) => ( + + + + + + + + + + + + + + + + +); + +export const AudioPlayerSvg = (props) => { + return ( + + + + ); +}; + +export const PlayAudioButton = (props) => ( + + + + +); + +export const StopAudioButton = (props) => ( + + + +); + +export const AudioBarSvg = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const AudioBarColoredSvg = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const SubmitButton = (props) => ( + + + + + + + + + + +); + +export const LevelOne = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelTwo = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelThree = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelFour = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelFive = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelSix = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelSeven = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelEight = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LevelNine = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const LetsStart = (props) => ( + + + + + + + + + + +); +export const StartAssessmentButton = (props) => ( + + + + + +); + +export const GoodMood = (props) => ( + + + +); + +export const AverageMood = (props) => ( + + + +); + +export const BadMood = (props) => ( + + + +); + +export const GreenTick = (props) => ( + + + + + + + + + +); + +export const LevelRight = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const SelectLanguageButton = (props) => ( + + + + + + + +); + +export const RoundTick = (props) => ( + + + + + + + + + + +); + +export const RetryIcon = (props) => ( + + + + + + + + + + + + + + + + +); + +export const AssesmentCompletePlane = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const HeartRed = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const HeartBlack = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export const SessionID = "13900744731701973109305"; +export const UserID = "1390074473"; + +export const practiceSteps = [ + { name: "P1", fullName: "Practice 1" }, + { name: "P2", fullName: "Practice 2" }, + { name: "P3", fullName: "Practice 3" }, + { name: "P4", fullName: "Practice 4" }, + { name: "S1", fullName: "Showcase 1" }, + { name: "P5", fullName: "Practice 5" }, + { name: "P6", fullName: "Practice 6" }, + { name: "P7", fullName: "Practice 7" }, + { name: "P8", fullName: "Practice 8" }, + { name: "S2", fullName: "Showcase 2" }, +]; + +export const levelGetContent = { + 0: [ + { title: "P1", criteria: "word", template: "simple" }, + { title: "P2", criteria: "word", template: "simple" }, + { title: "P3", criteria: "word", template: "simple" }, + { title: "P4", criteria: "word", template: "simple" }, + { title: "S1", criteria: "word", template: "simple" }, + { title: "P5", criteria: "word", template: "simple" }, + { title: "P6", criteria: "word", template: "simple" }, + { title: "P7", criteria: "word", template: "simple" }, + { title: "P8", criteria: "word", template: "simple" }, + { title: "S2", criteria: "word", template: "simple" }, + ], + 1: [ + { title: "P1", criteria: "word", template: "simple" }, + { title: "P2", criteria: "word", template: "simple" }, + { title: "P3", criteria: "word", template: "simple" }, + { title: "P4", criteria: "word", template: "simple" }, + { title: "S1", criteria: "word", template: "simple" }, + { title: "P5", criteria: "word", template: "simple" }, + { title: "P6", criteria: "word", template: "simple" }, + { title: "P7", criteria: "word", template: "simple" }, + { title: "P8", criteria: "word", template: "simple" }, + { title: "S2", criteria: "word", template: "simple" }, + ], + 2: [ + { title: "P1", criteria: "char", template: "simple" }, + { title: "P2", criteria: "char", template: "simple" }, + { title: "P3", criteria: "word", template: "simple", mechanism: "audio" }, + { title: "P4", criteria: "word", template: "simple", mechanism: "audio" }, + { title: "S1", criteria: "word", template: "simple" }, + { title: "P5", criteria: "word", template: "simple" }, + { title: "P6", criteria: "word", template: "simple" }, + { title: "P7", criteria: "word", template: "simple", mechanism: "audio" }, + { title: "P8", criteria: "word", template: "simple", mechanism: "audio" }, + { title: "S2", criteria: "word", template: "simple" }, + ], + 3: [ + { + title: "P1", + criteria: "word", + template: "simple", + }, + { + title: "P2", + criteria: "word", + template: "simple", + }, + { title: "P3", criteria: "sentence", template: "simple" }, + { title: "P4", criteria: "sentence", template: "simple" }, + { title: "S1", criteria: "sentence", template: "simple" }, + { + title: "P5", + criteria: "sentence", + template: "simple", + mechanism: "fillInTheBlank", + }, + { + title: "P6", + criteria: "sentence", + template: "simple", + mechanism: "fillInTheBlank", + }, + { title: "P7", criteria: "sentence", template: "simple" }, + { title: "P8", criteria: "sentence", template: "simple" }, + { title: "S2", criteria: "sentence", template: "simple" }, + ], + 4: [ + { title: "P1", criteria: "word", template: "simple" }, + { title: "P2", criteria: "word", template: "simple" }, + { title: "P3", criteria: "sentence", template: "simple" }, + { title: "P4", criteria: "sentence", template: "simple" }, + { title: "S1", criteria: "sentence", template: "simple" }, + { title: "P5", criteria: "sentence", template: "simple" }, + { title: "P6", criteria: "sentence", template: "simple" }, + { title: "P7", criteria: "sentence", template: "simple" }, + { title: "P8", criteria: "sentence", template: "simple" }, + { title: "S2", criteria: "sentence", template: "simple" }, + ], + 5: [ + { title: "P1", criteria: "sentence", template: "simple" }, + { title: "P2", criteria: "sentence", template: "simple" }, + { title: "P3", criteria: "sentence", template: "simple" }, + { title: "P4", criteria: "sentence", template: "simple" }, + { title: "S1", criteria: "sentence", template: "simple" }, + { title: "P5", criteria: "sentence", template: "simple" }, + { title: "P6", criteria: "sentence", template: "simple" }, + { title: "P7", criteria: "sentence", template: "simple" }, + { title: "P8", criteria: "sentence", template: "simple" }, + { title: "S2", criteria: "sentence", template: "simple" }, + ], + 6: [ + { title: "P1", criteria: "sentence", template: "simple" }, + { title: "P2", criteria: "sentence", template: "simple" }, + { title: "P3", criteria: "paragraph", template: "simple" }, + { title: "P4", criteria: "paragraph", template: "simple" }, + { title: "S1", criteria: "paragraph", template: "simple" }, + { title: "P5", criteria: "sentence", template: "simple" }, + { title: "P6", criteria: "paragraph", template: "simple" }, + { title: "P7", criteria: "paragraph", template: "simple" }, + { title: "P8", criteria: "paragraph", template: "simple" }, + { title: "S2", criteria: "paragraph", template: "simple" }, + ], + 7: [ + { title: "P1", criteria: "sentence", template: "simple" }, + { title: "P2", criteria: "sentence", template: "simple" }, + { title: "P3", criteria: "paragraph", template: "simple" }, + { title: "P4", criteria: "paragraph", template: "simple" }, + { title: "S1", criteria: "paragraph", template: "simple" }, + { title: "P5", criteria: "paragraph", template: "simple" }, + { title: "P6", criteria: "paragraph", template: "simple" }, + { title: "P7", criteria: "paragraph", template: "simple" }, + { title: "P8", criteria: "paragraph", template: "simple" }, + { title: "S2", criteria: "paragraph", template: "simple" }, + ], + 8: [ + { title: "P1", criteria: "sentence", template: "simple" }, + { title: "P2", criteria: "sentence", template: "simple" }, + { title: "P3", criteria: "paragraph", template: "simple" }, + { title: "P4", criteria: "paragraph", template: "simple" }, + { title: "S1", criteria: "paragraph", template: "simple" }, + { title: "P5", criteria: "paragraph", template: "simple" }, + { title: "P6", criteria: "paragraph", template: "simple" }, + { title: "P7", criteria: "paragraph", template: "simple" }, + { title: "P8", criteria: "paragraph", template: "simple" }, + { title: "S2", criteria: "paragraph", template: "simple" }, + ], + 9: [ + { title: "P1", criteria: "sentence", template: "simple" }, + { title: "P2", criteria: "sentence", template: "simple" }, + { title: "P3", criteria: "paragraph", template: "simple" }, + { title: "P4", criteria: "paragraph", template: "simple" }, + { title: "S1", criteria: "paragraph", template: "simple" }, + { title: "P5", criteria: "paragraph", template: "simple" }, + { title: "P6", criteria: "paragraph", template: "simple" }, + { title: "P7", criteria: "paragraph", template: "simple" }, + { title: "P8", criteria: "paragraph", template: "simple" }, + { title: "S2", criteria: "paragraph", template: "simple" }, + ], +}; + +export function callConfettiSnow() { + var duration = 3 * 1000; + var animationEnd = Date.now() + duration; + // var defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 }; + + // function randomInRange(min, max) { + // return Math.random() * (max - min) + min; + // } + + var interval = setInterval(function () { + var timeLeft = animationEnd - Date.now(); + + if (timeLeft <= 0) { + return clearInterval(interval); + } + + // since particles fall down, start a bit higher than random + timeLeft = animationEnd - Date.now(); + var ticks = Math.max(200, 500 * (timeLeft / duration)); + var skew; + skew = Math.max(0.8, skew - 0.001); + + confetti({ + particleCount: 1, + startVelocity: 0, + ticks: ticks, + origin: { + x: Math.random(), + // since particles fall down, skew start toward the top + y: Math.random() * skew - 0.2, + }, + colors: ["#3298D6"], + shapes: ["circle"], + }); + }, 250); +} + +export const callConfetti = () => { + var duration = 3 * 1000; + var animationEnd = Date.now() + duration; + var defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 }; + + function randomInRange(min, max) { + return Math.random() * (max - min) + min; + } + + var interval = setInterval(function () { + var timeLeft = animationEnd - Date.now(); + + if (timeLeft <= 0) { + return clearInterval(interval); + } + + var particleCount = 50 * (timeLeft / duration); + // since particles fall down, start a bit higher than random + confetti({ + ...defaults, + particleCount, + origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 }, + }); + confetti({ + ...defaults, + particleCount, + origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 }, + }); + }, 250); +}; + +export const levelConfig = { + 1: { color: "#3872C1" }, + 2: { color: "#FF1276" }, + 3: { color: "#FFB31F" }, + 4: { color: "#BC00FF" }, + 5: { color: "#37C473" }, + 6: { color: "#F810E1" }, + 7: { color: "#634AFF" }, + 8: { color: "#B4CF12" }, + 9: { color: "#00C7E2" }, +}; + +const AllLanguages = [ + { name: "தமிழ்", lang: "ta", symbol: "இ" }, + { name: "English", lang: "en", symbol: "A" }, + { name: "हिंदी", lang: "hi", symbol: "क" }, + { name: "ಕನ್ನಡ", lang: "kn", symbol: "ಕ" }, + { name: "తెలుగు", lang: "te", symbol: "ఈ" }, +]; + +const appLanguages = import.meta.env.VITE_APP_LANGUAGES + ? JSON.parse(import.meta.env.VITE_APP_LANGUAGES) + : []; + +export const languages = AllLanguages.filter((lang) => + appLanguages.includes(lang.lang) +); + +export const randomizeArray = (arr) => { + let wordsArr = [...arr]; + for (let i = wordsArr.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * i); + let k = wordsArr[i]; + wordsArr[i] = wordsArr[j]; + wordsArr[j] = k; + } + return wordsArr; +};