Merge pull request #3247 from Savlik/dev

Accept valid JSON arrays in coding contracts
This commit is contained in:
hydroflame 2022-04-13 16:29:26 -04:00 committed by GitHub
commit 93eb5e2d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1121,14 +1121,17 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
dfs(0, 0, left, right, data, "", res); dfs(0, 0, left, right, data, "", res);
const sanitizedPlayerAns = removeBracketsFromArrayString(ans).replace(/\s/g, ""); const sanitizedPlayerAns: string = removeBracketsFromArrayString(ans);
const sanitizedPlayerAnsArr: string[] = sanitizedPlayerAns.split(",");
const playerAnsArray: string[] = sanitizedPlayerAns.split(","); for (let i = 0; i < sanitizedPlayerAnsArr.length; ++i) {
if (playerAnsArray.length !== res.length) { sanitizedPlayerAnsArr[i] = removeQuotesFromString(sanitizedPlayerAnsArr[i]).replace(/\s/g, "");
}
if (sanitizedPlayerAnsArr.length !== res.length) {
return false; return false;
} }
for (const resultInAnswer of res) { for (const resultInAnswer of res) {
if (!playerAnsArray.includes(resultInAnswer)) { if (!sanitizedPlayerAnsArr.includes(resultInAnswer)) {
return false; return false;
} }
} }