[FIX] createProgress compatibility

Wasn't previously fully backwards-compatible and its call hadn't been updated in all places
This commit is contained in:
2022-02-14 19:37:48 +00:00
parent 9c11bd2658
commit 18fd61721b
4 changed files with 37 additions and 6 deletions

View File

@@ -140,12 +140,12 @@ 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.ignoreCaps Whether capitalisation of answers should matter during the test. * @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".
* @param {array} data.sets An array of IDs of the desired sets. * @param {array} data.sets An array of IDs of the desired sets.
* @param {boolean} data.showNumberOfAnswers Whether the number of answers to each prompt should be * @param {boolean} data.showNumberOfAnswers Whether the number of answers to each prompt should be
* displayed to the user during the test. * displayed to the user during the test. Optional.
* @param {boolean} data.switch_language Whether or not the languages should be reversed. * @param {boolean} data.switch_language Whether or not the languages should be reversed.
* @return {string} The ID of the created progress document. * @return {string} The ID of the created progress document.
*/ */
@@ -169,12 +169,16 @@ exports.createProgress = functions.https.onCall((data, context) => {
throw new functions.https.HttpsError("invalid-argument", "switch_language must be a boolean"); throw new functions.https.HttpsError("invalid-argument", "switch_language must be a boolean");
} }
if (typeof data.ignoreCaps !== "boolean") { if (typeof data.ignoreCaps === "undefined") {
throw new functions.https.HttpsError("invalid-argument", "ignoreCaps must be a boolean"); data.ignoreCaps = false;
functions.logger.log("ignoreCaps not provided - using default value of false");
} else if (typeof data.ignoreCaps !== "boolean") {
throw new functions.https.HttpsError("invalid-argument", "showNumberOfAnswers must be a boolean");
} }
if (typeof data.showNumberOfAnswers === "undefined") { if (typeof data.showNumberOfAnswers === "undefined") {
data.showNumberOfAnswers = false; data.showNumberOfAnswers = false;
functions.logger.log("showNumberOfAnswers not provided - using default value of false");
} else if (typeof data.showNumberOfAnswers !== "boolean") { } else if (typeof data.showNumberOfAnswers !== "boolean") {
throw new functions.https.HttpsError("invalid-argument", "showNumberOfAnswers must be a boolean"); throw new functions.https.HttpsError("invalid-argument", "showNumberOfAnswers must be a boolean");
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "parandum", "name": "parandum",
"version": "2.1.6", "version": "2.1.7",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@babel/core": "^7.16.0", "@babel/core": "^7.16.0",

View File

@@ -133,7 +133,7 @@ export default withRouter(class Progress extends React.Component {
setComplete: data.duration !== null, setComplete: data.duration !== null,
pageLoaded: true, pageLoaded: true,
numberOfAnswers: data.showNumberOfAnswers ? 0 : null, numberOfAnswers: data.showNumberOfAnswers ? 0 : null,
ignoreCaps: data.ignoreCaps, ignoreCaps: data.ignoreCaps === true,
}; };
if (data.lives) { if (data.lives) {

View File

@@ -41,6 +41,11 @@ export default withRouter(class SearchSets extends Component {
showClassicTestStart: false, showClassicTestStart: false,
showLivesTestStart: false, showLivesTestStart: false,
searchInput: "", searchInput: "",
ignoreCaps: false,
showNumberOfAnswers: false,
switchLanguage: false,
sliderValue: 1,
totalTestQuestions: 1,
}; };
let isMounted = true; let isMounted = true;
@@ -134,6 +139,8 @@ export default withRouter(class SearchSets extends Component {
switch_language: this.state.switchLanguage, switch_language: this.state.switchLanguage,
mode: mode, mode: mode,
limit: this.state.sliderValue, limit: this.state.sliderValue,
ignoreCaps: this.state.ignoreCaps,
showNumberOfAnswers: this.state.showNumberOfAnswers,
}).then((result) => { }).then((result) => {
const progressId = result.data; const progressId = result.data;
this.stopLoading(); this.stopLoading();
@@ -238,6 +245,18 @@ export default withRouter(class SearchSets extends Component {
}); });
} }
handleIgnoreCapsChange = (event) => {
this.setState({
ignoreCaps: event.target.checked,
});
}
handleShowNumberOfAnswersChange = (event) => {
this.setState({
showNumberOfAnswers: event.target.checked,
});
}
handleSearchInput = (event) => { handleSearchInput = (event) => {
if (!this.state.loadingSets) { if (!this.state.loadingSets) {
this.setState({ this.setState({
@@ -336,7 +355,11 @@ export default withRouter(class SearchSets extends Component {
sliderValue={this.state.sliderValue} sliderValue={this.state.sliderValue}
onSliderChange={this.changeSliderValue} onSliderChange={this.changeSliderValue}
switchLanguage={this.state.switchLanguage} switchLanguage={this.state.switchLanguage}
ignoreCaps={this.state.ignoreCaps}
showNumberOfAnswers={this.state.showNumberOfAnswers}
handleSwitchLanguageChange={this.handleSwitchLanguageChange} handleSwitchLanguageChange={this.handleSwitchLanguageChange}
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
loading={this.state.loading} loading={this.state.loading}
/> />
} }
@@ -349,7 +372,11 @@ export default withRouter(class SearchSets extends Component {
sliderValue={this.state.sliderValue} sliderValue={this.state.sliderValue}
onSliderChange={this.changeSliderValue} onSliderChange={this.changeSliderValue}
switchLanguage={this.state.switchLanguage} switchLanguage={this.state.switchLanguage}
ignoreCaps={this.state.ignoreCaps}
showNumberOfAnswers={this.state.showNumberOfAnswers}
handleSwitchLanguageChange={this.handleSwitchLanguageChange} handleSwitchLanguageChange={this.handleSwitchLanguageChange}
handleIgnoreCapsChange={this.handleIgnoreCapsChange}
handleShowNumberOfAnswersChange={this.handleShowNumberOfAnswersChange}
loading={this.state.loading} loading={this.state.loading}
/> />
} }