diff --git a/src/ClassicTestStart.js b/src/ClassicTestStart.js new file mode 100644 index 0000000..fcf52b3 --- /dev/null +++ b/src/ClassicTestStart.js @@ -0,0 +1,78 @@ +import React from "react"; +import { CloseRounded as CloseRoundedIcon, ArrowForwardRounded as ArrowForwardRoundedIcon } from "@material-ui/icons"; +import Button from "./Button"; +import Checkbox from '@material-ui/core/Checkbox'; + +import Slider from "rc-slider"; +import "rc-slider/assets/index.css"; + +export default function ClassicTestStart(props) { + return ( + <> +
+
+

Number of Questions

+ +
+ div") + ).getPropertyValue("--text-color") + .trim(), + border: 0, + }} + handleStyle={{ + backgroundColor: getComputedStyle( + document.querySelector("#root > div") + ).getPropertyValue("--primary-color") + .trim(), + border: 0, + }} + trackStyle={{ + backgroundColor: getComputedStyle( + document.querySelector("#root > div") + ).getPropertyValue("--primary-color-tinted") + .trim(), + }} + /> + !isNaN(Number(event.key))} + onChange={(event) => props.onSliderChange(Number(event.target.value))} + value={props.sliderValue} + min={1} + max={props.max} + size="1" + /> +
+ + + + + + +
+ + ) +} diff --git a/src/CountdownTestStart.js b/src/CountdownTestStart.js new file mode 100644 index 0000000..e057fd4 --- /dev/null +++ b/src/CountdownTestStart.js @@ -0,0 +1,16 @@ +import React from "react"; + +export default function CountdownTestStart(props) { + return ( + <> +
+
+ Awaiting content + +
+ Cancel +
+
+ + ) +} diff --git a/src/LivesTestStart.js b/src/LivesTestStart.js new file mode 100644 index 0000000..d5e5cec --- /dev/null +++ b/src/LivesTestStart.js @@ -0,0 +1,78 @@ +import React from "react"; +import { CloseRounded as CloseRoundedIcon, ArrowForwardRounded as ArrowForwardRoundedIcon } from "@material-ui/icons"; +import Button from "./Button"; +import Checkbox from '@material-ui/core/Checkbox'; + +import Slider from "rc-slider"; +import "rc-slider/assets/index.css"; + +export default function LivesTestStart(props) { + return ( + <> +
+
+

Number of Lives

+ +
+ div") + ).getPropertyValue("--text-color") + .trim(), + border: 0, + }} + handleStyle={{ + backgroundColor: getComputedStyle( + document.querySelector("#root > div") + ).getPropertyValue("--primary-color") + .trim(), + border: 0, + }} + trackStyle={{ + backgroundColor: getComputedStyle( + document.querySelector("#root > div") + ).getPropertyValue("--primary-color-tinted") + .trim(), + }} + /> + !isNaN(Number(event.key))} + onChange={(event) => props.onSliderChange(Number(event.target.value))} + value={props.sliderValue} + min={1} + max={props.max} + size="1" + /> +
+ + + + + + +
+ + ) +} diff --git a/src/LoggedInHome.js b/src/LoggedInHome.js index 942fe7c..ae73539 100644 --- a/src/LoggedInHome.js +++ b/src/LoggedInHome.js @@ -12,9 +12,16 @@ import "firebase/functions"; import Button from './Button'; import LinkButton from './LinkButton'; import Footer from "./Footer"; +import TestStart from './TestStart'; +import ClassicTestStart from './ClassicTestStart'; +import LivesTestStart from './LivesTestStart'; +import CountdownTestStart from './CountdownTestStart'; import "./css/Form.css"; import "./css/History.css"; import "./css/LoggedInHome.css"; +import "./css/PopUp.css"; +import "./css/OptionsListOverlay.css"; +import "./css/SliderOverlay.css"; import { withRouter } from "react-router-dom"; @@ -54,6 +61,12 @@ export default withRouter(class LoggedInHome extends React.Component { } ], progressHistoryIncomplete: [], + showTestStart: false, + showClassicTestStart: false, + showLivesTestStart: false, + sliderValue: 1, + switchLanguage: false, + totalTestQuestions: 1, }; let isMounted = true; @@ -177,15 +190,15 @@ export default withRouter(class LoggedInHome extends React.Component { }); } - startTest = () => { + startTest = (mode) => { if (this.state.canStartTest) { const selections = Object.keys(this.state.selections) .filter(x => this.state.selections[x]); this.state.functions.createProgress({ sets: selections, - switch_language: false, - mode: "questions", - limit: 1000, + switch_language: this.state.switchLanguage, + mode: mode, + limit: this.state.sliderValue, }).then((result) => { const progressId = result.data; this.stopLoading(); @@ -231,6 +244,94 @@ export default withRouter(class LoggedInHome extends React.Component { }); } + showTestStart = () => { + if (this.state.canStartTest) { + this.setState({ + showTestStart: true, + totalTestQuestions: 1, + }); + } + } + + hideTestStart = () => { + this.setState({ + showTestStart: false, + }); + } + + showIndividualTestPrompt = async (mode) => { + if (!this.state.loading) { + if (mode === "classic") { + this.setState({ + loading: true, + }) + const setIds = Object.keys(this.state.selections) + .filter(x => this.state.selections[x]); + + const totalTestQuestions = (await Promise.all(setIds.map((setId) => + this.state.db.collection("sets") + .doc(setId) + .collection("vocab") + .get() + .then(querySnapshot => querySnapshot.docs.length) + ))).reduce((a, b) => a + b); + + this.setState({ + showTestStart: false, + showClassicTestStart: true, + sliderValue: totalTestQuestions, + switchLanguage: false, + totalTestQuestions: totalTestQuestions, + loading: false, + }); + } else if (mode === "lives") { + this.setState({ + showTestStart: false, + showLivesTestStart: true, + switchLanguage: false, + sliderValue: 5, + }); + } else { + // countdown + // this.setState({ + // showTestStart: false, + // showCountdownTestStart: true, + // switchLanguage: false, + // }); + } + } + } + + hideClassicTestStart = () => { + this.setState({ + showClassicTestStart: false, + }); + } + + hideLivesTestStart = () => { + this.setState({ + showLivesTestStart: false, + }); + } + + hideCountdownTestStart = () => { + this.setState({ + showCountdownTestStart: false, + }); + } + + changeSliderValue = (value) => { + if (value >= 1 && value <= 999) this.setState({ + sliderValue: value, + }); + } + + handleSwitchLanguageChange = (event) => { + this.setState({ + switchLanguage: event.target.checked, + }); + } + render() { return (
@@ -241,8 +342,7 @@ export default withRouter(class LoggedInHome extends React.Component {

Study

} className="button--round buttons--mobile">
+
+ + + Groups + + { + this.state.userSets && this.state.userSets.length > 0 && + + My Sets + + } +
{ this.state.progressHistoryIncomplete.length > 0 && <>

Incomplete Tests

-
+

Set

Progress

Mark

Grade

Mode

+
{ this.state.progressHistoryIncomplete.map((progressItem) => @@ -313,28 +435,6 @@ export default withRouter(class LoggedInHome extends React.Component {
} -
- - - Groups - - { - this.state.userSets && this.state.userSets.length > 0 && - - My Sets - - } -

{ this.state.userSets && this.state.userSets.length > 0 @@ -440,6 +540,48 @@ export default withRouter(class LoggedInHome extends React.Component {