Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5040f094e0 | |||
| 2730db089b | |||
| d9541567c2 | |||
| 866589f907 | |||
| 4109515568 | |||
| b567a0ddb0 | |||
| 6cee093529 | |||
| ae8d7efa53 | |||
| 0f1f23ae57 | |||
| a869f79423 | |||
| 1a282035dc | |||
| 48bb19c532 | |||
| 58aef9e2b3 | |||
| b8e76735a3 | |||
| 65e20625a1 | |||
| 1f0079868f | |||
| e60b1ab5ef | |||
| 221b61cce1 | |||
| eed97b0298 | |||
| 0127f55401 | |||
| 23c6e3630a | |||
| 9212a0e2b6 |
@@ -1,6 +1,16 @@
|
|||||||
{
|
{
|
||||||
"functions": {
|
"functions": {
|
||||||
"source": "functions"
|
"source": "functions",
|
||||||
|
"ignore": [
|
||||||
|
"node_modules",
|
||||||
|
".git",
|
||||||
|
"firebase-debug.log",
|
||||||
|
"firebase-debug.*.log",
|
||||||
|
"**/_private_stuff/**"
|
||||||
|
],
|
||||||
|
"predeploy": [
|
||||||
|
"npm --prefix \"$RESOURCE_DIR\" run lint"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"firestore": {
|
"firestore": {
|
||||||
"rules": "firestore.rules",
|
"rules": "firestore.rules",
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
/* eslint-disable no-tabs */
|
/* eslint-disable no-tabs */
|
||||||
const levenshtein = require('js-levenshtein');
|
const levenshtein = require('js-levenshtein');
|
||||||
const functions = require("firebase-functions");//.region("europe-west2")
|
const functions = require("firebase-functions").region("europe-west2");//.region("europe-west2")
|
||||||
const admin = require("firebase-admin");
|
const admin = require("firebase-admin");
|
||||||
admin.initializeApp();
|
admin.initializeApp();
|
||||||
const db = admin.firestore();
|
const db = admin.firestore();
|
||||||
|
|
||||||
const LOCAL_TESTING = false;
|
const LOCAL_TESTING = false;
|
||||||
|
const TESTING_USER_ID = "IjQBy5MmTPyOaZY0heexwb5bdKzG" //"M3JPrFRH6Fdo8XMUbF0l2zVZUCH3"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Randomises the items in an array.
|
* Randomises the items in an array.
|
||||||
@@ -66,7 +67,7 @@ exports.userDeleted = functions.auth.user().onDelete((user) => {
|
|||||||
* NOTE: can't be unit tested
|
* NOTE: can't be unit tested
|
||||||
*/
|
*/
|
||||||
exports.getGroupMembers = functions.https.onCall((data, context) => {
|
exports.getGroupMembers = functions.https.onCall((data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
|
|
||||||
if (context.app == undefined && !LOCAL_TESTING) {
|
if (context.app == undefined && !LOCAL_TESTING) {
|
||||||
throw new functions.https.HttpsError(
|
throw new functions.https.HttpsError(
|
||||||
@@ -140,6 +141,7 @@ exports.getGroupMembers = functions.https.onCall((data, context) => {
|
|||||||
/**
|
/**
|
||||||
* Creates new progress document.
|
* Creates new progress document.
|
||||||
* @param {object} data The data passed to the function.
|
* @param {object} data The data passed to the function.
|
||||||
|
* @param {boolean} data.ignoreAccents Whether accents on letters should matter during the test. Optional.
|
||||||
* @param {boolean} data.ignoreCaps Whether capitalisation of answers should matter during the test. Optional.
|
* @param {boolean} data.ignoreCaps Whether capitalisation of answers should matter during the test. Optional.
|
||||||
* @param {boolean} data.limit The maximum number of lives/questions for the test.
|
* @param {boolean} data.limit The maximum number of lives/questions for the test.
|
||||||
* @param {boolean} data.mode The mode to be tested in. Valid options are "questions" and "lives".
|
* @param {boolean} data.mode The mode to be tested in. Valid options are "questions" and "lives".
|
||||||
@@ -150,7 +152,7 @@ exports.getGroupMembers = functions.https.onCall((data, context) => {
|
|||||||
* @return {string} The ID of the created progress document.
|
* @return {string} The ID of the created progress document.
|
||||||
*/
|
*/
|
||||||
exports.createProgress = functions.https.onCall((data, context) => {
|
exports.createProgress = functions.https.onCall((data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
if (context.app == undefined && !LOCAL_TESTING) {
|
if (context.app == undefined && !LOCAL_TESTING) {
|
||||||
throw new functions.https.HttpsError(
|
throw new functions.https.HttpsError(
|
||||||
"failed-precondition",
|
"failed-precondition",
|
||||||
@@ -173,7 +175,14 @@ exports.createProgress = functions.https.onCall((data, context) => {
|
|||||||
data.ignoreCaps = false;
|
data.ignoreCaps = false;
|
||||||
console.log("ignoreCaps not provided - using default value of false");
|
console.log("ignoreCaps not provided - using default value of false");
|
||||||
} else if (typeof data.ignoreCaps !== "boolean") {
|
} else if (typeof data.ignoreCaps !== "boolean") {
|
||||||
throw new functions.https.HttpsError("invalid-argument", "showNumberOfAnswers must be a boolean");
|
throw new functions.https.HttpsError("invalid-argument", "ignoreCaps must be a boolean");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof data.ignoreAccents === "undefined") {
|
||||||
|
data.ignoreAccents = false;
|
||||||
|
console.log("ignoreAccents not provided - using default value of false");
|
||||||
|
} else if (typeof data.ignoreAccents !== "boolean") {
|
||||||
|
throw new functions.https.HttpsError("invalid-argument", "ignoreAccents must be a boolean");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data.showNumberOfAnswers === "undefined") {
|
if (typeof data.showNumberOfAnswers === "undefined") {
|
||||||
@@ -255,6 +264,7 @@ exports.createProgress = functions.https.onCall((data, context) => {
|
|||||||
set_titles: setIds.map((setId) => setTitlesDict[setId]),
|
set_titles: setIds.map((setId) => setTitlesDict[setId]),
|
||||||
typo: false,
|
typo: false,
|
||||||
ignoreCaps: data.ignoreCaps,
|
ignoreCaps: data.ignoreCaps,
|
||||||
|
ignoreAccents: data.ignoreAccents,
|
||||||
showNumberOfAnswers: data.showNumberOfAnswers,
|
showNumberOfAnswers: data.showNumberOfAnswers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +338,7 @@ exports.createProgress = functions.https.onCall((data, context) => {
|
|||||||
* @return {string} The ID of the created progress document.
|
* @return {string} The ID of the created progress document.
|
||||||
*/
|
*/
|
||||||
exports.createProgressWithIncorrect = functions.https.onCall((data, context) => {
|
exports.createProgressWithIncorrect = functions.https.onCall((data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
|
|
||||||
if (context.app == undefined && !LOCAL_TESTING) {
|
if (context.app == undefined && !LOCAL_TESTING) {
|
||||||
throw new functions.https.HttpsError(
|
throw new functions.https.HttpsError(
|
||||||
@@ -419,9 +429,10 @@ exports.createProgressWithIncorrect = functions.https.onCall((data, context) =>
|
|||||||
* @param {string} item The term/definition to remove the characters that should be ignored from.
|
* @param {string} item The term/definition to remove the characters that should be ignored from.
|
||||||
* @return {string} The original string with the unwanted characters removed.
|
* @return {string} The original string with the unwanted characters removed.
|
||||||
*/
|
*/
|
||||||
function cleanseVocabString(item, ignoreCaps=false) {
|
function cleanseVocabString(item, ignoreCaps=false, ignoreAccents=false) {
|
||||||
const chars = /[\p{P}\p{S} ]+/ug;
|
const chars = /[\p{P}\p{S}\n ]+/ug;
|
||||||
const cleansed = item.replace(chars, "");
|
let cleansed = item.replace(chars, "");
|
||||||
|
if (ignoreAccents) cleansed = cleansed.normalize('NFD').replace(/\p{Diacritic}/gu, "");
|
||||||
if (ignoreCaps) {
|
if (ignoreCaps) {
|
||||||
return cleansed.toLowerCase();
|
return cleansed.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
@@ -457,7 +468,7 @@ function cleanseVocabString(item, ignoreCaps=false) {
|
|||||||
* @return {boolean} typo Whether the inputted answer is likely to include a typo (using Levenshtein distance or by detecting a null answer).
|
* @return {boolean} typo Whether the inputted answer is likely to include a typo (using Levenshtein distance or by detecting a null answer).
|
||||||
*/
|
*/
|
||||||
exports.processAnswer = functions.https.onCall((data, context) => {
|
exports.processAnswer = functions.https.onCall((data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
|
|
||||||
if (context.app == undefined && !LOCAL_TESTING) {
|
if (context.app == undefined && !LOCAL_TESTING) {
|
||||||
throw new functions.https.HttpsError(
|
throw new functions.https.HttpsError(
|
||||||
@@ -493,6 +504,8 @@ exports.processAnswer = functions.https.onCall((data, context) => {
|
|||||||
|
|
||||||
return transaction.get(progressDoc.data().switch_language ? termDocId : definitionDocId).then((answerDoc) => {
|
return transaction.get(progressDoc.data().switch_language ? termDocId : definitionDocId).then((answerDoc) => {
|
||||||
const docData = progressDoc.data();
|
const docData = progressDoc.data();
|
||||||
|
docData.ignoreCaps = docData.ignoreCaps === true;
|
||||||
|
docData.ignoreAccents = docData.ignoreAccents === true;
|
||||||
const mode = docData.mode;
|
const mode = docData.mode;
|
||||||
const correctAnswers = answerDoc.data().item;
|
const correctAnswers = answerDoc.data().item;
|
||||||
const splitCorrectAnswers = correctAnswers.split("/");
|
const splitCorrectAnswers = correctAnswers.split("/");
|
||||||
@@ -506,15 +519,16 @@ exports.processAnswer = functions.https.onCall((data, context) => {
|
|||||||
cleansedDoneSplitCorrectAnswers.push(
|
cleansedDoneSplitCorrectAnswers.push(
|
||||||
cleanseVocabString(
|
cleanseVocabString(
|
||||||
notDoneSplitCorrectAnswers.splice(index, 1)[0],
|
notDoneSplitCorrectAnswers.splice(index, 1)[0],
|
||||||
docData.ignoreCaps
|
docData.ignoreCaps,
|
||||||
|
docData.ignoreAccents
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const cleansedNotDoneSplitCorrectAnswers = notDoneSplitCorrectAnswers.map((answer) => cleanseVocabString(answer, docData.ignoreCaps));
|
const cleansedNotDoneSplitCorrectAnswers = notDoneSplitCorrectAnswers.map((answer) => cleanseVocabString(answer, docData.ignoreCaps, docData.ignoreAccents));
|
||||||
|
|
||||||
const cleansedSplitCorrectAnswers = cleansedNotDoneSplitCorrectAnswers.concat(cleansedDoneSplitCorrectAnswers);
|
const cleansedSplitCorrectAnswers = cleansedNotDoneSplitCorrectAnswers.concat(cleansedDoneSplitCorrectAnswers);
|
||||||
const cleansedInputAnswer = cleanseVocabString(inputAnswer, docData.ignoreCaps);
|
const cleansedInputAnswer = cleanseVocabString(inputAnswer, docData.ignoreCaps, docData.ignoreAccents);
|
||||||
|
|
||||||
let isCorrectAnswer = false;
|
let isCorrectAnswer = false;
|
||||||
let correctAnswerIndex;
|
let correctAnswerIndex;
|
||||||
@@ -755,7 +769,7 @@ exports.processAnswer = functions.https.onCall((data, context) => {
|
|||||||
* @return {promise} The promise from setting the target user's admin custom auth claim.
|
* @return {promise} The promise from setting the target user's admin custom auth claim.
|
||||||
*/
|
*/
|
||||||
exports.setAdmin = functions.https.onCall(async (data, context) => {
|
exports.setAdmin = functions.https.onCall(async (data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
const isAdmin = LOCAL_TESTING ? true : context.auth.token.admin;
|
const isAdmin = LOCAL_TESTING ? true : context.auth.token.admin;
|
||||||
|
|
||||||
if (context.app == undefined && !LOCAL_TESTING) {
|
if (context.app == undefined && !LOCAL_TESTING) {
|
||||||
@@ -788,7 +802,7 @@ exports.setAdmin = functions.https.onCall(async (data, context) => {
|
|||||||
* @return {boolean} true, to show the function has succeeded.
|
* @return {boolean} true, to show the function has succeeded.
|
||||||
*/
|
*/
|
||||||
exports.addSetToGroup = functions.https.onCall((data, context) => {
|
exports.addSetToGroup = functions.https.onCall((data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
const isAdmin = LOCAL_TESTING ? false : context.auth.token.admin;
|
const isAdmin = LOCAL_TESTING ? false : context.auth.token.admin;
|
||||||
const auth = LOCAL_TESTING ? { uid: uid } : context.auth;
|
const auth = LOCAL_TESTING ? { uid: uid } : context.auth;
|
||||||
|
|
||||||
@@ -857,7 +871,7 @@ exports.addSetToGroup = functions.https.onCall((data, context) => {
|
|||||||
* @return {promise} The promise from setting the group's updated data.
|
* @return {promise} The promise from setting the group's updated data.
|
||||||
*/
|
*/
|
||||||
exports.removeSetFromGroup = functions.https.onCall((data, context) => {
|
exports.removeSetFromGroup = functions.https.onCall((data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
const isAdmin = LOCAL_TESTING ? false : context.auth.token.admin;
|
const isAdmin = LOCAL_TESTING ? false : context.auth.token.admin;
|
||||||
const auth = LOCAL_TESTING ? { uid: uid } : context.auth;
|
const auth = LOCAL_TESTING ? { uid: uid } : context.auth;
|
||||||
|
|
||||||
@@ -996,7 +1010,7 @@ async function generateJoinCode() {
|
|||||||
* @return {string} The ID of the new group's document in the groups collection.
|
* @return {string} The ID of the new group's document in the groups collection.
|
||||||
*/
|
*/
|
||||||
exports.createGroup = functions.https.onCall(async (data, context) => {
|
exports.createGroup = functions.https.onCall(async (data, context) => {
|
||||||
const uid = LOCAL_TESTING ? "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3" : context.auth.uid;
|
const uid = LOCAL_TESTING ? TESTING_USER_ID : context.auth.uid;
|
||||||
|
|
||||||
if (context.app == undefined && !LOCAL_TESTING) {
|
if (context.app == undefined && !LOCAL_TESTING) {
|
||||||
throw new functions.https.HttpsError(
|
throw new functions.https.HttpsError(
|
||||||
|
|||||||
3710
functions/package-lock.json
generated
3710
functions/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51213
package-lock.json
generated
51213
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "parandum",
|
"name": "parandum",
|
||||||
"version": "2.2.0",
|
"version": "2.3.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.16.0",
|
"@babel/core": "^7.16.0",
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"firebase": "^8.10.0",
|
"firebase": "^8.10.0",
|
||||||
"firebase-admin": "^9.12.0",
|
"firebase-admin": "^9.12.0",
|
||||||
"firebase-functions": "^3.16.0",
|
"firebase-functions": "^3.16.0",
|
||||||
"firebase-tools": "^9.23.0",
|
"firebase-tools": "^11.16.1",
|
||||||
"firebaseui": "^5.0.0",
|
"firebaseui": "^5.0.0",
|
||||||
"normalize-url": "^6.1.0",
|
"normalize-url": "^6.1.0",
|
||||||
"rc-slider": "^9.7.4",
|
"rc-slider": "^9.7.4",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-firebaseui": "^5.0.2",
|
"react-firebaseui": "^5.0.2",
|
||||||
"react-router-dom": "^5.3.0",
|
"react-router-dom": "^5.3.0",
|
||||||
"react-scripts": "^5.0.0-next.47",
|
"react-scripts": "^5.0.1",
|
||||||
"react-select": "^5.2.1",
|
"react-select": "^5.2.1",
|
||||||
"react-simple-keyboard": "^3.4.65",
|
"react-simple-keyboard": "^3.4.65",
|
||||||
"react-xarrows": "^2.0.2",
|
"react-xarrows": "^2.0.2",
|
||||||
@@ -75,8 +75,10 @@
|
|||||||
"@firebase/rules-unit-testing": "^1.3.12",
|
"@firebase/rules-unit-testing": "^1.3.12",
|
||||||
"@testing-library/react": "^11.2.7",
|
"@testing-library/react": "^11.2.7",
|
||||||
"@testing-library/user-event": "^12.8.3",
|
"@testing-library/user-event": "^12.8.3",
|
||||||
|
"create-react-app": "^5.0.1",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-google": "^0.14.0",
|
"eslint-config-google": "^0.14.0",
|
||||||
|
"eslint-config-react-app": "^6.0.0",
|
||||||
"eslint-plugin-promise": "^5.1.1",
|
"eslint-plugin-promise": "^5.1.1",
|
||||||
"firebase-functions-test": "^0.3.3",
|
"firebase-functions-test": "^0.3.3",
|
||||||
"hamjest": "^3.7.3",
|
"hamjest": "^3.7.3",
|
||||||
|
|||||||
20
src/AcceptDialog.js
Normal file
20
src/AcceptDialog.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Button from './Button';
|
||||||
|
|
||||||
|
export default function ConfirmationDialog(props) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="overlay" onClick={props.acceptFunction}></div>
|
||||||
|
<div className="overlay-content confirmation-dialog accept-dialog">
|
||||||
|
<h3>{props.message}</h3>
|
||||||
|
<div className="button-container button-container--center">
|
||||||
|
<Button
|
||||||
|
onClick={props.acceptFunction}
|
||||||
|
>
|
||||||
|
Ok
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
60
src/App.js
60
src/App.js
@@ -12,6 +12,7 @@ import Settings from "./Settings";
|
|||||||
import Progress from "./Progress";
|
import Progress from "./Progress";
|
||||||
import UserSets from "./UserSets";
|
import UserSets from "./UserSets";
|
||||||
import EditSet from "./EditSet";
|
import EditSet from "./EditSet";
|
||||||
|
import BulkCreateSets from "./BulkCreateSets";
|
||||||
import Error404 from "./Error404";
|
import Error404 from "./Error404";
|
||||||
import History from "./History";
|
import History from "./History";
|
||||||
import MistakesHistory from "./MistakesHistory";
|
import MistakesHistory from "./MistakesHistory";
|
||||||
@@ -34,6 +35,7 @@ import "firebase/functions";
|
|||||||
import "firebase/app-check";
|
import "firebase/app-check";
|
||||||
import "firebase/firestore";
|
import "firebase/firestore";
|
||||||
import "firebase/analytics";
|
import "firebase/analytics";
|
||||||
|
import PlatformDisabled from './PlatformDisabled';
|
||||||
|
|
||||||
// TODO: app check debug token set in index.html - remove before deploy
|
// TODO: app check debug token set in index.html - remove before deploy
|
||||||
|
|
||||||
@@ -53,10 +55,10 @@ appCheck.activate(
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
firebase.functions().useEmulator("localhost", 5001);
|
// firebase.functions().useEmulator("localhost", 5001);
|
||||||
firebase.auth().useEmulator("http://localhost:9099");
|
// firebase.auth().useEmulator("http://localhost:9099");
|
||||||
firebase.firestore().useEmulator("localhost", 8080);
|
// firebase.firestore().useEmulator("localhost", 8080);
|
||||||
const functions = firebase.functions();//firebase.app().functions("europe-west2");
|
const functions = firebase.app().functions("europe-west2");//firebase.functions();
|
||||||
|
|
||||||
const fadeIn = keyframes`
|
const fadeIn = keyframes`
|
||||||
from {
|
from {
|
||||||
@@ -191,29 +193,6 @@ class App extends React.Component {
|
|||||||
iterations: 1,
|
iterations: 1,
|
||||||
fill: "forwards",
|
fill: "forwards",
|
||||||
});
|
});
|
||||||
this.root.animate({
|
|
||||||
marginBottom: ["0px", `${this.cookieNoticeHeight}px`],
|
|
||||||
}, {
|
|
||||||
duration: 1000,
|
|
||||||
easing: "ease-in-out",
|
|
||||||
iterations: 1,
|
|
||||||
fill: "forwards",
|
|
||||||
});
|
|
||||||
window.addEventListener('resize', this.updateCookieNoticeMargins);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCookieNoticeMargins = () => {
|
|
||||||
if (this.cookieNoticeHeight !== this.cookieNotice.offsetHeight) {
|
|
||||||
this.cookieNoticeHeight = this.cookieNotice.offsetHeight;
|
|
||||||
this.root.animate({
|
|
||||||
marginBottom: [`${this.root.marginBottom}px`, `${this.cookieNoticeHeight}px`],
|
|
||||||
}, {
|
|
||||||
duration: 500,
|
|
||||||
easing: "ease-in-out",
|
|
||||||
iterations: 1,
|
|
||||||
fill: "forwards",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,14 +240,6 @@ class App extends React.Component {
|
|||||||
iterations: 1,
|
iterations: 1,
|
||||||
fill: "forwards",
|
fill: "forwards",
|
||||||
});
|
});
|
||||||
this.root.animate({
|
|
||||||
marginBottom: [`${this.cookieNoticeHeight}px`, "0px"],
|
|
||||||
}, {
|
|
||||||
duration: 1000,
|
|
||||||
easing: "ease-in-out",
|
|
||||||
iterations: 1,
|
|
||||||
fill: "forwards",
|
|
||||||
});
|
|
||||||
setTimeout(() => this.cookieNotice.style.display = "none", 1000);
|
setTimeout(() => this.cookieNotice.style.display = "none", 1000);
|
||||||
this.cookies.set("parandum-cookies-accepted", "true", {
|
this.cookies.set("parandum-cookies-accepted", "true", {
|
||||||
maxAge: 31556952,
|
maxAge: 31556952,
|
||||||
@@ -288,6 +259,18 @@ class App extends React.Component {
|
|||||||
?
|
?
|
||||||
<>
|
<>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
<Route path="/tos" exact>
|
||||||
|
<TermsOfService logEvent={analytics.logEvent} page={this.page} />
|
||||||
|
</Route>
|
||||||
|
<Route path="/privacy" exact>
|
||||||
|
<PrivacyPolicy logEvent={analytics.logEvent} page={this.page} />
|
||||||
|
</Route>
|
||||||
|
{
|
||||||
|
this.state.user.email.endsWith("@reading-school.co.uk") &&
|
||||||
|
<Route path="/">
|
||||||
|
<PlatformDisabled logEvent={analytics.logEvent} page={this.page} />
|
||||||
|
</Route>
|
||||||
|
}
|
||||||
<Route path="/" exact>
|
<Route path="/" exact>
|
||||||
<LoggedInHome db={db} firebase={firebase} functions={functions} user={this.state.user} logEvent={analytics.logEvent} page={this.page} />
|
<LoggedInHome db={db} firebase={firebase} functions={functions} user={this.state.user} logEvent={analytics.logEvent} page={this.page} />
|
||||||
</Route>
|
</Route>
|
||||||
@@ -315,10 +298,13 @@ class App extends React.Component {
|
|||||||
this.state.coloredEdges &&
|
this.state.coloredEdges &&
|
||||||
<div className="colored-edges"></div>
|
<div className="colored-edges"></div>
|
||||||
}
|
}
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/create-set" exact>
|
<Route path="/create-set" exact>
|
||||||
<EditSet db={db} user={this.state.user} logEvent={analytics.logEvent} page={this.page} createSet={true} />
|
<EditSet db={db} user={this.state.user} logEvent={analytics.logEvent} page={this.page} createSet={true} />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="/create-set/bulk" exact>
|
||||||
|
<BulkCreateSets db={db} user={this.state.user} logEvent={analytics.logEvent} page={this.page} />
|
||||||
|
</Route>
|
||||||
<Route path="/my-sets" exact>
|
<Route path="/my-sets" exact>
|
||||||
<UserSets db={db} functions={functions} user={this.state.user} logEvent={analytics.logEvent} page={this.page} />
|
<UserSets db={db} functions={functions} user={this.state.user} logEvent={analytics.logEvent} page={this.page} />
|
||||||
</Route>
|
</Route>
|
||||||
@@ -367,7 +353,7 @@ class App extends React.Component {
|
|||||||
}
|
}
|
||||||
<div className="cookie-notice" id="cookie-notice">
|
<div className="cookie-notice" id="cookie-notice">
|
||||||
<div>
|
<div>
|
||||||
<p>Just so you know, we use cookies. Read our privacy policy <Link to="/privacy">here</Link>.</p>
|
<p>Just so you know, we use cookies. By using this site you consent to this. Read our privacy policy <Link to="/privacy">here</Link>.</p>
|
||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
394
src/BulkCreateSets.js
Normal file
394
src/BulkCreateSets.js
Normal file
@@ -0,0 +1,394 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import { withRouter, Prompt } from "react-router-dom";
|
||||||
|
import { HomeRounded as HomeRoundedIcon, UndoRounded as TuneRoundedIcon } from "@material-ui/icons";
|
||||||
|
import NavBar from "./NavBar";
|
||||||
|
import Button from "./Button";
|
||||||
|
import Footer from "./Footer";
|
||||||
|
import LinkButton from "./LinkButton";
|
||||||
|
import AcceptDialog from "./AcceptDialog";
|
||||||
|
import Checkbox from '@material-ui/core/Checkbox';
|
||||||
|
|
||||||
|
const emptySetData = {
|
||||||
|
title: "",
|
||||||
|
public: false,
|
||||||
|
text: "",
|
||||||
|
vocabPairs: [],
|
||||||
|
vocabChanged: false,
|
||||||
|
incompletePairFound: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withRouter(class BulkCreateSets extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
user: props.user,
|
||||||
|
db: props.db,
|
||||||
|
loading: false,
|
||||||
|
canSave: false,
|
||||||
|
sets: [
|
||||||
|
{
|
||||||
|
...emptySetData
|
||||||
|
}
|
||||||
|
],
|
||||||
|
navbarItems: [
|
||||||
|
{
|
||||||
|
type: "link",
|
||||||
|
link: "/",
|
||||||
|
icon: <HomeRoundedIcon />,
|
||||||
|
hideTextMobile: true,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
termDefSeparator: "\\n",
|
||||||
|
pairSeparator: "\\n",
|
||||||
|
changesMade: false,
|
||||||
|
showErrorDialog: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let isMounted = true;
|
||||||
|
Object.defineProperty(this, "isMounted", {
|
||||||
|
get: () => isMounted,
|
||||||
|
set: (value) => isMounted = value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setState = (state, callback = null) => {
|
||||||
|
if (this.isMounted) super.setState(state, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
alertLeavingWithoutSaving = (e = null) => {
|
||||||
|
if (this.state.changesMade) {
|
||||||
|
var confirmationMessage = "Are you sure you want to leave? You will lose any unsaved changes.";
|
||||||
|
|
||||||
|
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
|
||||||
|
return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
async componentDidMount() {
|
||||||
|
window.addEventListener("beforeunload", this.alertLeavingWithoutSaving);
|
||||||
|
|
||||||
|
document.title = "Bulk Create Sets | Parandum";
|
||||||
|
this.props.logEvent("page_view");
|
||||||
|
|
||||||
|
this.firstSetNameInput.focus();
|
||||||
|
this.props.page.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount = () => {
|
||||||
|
window.removeEventListener('beforeunload', this.alertLeavingWithoutSaving);
|
||||||
|
this.isMounted = false;
|
||||||
|
this.props.page.unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
stopLoading = () => {
|
||||||
|
this.setState({
|
||||||
|
canSave: false,
|
||||||
|
loading: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanseVocabString = (item, otherPatterns=[]) => {
|
||||||
|
let newItem = item;
|
||||||
|
otherPatterns.map(pattern => newItem = newItem.replace(new RegExp(pattern, "g"), ""));
|
||||||
|
const chars = /[\p{P}\p{S}\n ]+/ug;
|
||||||
|
return newItem.replace(chars, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
removeNewLines = (item) => item.replace(/[\n]+/ug, "")
|
||||||
|
|
||||||
|
handleSetDataChange = () => {
|
||||||
|
const sets = [...this.state.sets];
|
||||||
|
if (sets[this.state.sets.length - 1].text !== "" || sets[this.state.sets.length - 1].title !== "") {
|
||||||
|
sets.push({...emptySetData});
|
||||||
|
this.setState({
|
||||||
|
sets,
|
||||||
|
changesMade: true,
|
||||||
|
});
|
||||||
|
} else if (sets[this.state.sets.length - 2].text === "" && sets[this.state.sets.length - 2].title === "") {
|
||||||
|
sets.pop();
|
||||||
|
this.setState({
|
||||||
|
sets,
|
||||||
|
changesMade: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkIfCanSave = async () => {
|
||||||
|
let anySetIncomplete = this.state.termDefSeparator === "" || this.state.pairSeparator === "";
|
||||||
|
let newSets;
|
||||||
|
if (!anySetIncomplete) {
|
||||||
|
let sets = [...this.state.sets];
|
||||||
|
const pairSeparator = this.state.pairSeparator.replace("\\n","\n");
|
||||||
|
const termDefSeparator = this.state.termDefSeparator.replace("\\n","\n");
|
||||||
|
|
||||||
|
const setsWithVocab = sets.slice(0,-1).map(set => {
|
||||||
|
let setIncomplete = this.cleanseVocabString(set.title) === "" || this.cleanseVocabString(set.text, [pairSeparator, termDefSeparator]) === "";
|
||||||
|
if (setIncomplete) {
|
||||||
|
anySetIncomplete = true;
|
||||||
|
return {
|
||||||
|
...set,
|
||||||
|
vocabChanged: false,
|
||||||
|
setIncomplete,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (set.vocabChanged) {
|
||||||
|
let vocabPairs = [];
|
||||||
|
if (pairSeparator === termDefSeparator) {
|
||||||
|
set.text.trim().split(pairSeparator).forEach((item, index, arr) => {
|
||||||
|
if (index % 2 === 0) {
|
||||||
|
let definition = "unknown";
|
||||||
|
if (index === arr.length - 1 || this.cleanseVocabString(item, [pairSeparator, termDefSeparator]) === "" || this.cleanseVocabString(arr[index + 1], [pairSeparator, termDefSeparator]) === "") {
|
||||||
|
anySetIncomplete = setIncomplete = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
definition = arr[index + 1];
|
||||||
|
}
|
||||||
|
vocabPairs.push({
|
||||||
|
term: item,
|
||||||
|
definition,
|
||||||
|
sound: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
vocabPairs = set.text.trim().split(pairSeparator)
|
||||||
|
.map((pair) => {
|
||||||
|
let [first, ...rest] = pair.split(termDefSeparator);
|
||||||
|
if (rest.length <= 0 || this.cleanseVocabString(first, [pairSeparator, termDefSeparator]) === "" || this.cleanseVocabString(rest.join(termDefSeparator), [pairSeparator, termDefSeparator]) === "") {
|
||||||
|
rest = "unknown";
|
||||||
|
anySetIncomplete = setIncomplete = true;
|
||||||
|
} else {
|
||||||
|
rest = rest.join(termDefSeparator);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
term: first,
|
||||||
|
definition: rest,
|
||||||
|
sound: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vocabPairs.length < 1) {
|
||||||
|
anySetIncomplete = setIncomplete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...set,
|
||||||
|
vocabPairs,
|
||||||
|
vocabChanged: false,
|
||||||
|
setIncomplete,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (set.setIncomplete) {
|
||||||
|
anySetIncomplete = true;
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
});
|
||||||
|
newSets = setsWithVocab.concat(sets[sets.length - 1]);
|
||||||
|
} else {
|
||||||
|
newSets = [...this.state.sets];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
sets: newSets,
|
||||||
|
canSave: !anySetIncomplete,
|
||||||
|
showErrorDialog: anySetIncomplete,
|
||||||
|
}, () => {if (!anySetIncomplete) this.saveSets()});
|
||||||
|
}
|
||||||
|
|
||||||
|
onTermDefSeparatorInputChange = (event) => {
|
||||||
|
this.setState({
|
||||||
|
termDefSeparator: event.target.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onPairSeparatorInputChange = (event) => {
|
||||||
|
this.setState({
|
||||||
|
pairSeparator: event.target.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSetTitleInputChange = (event, setIndex) => {
|
||||||
|
let sets = [...this.state.sets];
|
||||||
|
sets[setIndex].title = event.target.value;
|
||||||
|
this.setState({
|
||||||
|
sets,
|
||||||
|
}, () => this.handleSetDataChange());
|
||||||
|
}
|
||||||
|
|
||||||
|
onPublicSetInputChange = (event, setIndex) => {
|
||||||
|
let sets = [...this.state.sets];
|
||||||
|
sets[setIndex].public = event.target.checked;
|
||||||
|
this.setState({
|
||||||
|
sets,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onVocabInputChange = (event, setIndex) => {
|
||||||
|
let sets = [...this.state.sets];
|
||||||
|
sets[setIndex].text = event.target.value;
|
||||||
|
sets[setIndex].vocabChanged = true;
|
||||||
|
this.setState({
|
||||||
|
sets,
|
||||||
|
}, () => this.handleSetDataChange());
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSets = async () => {
|
||||||
|
if (this.state.canSave) {
|
||||||
|
this.setState({
|
||||||
|
loading: true,
|
||||||
|
canSave: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const db = this.state.db;
|
||||||
|
const setCollectionRef = db.collection("sets");
|
||||||
|
|
||||||
|
let promises = [];
|
||||||
|
|
||||||
|
this.state.sets.slice(0,-1).map(async (set) => {
|
||||||
|
let setDocRef = setCollectionRef.doc();
|
||||||
|
setDocRef.set({
|
||||||
|
title: set.title,
|
||||||
|
public: set.public,
|
||||||
|
owner: this.state.user.uid,
|
||||||
|
groups: [],
|
||||||
|
}).then(() => {
|
||||||
|
let vocabCollectionRef = setDocRef.collection("vocab");
|
||||||
|
|
||||||
|
let batches = [db.batch()];
|
||||||
|
|
||||||
|
set.vocabPairs.map((vocabPair, index) => {
|
||||||
|
if (index % 248 === 0) {
|
||||||
|
promises.push(batches[batches.length - 1].commit());
|
||||||
|
batches.push(db.batch());
|
||||||
|
}
|
||||||
|
|
||||||
|
let vocabDocRef = vocabCollectionRef.doc()
|
||||||
|
return batches[batches.length - 1].set(vocabDocRef, {
|
||||||
|
term: this.removeNewLines(vocabPair.term),
|
||||||
|
definition: this.removeNewLines(vocabPair.definition),
|
||||||
|
sound: vocabPair.sound,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!batches[batches.length - 1]._delegate._committed) promises.push(batches[batches.length - 1].commit().catch(() => null));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.all(promises).then(() => {
|
||||||
|
this.stopLoading();
|
||||||
|
this.props.history.push("/");
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log("Couldn't create sets: " + error);
|
||||||
|
this.stopLoading();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closeErrorDialog = () => {
|
||||||
|
this.setState({
|
||||||
|
showErrorDialog: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Prompt
|
||||||
|
when={this.state.changesMade}
|
||||||
|
message="Are you sure you want to leave? You will lose any unsaved changes."
|
||||||
|
/>
|
||||||
|
|
||||||
|
<NavBar items={this.state.navbarItems} />
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div className="page-header">
|
||||||
|
<h1>Bulk Create Sets</h1>
|
||||||
|
<LinkButton to="/create-set" icon={<TuneRoundedIcon/>}>Normal</LinkButton>
|
||||||
|
</div>
|
||||||
|
<div className="bulk-create-sets-section bulk-create-sets-header">
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="term-def-separator"
|
||||||
|
onChange={this.onTermDefSeparatorInputChange}
|
||||||
|
value={this.state.termDefSeparator}
|
||||||
|
autoComplete="off"
|
||||||
|
autoCapitalize="none"
|
||||||
|
autoCorrect="off"
|
||||||
|
/>
|
||||||
|
<span>Term/definition separator</span>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="pair-separator"
|
||||||
|
onChange={this.onPairSeparatorInputChange}
|
||||||
|
value={this.state.pairSeparator}
|
||||||
|
autoComplete="off"
|
||||||
|
autoCapitalize="none"
|
||||||
|
autoCorrect="off"
|
||||||
|
/>
|
||||||
|
<span>Pair separator</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{
|
||||||
|
this.state.sets.map((data, setIndex) =>
|
||||||
|
<div className="bulk-create-sets-section" key={setIndex}>
|
||||||
|
<div className="page-header">
|
||||||
|
<h2>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name={`set_${setIndex}_title`}
|
||||||
|
onChange={(event) => this.onSetTitleInputChange(event, setIndex)}
|
||||||
|
placeholder="Set Title"
|
||||||
|
value={data.title}
|
||||||
|
className="set-title-input"
|
||||||
|
autoComplete="off"
|
||||||
|
ref={(inputEl) => {if (setIndex === 0) this.firstSetNameInput = inputEl}}
|
||||||
|
/>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<Checkbox
|
||||||
|
checked={data.public}
|
||||||
|
onChange={(event) => this.onPublicSetInputChange(event, setIndex)}
|
||||||
|
inputProps={{ 'aria-label': 'checkbox' }}
|
||||||
|
/>
|
||||||
|
<span>Public</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div className="form create-set-vocab-list">
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
name={`set_${setIndex}_vocab`}
|
||||||
|
onChange={(event) => this.onVocabInputChange(event, setIndex)}
|
||||||
|
value={data.text}
|
||||||
|
autoComplete="off"
|
||||||
|
autoCapitalize="none"
|
||||||
|
autoCorrect="off"
|
||||||
|
className="bulk-create-sets-text"
|
||||||
|
placeholder="Vocabulary"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
<Button
|
||||||
|
onClick={this.checkIfCanSave}
|
||||||
|
loading={this.state.loading}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
{
|
||||||
|
this.state.showErrorDialog && <AcceptDialog acceptFunction={this.closeErrorDialog} message="Ensure all fields are filled in correctly"/>
|
||||||
|
}
|
||||||
|
</main>
|
||||||
|
<Footer />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -70,6 +70,14 @@ export default function ClassicTestStart(props) {
|
|||||||
/>
|
/>
|
||||||
<span>Ignore capitals</span>
|
<span>Ignore capitals</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<Checkbox
|
||||||
|
checked={props.ignoreAccents}
|
||||||
|
onChange={props.handleIgnoreAccentsChange}
|
||||||
|
inputProps={{ 'aria-label': 'checkbox' }}
|
||||||
|
/>
|
||||||
|
<span>Ignore accents</span>
|
||||||
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={props.showNumberOfAnswers}
|
checked={props.showNumberOfAnswers}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { withRouter, Prompt } from "react-router-dom";
|
|||||||
import { HomeRounded as HomeRoundedIcon } from "@material-ui/icons";
|
import { HomeRounded as HomeRoundedIcon } from "@material-ui/icons";
|
||||||
import NavBar from "./NavBar";
|
import NavBar from "./NavBar";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
|
import LinkButton from "./LinkButton";
|
||||||
import Error404 from "./Error404";
|
import Error404 from "./Error404";
|
||||||
import Footer from "./Footer";
|
import Footer from "./Footer";
|
||||||
import Checkbox from '@material-ui/core/Checkbox';
|
import Checkbox from '@material-ui/core/Checkbox';
|
||||||
@@ -137,7 +138,7 @@ export default withRouter(class EditSet extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanseVocabString = (item) => {
|
cleanseVocabString = (item) => {
|
||||||
const chars = /[\p{P}\p{S} ]+/ug;
|
const chars = /[\p{P}\p{S}\n ]+/ug;
|
||||||
return item.replace(chars, "");
|
return item.replace(chars, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,6 +361,10 @@ export default withRouter(class EditSet extends Component {
|
|||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
|
{
|
||||||
|
this.props.createSet &&
|
||||||
|
<LinkButton to="/create-set/bulk">Bulk add</LinkButton>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form create-set-vocab-list">
|
<div className="form create-set-vocab-list">
|
||||||
|
|||||||
82
src/Home.js
82
src/Home.js
@@ -42,16 +42,80 @@ export default function Home(props) {
|
|||||||
<br/>
|
<br/>
|
||||||
<p>To get started, click login 👆</p>
|
<p>To get started, click login 👆</p>
|
||||||
<br/>
|
<br/>
|
||||||
<p>If you have any feedback, please feel free to email me at <a href="mailto:parandum@mgrove.uk">parandum@mgrove.uk</a>.</p>
|
<p>If you have any feedback, please feel free to email us at <a href="mailto:contact@parandum.mgrove.uk">contact@parandum.mgrove.uk</a>.</p>
|
||||||
<br/>
|
<br/>
|
||||||
<h2>What's New?</h2>
|
<div className="whats-new">
|
||||||
<Collapsible transitionTime={300} trigger={<>v2.0.6<ArrowDropDownRoundedIcon /></>}>
|
<h2>What's New?</h2>
|
||||||
<ul>
|
<Collapsible open={true} transitionTime={500} easing="ease" trigger={<>v2.3.3<ArrowDropDownRoundedIcon /></>}>
|
||||||
<li>Add option to show number of answers for each prompt</li>
|
<ul>
|
||||||
<li>Ensure test options are carried over to new tests that are made from pre-existing ones (i.e. with the restart test buttons)</li>
|
<li>Bug fixes:</li>
|
||||||
</ul>
|
<ul>
|
||||||
{/* TODO: style */}
|
<li>On the search page, all sets are shown instead of only the last 50 showing and previous ones being overwritten</li>
|
||||||
</Collapsible>
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.3.2<ArrowDropDownRoundedIcon /></>}>
|
||||||
|
<ul>
|
||||||
|
<li>Bug fixes:</li>
|
||||||
|
<ul>
|
||||||
|
<li>On the search page, all sets are now visible rather than just the first 48</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.3.0<ArrowDropDownRoundedIcon /></>}>
|
||||||
|
<ul>
|
||||||
|
<li>Add option to ignore accents during tests</li>
|
||||||
|
<li>Update cookie notice</li>
|
||||||
|
<li>Update contact email address</li>
|
||||||
|
<li>Add ability to bulk-create sets and bulk-add vocabulary</li>
|
||||||
|
<li>Bug fixes:</li>
|
||||||
|
<ul>
|
||||||
|
<li>Minor styling improvements</li>
|
||||||
|
<li>Efficiency improvements</li>
|
||||||
|
<li>When a set is in a group and the group is deleted, navigating to the home screen no longer throws an error</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.2.0<ArrowDropDownRoundedIcon /></>} >
|
||||||
|
<ul>
|
||||||
|
<li>Allow saving a set with no changes</li>
|
||||||
|
<li>Bug fixes:</li>
|
||||||
|
<ul>
|
||||||
|
<li>Minor styling improvements</li>
|
||||||
|
<li>Efficiency improvements</li>
|
||||||
|
<li>Users are now correctly removed from groups</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.1.9<ArrowDropDownRoundedIcon /></>}>
|
||||||
|
<ul>
|
||||||
|
<li>Add an optional on-screen configurable keyboard during tests for easier access to accented characters</li>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.1.8<ArrowDropDownRoundedIcon /></>}>
|
||||||
|
<ul>
|
||||||
|
<li>Bug fixes:</li>
|
||||||
|
<ul>
|
||||||
|
<li>Test options are now set correctly when starting tests</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.1.7<ArrowDropDownRoundedIcon /></>}>
|
||||||
|
<ul>
|
||||||
|
<li>Bug fixes:</li>
|
||||||
|
<ul>
|
||||||
|
<li>Ensure backwards-compatibility with old versions of Parandum</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible transitionTime={500} easing="ease" trigger={<>v2.1.6<ArrowDropDownRoundedIcon /></>}>
|
||||||
|
<ul>
|
||||||
|
<li>Add option to show number of answers for each prompt</li>
|
||||||
|
<li>Ensure test options are carried over to new tests that are made from pre-existing ones (i.e. with the restart test buttons)</li>
|
||||||
|
</ul>
|
||||||
|
{/* TODO: style */}
|
||||||
|
</Collapsible>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
@@ -70,6 +70,14 @@ export default function LivesTestStart(props) {
|
|||||||
/>
|
/>
|
||||||
<span>Ignore capitals</span>
|
<span>Ignore capitals</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<Checkbox
|
||||||
|
checked={props.ignoreAccents}
|
||||||
|
onChange={props.handleIgnoreAccentsChange}
|
||||||
|
inputProps={{ 'aria-label': 'checkbox' }}
|
||||||
|
/>
|
||||||
|
<span>Ignore accents</span>
|
||||||
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={props.showNumberOfAnswers}
|
checked={props.showNumberOfAnswers}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export default withRouter(class LoggedInHome extends React.Component {
|
|||||||
sliderValue: 1,
|
sliderValue: 1,
|
||||||
switchLanguage: false,
|
switchLanguage: false,
|
||||||
ignoreCaps: false,
|
ignoreCaps: false,
|
||||||
|
ignoreAccents: false,
|
||||||
showNumberOfAnswers: false,
|
showNumberOfAnswers: false,
|
||||||
totalTestQuestions: 1,
|
totalTestQuestions: 1,
|
||||||
pendingDeletions: {},
|
pendingDeletions: {},
|
||||||
@@ -201,6 +202,7 @@ export default withRouter(class LoggedInHome extends React.Component {
|
|||||||
mode: mode,
|
mode: mode,
|
||||||
limit: this.state.sliderValue,
|
limit: this.state.sliderValue,
|
||||||
ignoreCaps: this.state.ignoreCaps,
|
ignoreCaps: this.state.ignoreCaps,
|
||||||
|
ignoreAccents: this.state.ignoreAccents,
|
||||||
showNumberOfAnswers: this.state.showNumberOfAnswers,
|
showNumberOfAnswers: this.state.showNumberOfAnswers,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
const progressId = result.data;
|
const progressId = result.data;
|
||||||
@@ -360,6 +362,12 @@ export default withRouter(class LoggedInHome extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleIgnoreAccentsChange = (event) => {
|
||||||
|
this.setState({
|
||||||
|
ignoreAccents: event.target.checked,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleShowNumberOfAnswersChange = (event) => {
|
handleShowNumberOfAnswersChange = (event) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showNumberOfAnswers: event.target.checked,
|
showNumberOfAnswers: event.target.checked,
|
||||||
@@ -526,7 +534,7 @@ export default withRouter(class LoggedInHome extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{this.state.userGroupSets && this.state.userGroupSets.length > 0 && this.state.userGroupSets
|
{this.state.userGroupSets && this.state.userGroupSets.length > 0 && this.state.userGroupSets.group && typeof this.state.userGroupSets.group.data === "function" && this.state.userGroupSets
|
||||||
.map(data =>
|
.map(data =>
|
||||||
data.sets && data.sets.length > 0 &&
|
data.sets && data.sets.length > 0 &&
|
||||||
<div key={data.group.id} className="checkbox-list-container">
|
<div key={data.group.id} className="checkbox-list-container">
|
||||||
@@ -586,9 +594,11 @@ export default withRouter(class LoggedInHome extends React.Component {
|
|||||||
onSliderChange={this.changeSliderValue}
|
onSliderChange={this.changeSliderValue}
|
||||||
switchLanguage={this.state.switchLanguage}
|
switchLanguage={this.state.switchLanguage}
|
||||||
ignoreCaps={this.state.ignoreCaps}
|
ignoreCaps={this.state.ignoreCaps}
|
||||||
|
ignoreAccents={this.state.ignoreAccents}
|
||||||
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
||||||
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
||||||
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
||||||
|
handleIgnoreAccentsChange={this.handleIgnoreAccentsChange}
|
||||||
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
/>
|
/>
|
||||||
@@ -603,9 +613,11 @@ export default withRouter(class LoggedInHome extends React.Component {
|
|||||||
onSliderChange={this.changeSliderValue}
|
onSliderChange={this.changeSliderValue}
|
||||||
switchLanguage={this.state.switchLanguage}
|
switchLanguage={this.state.switchLanguage}
|
||||||
ignoreCaps={this.state.ignoreCaps}
|
ignoreCaps={this.state.ignoreCaps}
|
||||||
|
ignoreAccents={this.state.ignoreAccents}
|
||||||
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
||||||
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
||||||
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
||||||
|
handleIgnoreAccentsChange={this.handleIgnoreAccentsChange}
|
||||||
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
/>
|
/>
|
||||||
|
|||||||
32
src/PlatformDisabled.js
Normal file
32
src/PlatformDisabled.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import Footer from "./Footer";
|
||||||
|
import NavBar from "./NavBar";
|
||||||
|
|
||||||
|
const PlatformDisabled = (props) => {
|
||||||
|
useEffect(() => {
|
||||||
|
if (props.page) {
|
||||||
|
props.page.load();
|
||||||
|
return () => props.page.unload();
|
||||||
|
}
|
||||||
|
if (props.logEvent) props.logEvent("page_view");
|
||||||
|
}, [props, props.logEvent, props.page]);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<NavBar items={[]} />
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div className="description-section">
|
||||||
|
<h1>Your access to Parandum has been disabled</h1>
|
||||||
|
<p>
|
||||||
|
Apologies, but due to unpaid invoices by <Link to={{pathname: "https://reading-school.co.uk"}} target="_blank">Reading School</Link> you
|
||||||
|
are currently unable to access this platform. Please contact your head of department, senior leadership team, and finance department.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlatformDisabled;
|
||||||
@@ -247,7 +247,7 @@ export default function PrivacyPolicy(props) {
|
|||||||
|
|
||||||
<h2>Contact Us</h2>
|
<h2>Contact Us</h2>
|
||||||
|
|
||||||
<p>If you have questions or comments about this Privacy Policy, please contact us at <a href="mailto:parandum@mgrove.uk">parandum@mgrove.uk</a></p>
|
<p>If you have questions or comments about this Privacy Policy, please contact us at <a href="mailto:contact@parandum.mgrove.uk">contact@parandum.mgrove.uk</a></p>
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
showLivesTestStart: false,
|
showLivesTestStart: false,
|
||||||
searchInput: "",
|
searchInput: "",
|
||||||
ignoreCaps: false,
|
ignoreCaps: false,
|
||||||
|
ignoreAccents: false,
|
||||||
showNumberOfAnswers: false,
|
showNumberOfAnswers: false,
|
||||||
switchLanguage: false,
|
switchLanguage: false,
|
||||||
sliderValue: 1,
|
sliderValue: 1,
|
||||||
@@ -101,7 +102,7 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
sets: reload ? querySnapshot.docs : this.state.sets.concat(querySnapshot.docs),
|
sets: reload ? querySnapshot.docs : this.state.sets.concat(querySnapshot.docs),
|
||||||
selections: selections,
|
selections: selections,
|
||||||
pageNumber: this.state.pageNumber + 1,
|
pageNumber: this.state.pageNumber + 1,
|
||||||
loadedAllSets: querySnapshot.docs.length === 0,
|
loadedAllSets: querySnapshot.docs.length < paginationFrequency,
|
||||||
loadingSets: false,
|
loadingSets: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -140,6 +141,7 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
mode: mode,
|
mode: mode,
|
||||||
limit: this.state.sliderValue,
|
limit: this.state.sliderValue,
|
||||||
ignoreCaps: this.state.ignoreCaps,
|
ignoreCaps: this.state.ignoreCaps,
|
||||||
|
ignoreAccents: this.state.ignoreAccents,
|
||||||
showNumberOfAnswers: this.state.showNumberOfAnswers,
|
showNumberOfAnswers: this.state.showNumberOfAnswers,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
const progressId = result.data;
|
const progressId = result.data;
|
||||||
@@ -251,6 +253,12 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleIgnoreAccentsChange = (event) => {
|
||||||
|
this.setState({
|
||||||
|
ignoreAccents: event.target.checked,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleShowNumberOfAnswersChange = (event) => {
|
handleShowNumberOfAnswersChange = (event) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showNumberOfAnswers: event.target.checked,
|
showNumberOfAnswers: event.target.checked,
|
||||||
@@ -309,7 +317,7 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
|
|
||||||
<div className="checkbox-list">
|
<div className="checkbox-list">
|
||||||
{
|
{
|
||||||
this.state.sets.slice(-50).map(set =>
|
this.state.sets.map(set =>
|
||||||
<div key={set.id}>
|
<div key={set.id}>
|
||||||
<label>
|
<label>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
@@ -326,7 +334,7 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
!this.state.loadedAllSets && this.state.sets.length === paginationFrequency &&
|
!this.state.loadedAllSets &&
|
||||||
<Button
|
<Button
|
||||||
onClick={() => this.loadSets()}
|
onClick={() => this.loadSets()}
|
||||||
disabled={this.state.loadingSets}
|
disabled={this.state.loadingSets}
|
||||||
@@ -356,9 +364,11 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
onSliderChange={this.changeSliderValue}
|
onSliderChange={this.changeSliderValue}
|
||||||
switchLanguage={this.state.switchLanguage}
|
switchLanguage={this.state.switchLanguage}
|
||||||
ignoreCaps={this.state.ignoreCaps}
|
ignoreCaps={this.state.ignoreCaps}
|
||||||
|
ignoreAccents={this.state.ignoreAccents}
|
||||||
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
||||||
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
||||||
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
||||||
|
handleIgnoreAccentsChange={this.handleIgnoreAccentsChange}
|
||||||
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
/>
|
/>
|
||||||
@@ -373,9 +383,11 @@ export default withRouter(class SearchSets extends Component {
|
|||||||
onSliderChange={this.changeSliderValue}
|
onSliderChange={this.changeSliderValue}
|
||||||
switchLanguage={this.state.switchLanguage}
|
switchLanguage={this.state.switchLanguage}
|
||||||
ignoreCaps={this.state.ignoreCaps}
|
ignoreCaps={this.state.ignoreCaps}
|
||||||
|
ignoreAccents={this.state.ignoreAccents}
|
||||||
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
||||||
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
||||||
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
||||||
|
handleIgnoreAccentsChange={this.handleIgnoreAccentsChange}
|
||||||
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export default withRouter(class SetPage extends React.Component {
|
|||||||
sliderValue: 1,
|
sliderValue: 1,
|
||||||
switchLanguage: false,
|
switchLanguage: false,
|
||||||
ignoreCaps: false,
|
ignoreCaps: false,
|
||||||
|
ignoreAccents: false,
|
||||||
showNumberOfAnswers: false,
|
showNumberOfAnswers: false,
|
||||||
totalTestQuestions: 1,
|
totalTestQuestions: 1,
|
||||||
};
|
};
|
||||||
@@ -137,6 +138,7 @@ export default withRouter(class SetPage extends React.Component {
|
|||||||
mode: mode,
|
mode: mode,
|
||||||
limit: this.state.sliderValue,
|
limit: this.state.sliderValue,
|
||||||
ignoreCaps: this.state.ignoreCaps,
|
ignoreCaps: this.state.ignoreCaps,
|
||||||
|
ignoreAccents: this.state.ignoreAccents,
|
||||||
showNumberOfAnswers: this.state.showNumberOfAnswers,
|
showNumberOfAnswers: this.state.showNumberOfAnswers,
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
const progressId = result.data;
|
const progressId = result.data;
|
||||||
@@ -342,6 +344,12 @@ export default withRouter(class SetPage extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleIgnoreAccentsChange = (event) => {
|
||||||
|
this.setState({
|
||||||
|
ignoreAccents: event.target.checked,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleShowNumberOfAnswersChange = (event) => {
|
handleShowNumberOfAnswersChange = (event) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showNumberOfAnswers: event.target.checked,
|
showNumberOfAnswers: event.target.checked,
|
||||||
@@ -496,9 +504,11 @@ export default withRouter(class SetPage extends React.Component {
|
|||||||
onSliderChange={this.changeSliderValue}
|
onSliderChange={this.changeSliderValue}
|
||||||
switchLanguage={this.state.switchLanguage}
|
switchLanguage={this.state.switchLanguage}
|
||||||
ignoreCaps={this.state.ignoreCaps}
|
ignoreCaps={this.state.ignoreCaps}
|
||||||
|
ignoreAccents={this.state.ignoreAccents}
|
||||||
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
||||||
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
||||||
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
||||||
|
handleIgnoreAccentsChange={this.handleIgnoreAccentsChange}
|
||||||
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
disabled={!this.state.canStartTest}
|
disabled={!this.state.canStartTest}
|
||||||
@@ -514,9 +524,11 @@ export default withRouter(class SetPage extends React.Component {
|
|||||||
onSliderChange={this.changeSliderValue}
|
onSliderChange={this.changeSliderValue}
|
||||||
switchLanguage={this.state.switchLanguage}
|
switchLanguage={this.state.switchLanguage}
|
||||||
ignoreCaps={this.state.ignoreCaps}
|
ignoreCaps={this.state.ignoreCaps}
|
||||||
|
ignoreAccents={this.state.ignoreAccents}
|
||||||
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
showNumberOfAnswers={this.state.showNumberOfAnswers}
|
||||||
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
handleSwitchLanguageChange={this.handleSwitchLanguageChange}
|
||||||
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
|
||||||
|
handleIgnoreAccentsChange={this.handleIgnoreAccentsChange}
|
||||||
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
|
||||||
loading={this.state.loading}
|
loading={this.state.loading}
|
||||||
disabled={!this.state.canStartTest}
|
disabled={!this.state.canStartTest}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ label .MuiIconButton-label > input {
|
|||||||
border-radius: 150px;
|
border-radius: 150px;
|
||||||
background: var(--primary-color-dark);
|
background: var(--primary-color-dark);
|
||||||
margin: auto;
|
margin: auto;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@@ -332,6 +332,9 @@ label .MuiIconButton-label > input {
|
|||||||
padding: 16px 24px;
|
padding: 16px 24px;
|
||||||
background-color: var(--primary-color-dark);
|
background-color: var(--primary-color-dark);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
height: 300px;
|
||||||
|
max-height: 80vh;
|
||||||
|
font-size: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cookie-notice > div > p {
|
.cookie-notice > div > p {
|
||||||
@@ -424,6 +427,16 @@ label .MuiIconButton-label > input {
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Collapsible > span {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Collapsible .Collapsible__contentInner > ul {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@media screen and (max-width: 420px) {
|
@media screen and (max-width: 420px) {
|
||||||
.progress-history-container > div > *:nth-child(2), .progress-history-container--complete > div > *:nth-last-child(3), .progress-history-container--incomplete > div > *:nth-last-child(4) {
|
.progress-history-container > div > *:nth-child(2), .progress-history-container--complete > div > *:nth-last-child(3), .progress-history-container--incomplete > div > *:nth-last-child(4) {
|
||||||
|
|||||||
@@ -10,3 +10,7 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.accept-dialog > .button-container {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,40 @@
|
|||||||
flex-basis: 0;
|
flex-basis: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bulk-create-sets-section {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bulk-create-sets-header, .bulk-create-sets-header > * {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
column-gap: 24px;
|
||||||
|
row-gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bulk-create-sets-header > * {
|
||||||
|
column-gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bulk-create-sets-header > * > input {
|
||||||
|
min-width: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bulk-create-sets-text {
|
||||||
|
min-height: 400px;
|
||||||
|
font: inherit;
|
||||||
|
background: transparent;
|
||||||
|
color: inherit;
|
||||||
|
border: 2px solid var(--overlay-color);
|
||||||
|
padding: 8px;
|
||||||
|
margin: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bulk-create-sets-text:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.form .checkbox-list-container {
|
.form .checkbox-list-container {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.overlay-content {
|
.overlay-content {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ const setTwo = "set_02";
|
|||||||
const vocabOne = "vocab_01";
|
const vocabOne = "vocab_01";
|
||||||
const termOne = "term_01";
|
const termOne = "term_01";
|
||||||
const definitionOne = "definition_01";
|
const definitionOne = "definition_01";
|
||||||
|
const definitionOneWithCaps = "DefinitIon_01";
|
||||||
|
const definitionOneWithAccents = "dëfiñítion_01";
|
||||||
const definitionOneTypoOne = "ddefinition_01";
|
const definitionOneTypoOne = "ddefinition_01";
|
||||||
const definitionOneTypoTwo = "dinition_01";
|
const definitionOneTypoTwo = "dinition_01";
|
||||||
const definitionOneTypoThree = "dinition_02";
|
const definitionOneTypoThree = "dinition_02";
|
||||||
@@ -127,6 +129,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
sets: [setOne],
|
sets: [setOne],
|
||||||
mode: "questions",
|
mode: "questions",
|
||||||
limit: 2,
|
limit: 2,
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const progressId = await createProgress(requestData);
|
const progressId = await createProgress(requestData);
|
||||||
@@ -164,7 +169,7 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("createProgress can create new questions mode progress file from multiple existing sets", async () => {
|
it("createProgress can create new questions mode progress file from multiple existing sets with all test aids enabled", async () => {
|
||||||
const createProgress = test.wrap(cloudFunctions.createProgress);
|
const createProgress = test.wrap(cloudFunctions.createProgress);
|
||||||
|
|
||||||
const setDataOne = {
|
const setDataOne = {
|
||||||
@@ -218,6 +223,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
sets: [setOne, setTwo],
|
sets: [setOne, setTwo],
|
||||||
mode: "questions",
|
mode: "questions",
|
||||||
limit: 4,
|
limit: 4,
|
||||||
|
ignoreAccents: true,
|
||||||
|
ignoreCaps: true,
|
||||||
|
showNumberOfAnswers: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const progressId = await createProgress(requestData);
|
const progressId = await createProgress(requestData);
|
||||||
@@ -241,7 +249,7 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
assert.strictEqual(snapAfter.typo, false);
|
assert.strictEqual(snapAfter.typo, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("createProgress can create new lives mode progress file from existing set", async () => {
|
it("createProgress can create new lives mode progress file from existing set with no test aids enabled", async () => {
|
||||||
const createProgress = test.wrap(cloudFunctions.createProgress);
|
const createProgress = test.wrap(cloudFunctions.createProgress);
|
||||||
|
|
||||||
const setDataOne = {
|
const setDataOne = {
|
||||||
@@ -271,6 +279,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
sets: [setOne],
|
sets: [setOne],
|
||||||
mode: "lives",
|
mode: "lives",
|
||||||
limit: 2,
|
limit: 2,
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const progressId = await createProgress(requestData);
|
const progressId = await createProgress(requestData);
|
||||||
@@ -328,6 +339,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
sets: [setOne],
|
sets: [setOne],
|
||||||
mode: "questions",
|
mode: "questions",
|
||||||
limit: 2,
|
limit: 2,
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
firebase.assertSucceeds(createProgress(requestData));
|
firebase.assertSucceeds(createProgress(requestData));
|
||||||
@@ -363,6 +377,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
sets: [setTwo],
|
sets: [setTwo],
|
||||||
mode: "questions",
|
mode: "questions",
|
||||||
limit: 2,
|
limit: 2,
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
firebase.assertFails(createProgress(requestData));
|
firebase.assertFails(createProgress(requestData));
|
||||||
@@ -389,6 +406,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -548,6 +568,372 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
assert.strictEqual(snapAfterCorrectData.typo, false);
|
assert.strictEqual(snapAfterCorrectData.typo, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("processAnswer updates progress documents appropriately when correct and incorrect answers provided with ignore caps enabled", async () => {
|
||||||
|
const processAnswer = test.wrap(cloudFunctions.processAnswer);
|
||||||
|
|
||||||
|
const progressData = {
|
||||||
|
correct: [],
|
||||||
|
current_correct: [],
|
||||||
|
duration: null,
|
||||||
|
incorrect: [],
|
||||||
|
progress: 0,
|
||||||
|
questions: [
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabTwo
|
||||||
|
],
|
||||||
|
set_title: setOne,
|
||||||
|
set_titles: [setOne],
|
||||||
|
start_time: 1627308670962,
|
||||||
|
switch_language: false,
|
||||||
|
uid: userOne,
|
||||||
|
mode: "questions",
|
||||||
|
typo: false,
|
||||||
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: true,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
|
};
|
||||||
|
const termDataOne = {
|
||||||
|
"item": termOne,
|
||||||
|
"sound": soundOne,
|
||||||
|
};
|
||||||
|
const termDataTwo = {
|
||||||
|
"item": termTwo,
|
||||||
|
"sound": soundTwo,
|
||||||
|
};
|
||||||
|
const definitionDataOne = {
|
||||||
|
"item": definitionOne,
|
||||||
|
"sound": soundOne,
|
||||||
|
};
|
||||||
|
const definitionDataTwo = {
|
||||||
|
"item": definitionTwo,
|
||||||
|
"sound": soundTwo,
|
||||||
|
};
|
||||||
|
|
||||||
|
const progressId = "progress_01";
|
||||||
|
const progressDocId = firestore.collection("progress").doc(progressId);
|
||||||
|
|
||||||
|
await progressDocId.set(progressData);
|
||||||
|
await progressDocId.collection("terms").doc(progressVocabOne)
|
||||||
|
.set(termDataOne);
|
||||||
|
await progressDocId.collection("terms").doc(progressVocabTwo)
|
||||||
|
.set(termDataTwo);
|
||||||
|
await progressDocId.collection("definitions").doc(progressVocabOne)
|
||||||
|
.set(definitionDataOne);
|
||||||
|
await progressDocId.collection("definitions").doc(progressVocabTwo)
|
||||||
|
.set(definitionDataTwo);
|
||||||
|
|
||||||
|
const firstTermAnswerRequestData = {
|
||||||
|
progressId: progressId,
|
||||||
|
answer: definitionOne,
|
||||||
|
};
|
||||||
|
const secondTermAnswerRequestData = {
|
||||||
|
progressId: progressId,
|
||||||
|
answer: definitionTwo,
|
||||||
|
};
|
||||||
|
const incorrectAnswerRequestData = {
|
||||||
|
progressId: progressId,
|
||||||
|
answer: definitionOneWithCaps,
|
||||||
|
};
|
||||||
|
|
||||||
|
const firstReturn = await processAnswer(incorrectAnswerRequestData);
|
||||||
|
|
||||||
|
hamjest.assertThat(firstReturn, hamjest.anyOf(
|
||||||
|
hamjest.is({
|
||||||
|
mode: "questions",
|
||||||
|
correct: false,
|
||||||
|
correctAnswers: [definitionOne],
|
||||||
|
currentVocabId: progressVocabOne,
|
||||||
|
moreAnswers: false,
|
||||||
|
nextPrompt: {
|
||||||
|
item: termOne,
|
||||||
|
sound: soundOne,
|
||||||
|
set_owner: userOne,
|
||||||
|
},
|
||||||
|
progress: 1,
|
||||||
|
totalQuestions: 3,
|
||||||
|
totalCorrect: 0,
|
||||||
|
totalIncorrect: 1,
|
||||||
|
typo: false,
|
||||||
|
}),
|
||||||
|
hamjest.is({
|
||||||
|
mode: "questions",
|
||||||
|
correct: false,
|
||||||
|
correctAnswers: [definitionOne],
|
||||||
|
currentVocabId: progressVocabOne,
|
||||||
|
moreAnswers: false,
|
||||||
|
nextPrompt: {
|
||||||
|
item: termTwo,
|
||||||
|
sound: soundTwo,
|
||||||
|
set_owner: userOne,
|
||||||
|
},
|
||||||
|
progress: 1,
|
||||||
|
totalQuestions: 3,
|
||||||
|
totalCorrect: 0,
|
||||||
|
totalIncorrect: 1,
|
||||||
|
typo: false,
|
||||||
|
})
|
||||||
|
));
|
||||||
|
|
||||||
|
const snapAfterIncorrectData = await progressDocId.get().then((doc) => doc.data());
|
||||||
|
|
||||||
|
hamjest.assertThat(snapAfterIncorrectData, hamjest.anyOf(
|
||||||
|
hamjest.is({
|
||||||
|
correct: [],
|
||||||
|
current_correct: [],
|
||||||
|
duration: null,
|
||||||
|
incorrect: [progressVocabOne],
|
||||||
|
progress: 1,
|
||||||
|
questions: [
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabTwo
|
||||||
|
],
|
||||||
|
set_title: setOne,
|
||||||
|
set_titles: [setOne],
|
||||||
|
start_time: 1627308670962,
|
||||||
|
switch_language: false,
|
||||||
|
uid: userOne,
|
||||||
|
mode: "questions",
|
||||||
|
typo: false,
|
||||||
|
setIds: [setOne],
|
||||||
|
}),
|
||||||
|
hamjest.is({
|
||||||
|
correct: [],
|
||||||
|
current_correct: [],
|
||||||
|
duration: null,
|
||||||
|
incorrect: [progressVocabOne],
|
||||||
|
progress: 1,
|
||||||
|
questions: [
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabTwo,
|
||||||
|
progressVocabOne
|
||||||
|
],
|
||||||
|
set_title: setOne,
|
||||||
|
set_titles: [setOne],
|
||||||
|
start_time: 1627308670962,
|
||||||
|
switch_language: false,
|
||||||
|
uid: userOne,
|
||||||
|
mode: "questions",
|
||||||
|
typo: false,
|
||||||
|
setIds: [setOne],
|
||||||
|
})
|
||||||
|
));
|
||||||
|
|
||||||
|
if (firstReturn.nextPrompt.item === termOne) {
|
||||||
|
await processAnswer(firstTermAnswerRequestData);
|
||||||
|
await processAnswer(secondTermAnswerRequestData);
|
||||||
|
} else {
|
||||||
|
await processAnswer(secondTermAnswerRequestData);
|
||||||
|
await processAnswer(firstTermAnswerRequestData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const snapAfterCorrectData = await progressDocId.get().then((doc) => doc.data());
|
||||||
|
|
||||||
|
hamjest.assertThat(snapAfterCorrectData.correct, hamjest.anyOf(
|
||||||
|
hamjest.is([progressVocabOne, progressVocabTwo]),
|
||||||
|
hamjest.is([progressVocabTwo, progressVocabOne])
|
||||||
|
));
|
||||||
|
hamjest.assertThat(snapAfterCorrectData.questions, hamjest.anyOf(
|
||||||
|
hamjest.is([progressVocabOne, progressVocabOne, progressVocabTwo]),
|
||||||
|
hamjest.is([progressVocabOne, progressVocabTwo, progressVocabOne])
|
||||||
|
));
|
||||||
|
assert.deepStrictEqual(snapAfterCorrectData.incorrect, [progressVocabOne]);
|
||||||
|
assert.deepStrictEqual(snapAfterCorrectData.current_correct, []);
|
||||||
|
assert.notStrictEqual(snapAfterCorrectData.duration, null);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.progress, 3);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.set_title, setOne);
|
||||||
|
assert.deepStrictEqual(snapAfterCorrectData.set_titles, [setOne]);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.start_time, 1627308670962);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.switch_language, false);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.uid, userOne);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.mode, "questions");
|
||||||
|
assert.strictEqual(snapAfterCorrectData.typo, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("processAnswer updates progress documents appropriately when correct and incorrect answers provided with ignore accents enabled", async () => {
|
||||||
|
const processAnswer = test.wrap(cloudFunctions.processAnswer);
|
||||||
|
|
||||||
|
const progressData = {
|
||||||
|
correct: [],
|
||||||
|
current_correct: [],
|
||||||
|
duration: null,
|
||||||
|
incorrect: [],
|
||||||
|
progress: 0,
|
||||||
|
questions: [
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabTwo
|
||||||
|
],
|
||||||
|
set_title: setOne,
|
||||||
|
set_titles: [setOne],
|
||||||
|
start_time: 1627308670962,
|
||||||
|
switch_language: false,
|
||||||
|
uid: userOne,
|
||||||
|
mode: "questions",
|
||||||
|
typo: false,
|
||||||
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: true,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
|
};
|
||||||
|
const termDataOne = {
|
||||||
|
"item": termOne,
|
||||||
|
"sound": soundOne,
|
||||||
|
};
|
||||||
|
const termDataTwo = {
|
||||||
|
"item": termTwo,
|
||||||
|
"sound": soundTwo,
|
||||||
|
};
|
||||||
|
const definitionDataOne = {
|
||||||
|
"item": definitionOne,
|
||||||
|
"sound": soundOne,
|
||||||
|
};
|
||||||
|
const definitionDataTwo = {
|
||||||
|
"item": definitionTwo,
|
||||||
|
"sound": soundTwo,
|
||||||
|
};
|
||||||
|
|
||||||
|
const progressId = "progress_01";
|
||||||
|
const progressDocId = firestore.collection("progress").doc(progressId);
|
||||||
|
|
||||||
|
await progressDocId.set(progressData);
|
||||||
|
await progressDocId.collection("terms").doc(progressVocabOne)
|
||||||
|
.set(termDataOne);
|
||||||
|
await progressDocId.collection("terms").doc(progressVocabTwo)
|
||||||
|
.set(termDataTwo);
|
||||||
|
await progressDocId.collection("definitions").doc(progressVocabOne)
|
||||||
|
.set(definitionDataOne);
|
||||||
|
await progressDocId.collection("definitions").doc(progressVocabTwo)
|
||||||
|
.set(definitionDataTwo);
|
||||||
|
|
||||||
|
const firstTermAnswerRequestData = {
|
||||||
|
progressId: progressId,
|
||||||
|
answer: definitionOne,
|
||||||
|
};
|
||||||
|
const secondTermAnswerRequestData = {
|
||||||
|
progressId: progressId,
|
||||||
|
answer: definitionTwo,
|
||||||
|
};
|
||||||
|
const incorrectAnswerRequestData = {
|
||||||
|
progressId: progressId,
|
||||||
|
answer: definitionOneWithAccents,
|
||||||
|
};
|
||||||
|
|
||||||
|
const firstReturn = await processAnswer(incorrectAnswerRequestData);
|
||||||
|
|
||||||
|
hamjest.assertThat(firstReturn, hamjest.anyOf(
|
||||||
|
hamjest.is({
|
||||||
|
mode: "questions",
|
||||||
|
correct: false,
|
||||||
|
correctAnswers: [definitionOne],
|
||||||
|
currentVocabId: progressVocabOne,
|
||||||
|
moreAnswers: false,
|
||||||
|
nextPrompt: {
|
||||||
|
item: termOne,
|
||||||
|
sound: soundOne,
|
||||||
|
set_owner: userOne,
|
||||||
|
},
|
||||||
|
progress: 1,
|
||||||
|
totalQuestions: 3,
|
||||||
|
totalCorrect: 0,
|
||||||
|
totalIncorrect: 1,
|
||||||
|
typo: false,
|
||||||
|
}),
|
||||||
|
hamjest.is({
|
||||||
|
mode: "questions",
|
||||||
|
correct: false,
|
||||||
|
correctAnswers: [definitionOne],
|
||||||
|
currentVocabId: progressVocabOne,
|
||||||
|
moreAnswers: false,
|
||||||
|
nextPrompt: {
|
||||||
|
item: termTwo,
|
||||||
|
sound: soundTwo,
|
||||||
|
set_owner: userOne,
|
||||||
|
},
|
||||||
|
progress: 1,
|
||||||
|
totalQuestions: 3,
|
||||||
|
totalCorrect: 0,
|
||||||
|
totalIncorrect: 1,
|
||||||
|
typo: false,
|
||||||
|
})
|
||||||
|
));
|
||||||
|
|
||||||
|
const snapAfterIncorrectData = await progressDocId.get().then((doc) => doc.data());
|
||||||
|
|
||||||
|
hamjest.assertThat(snapAfterIncorrectData, hamjest.anyOf(
|
||||||
|
hamjest.is({
|
||||||
|
correct: [],
|
||||||
|
current_correct: [],
|
||||||
|
duration: null,
|
||||||
|
incorrect: [progressVocabOne],
|
||||||
|
progress: 1,
|
||||||
|
questions: [
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabTwo
|
||||||
|
],
|
||||||
|
set_title: setOne,
|
||||||
|
set_titles: [setOne],
|
||||||
|
start_time: 1627308670962,
|
||||||
|
switch_language: false,
|
||||||
|
uid: userOne,
|
||||||
|
mode: "questions",
|
||||||
|
typo: false,
|
||||||
|
setIds: [setOne],
|
||||||
|
}),
|
||||||
|
hamjest.is({
|
||||||
|
correct: [],
|
||||||
|
current_correct: [],
|
||||||
|
duration: null,
|
||||||
|
incorrect: [progressVocabOne],
|
||||||
|
progress: 1,
|
||||||
|
questions: [
|
||||||
|
progressVocabOne,
|
||||||
|
progressVocabTwo,
|
||||||
|
progressVocabOne
|
||||||
|
],
|
||||||
|
set_title: setOne,
|
||||||
|
set_titles: [setOne],
|
||||||
|
start_time: 1627308670962,
|
||||||
|
switch_language: false,
|
||||||
|
uid: userOne,
|
||||||
|
mode: "questions",
|
||||||
|
typo: false,
|
||||||
|
setIds: [setOne],
|
||||||
|
})
|
||||||
|
));
|
||||||
|
|
||||||
|
if (firstReturn.nextPrompt.item === termOne) {
|
||||||
|
await processAnswer(firstTermAnswerRequestData);
|
||||||
|
await processAnswer(secondTermAnswerRequestData);
|
||||||
|
} else {
|
||||||
|
await processAnswer(secondTermAnswerRequestData);
|
||||||
|
await processAnswer(firstTermAnswerRequestData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const snapAfterCorrectData = await progressDocId.get().then((doc) => doc.data());
|
||||||
|
|
||||||
|
hamjest.assertThat(snapAfterCorrectData.correct, hamjest.anyOf(
|
||||||
|
hamjest.is([progressVocabOne, progressVocabTwo]),
|
||||||
|
hamjest.is([progressVocabTwo, progressVocabOne])
|
||||||
|
));
|
||||||
|
hamjest.assertThat(snapAfterCorrectData.questions, hamjest.anyOf(
|
||||||
|
hamjest.is([progressVocabOne, progressVocabOne, progressVocabTwo]),
|
||||||
|
hamjest.is([progressVocabOne, progressVocabTwo, progressVocabOne])
|
||||||
|
));
|
||||||
|
assert.deepStrictEqual(snapAfterCorrectData.incorrect, [progressVocabOne]);
|
||||||
|
assert.deepStrictEqual(snapAfterCorrectData.current_correct, []);
|
||||||
|
assert.notStrictEqual(snapAfterCorrectData.duration, null);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.progress, 3);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.set_title, setOne);
|
||||||
|
assert.deepStrictEqual(snapAfterCorrectData.set_titles, [setOne]);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.start_time, 1627308670962);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.switch_language, false);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.uid, userOne);
|
||||||
|
assert.strictEqual(snapAfterCorrectData.mode, "questions");
|
||||||
|
assert.strictEqual(snapAfterCorrectData.typo, false);
|
||||||
|
});
|
||||||
|
|
||||||
it("processAnswer returns correct data", async () => {
|
it("processAnswer returns correct data", async () => {
|
||||||
const processAnswer = test.wrap(cloudFunctions.processAnswer);
|
const processAnswer = test.wrap(cloudFunctions.processAnswer);
|
||||||
|
|
||||||
@@ -568,6 +954,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -653,6 +1042,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -846,6 +1238,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -907,6 +1302,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -958,6 +1356,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1007,6 +1408,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1058,6 +1462,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1109,6 +1516,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1160,6 +1570,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1209,6 +1622,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1260,6 +1676,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1311,6 +1730,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: true,
|
typo: true,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1364,6 +1786,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: true,
|
typo: true,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1421,6 +1846,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne, setTwo],
|
setIds: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1481,6 +1909,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne, setTwo],
|
setIds: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const completedProgressData = {
|
const completedProgressData = {
|
||||||
attempts: 1,
|
attempts: 1,
|
||||||
@@ -1554,6 +1985,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1625,6 +2059,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const groupOneData = {
|
const groupOneData = {
|
||||||
role: "owner",
|
role: "owner",
|
||||||
@@ -1700,6 +2137,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -1757,6 +2197,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
mode: "questions",
|
mode: "questions",
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne],
|
setIds: [setOne],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
"item": termOne,
|
"item": termOne,
|
||||||
@@ -2151,6 +2594,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne, setTwo],
|
setIds: [setOne, setTwo],
|
||||||
set_titles: [setOne, setTwo],
|
set_titles: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
term: termOne,
|
term: termOne,
|
||||||
@@ -2255,6 +2701,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
lives: 2,
|
lives: 2,
|
||||||
start_lives: 5,
|
start_lives: 5,
|
||||||
set_titles: [setOne, setTwo],
|
set_titles: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
term: termOne,
|
term: termOne,
|
||||||
@@ -2354,6 +2803,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
current_correct: [],
|
current_correct: [],
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne, setTwo],
|
setIds: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
term: termOne,
|
term: termOne,
|
||||||
@@ -2416,6 +2868,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
current_correct: [],
|
current_correct: [],
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne, setTwo],
|
setIds: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
term: termOne,
|
term: termOne,
|
||||||
@@ -2484,6 +2939,9 @@ describe("Parandum Cloud Functions", function () {
|
|||||||
current_correct: [],
|
current_correct: [],
|
||||||
typo: false,
|
typo: false,
|
||||||
setIds: [setOne, setTwo],
|
setIds: [setOne, setTwo],
|
||||||
|
ignoreAccents: false,
|
||||||
|
ignoreCaps: false,
|
||||||
|
showNumberOfAnswers: false,
|
||||||
};
|
};
|
||||||
const termDataOne = {
|
const termDataOne = {
|
||||||
term: termOne,
|
term: termOne,
|
||||||
|
|||||||
Reference in New Issue
Block a user