fix: open text number question logic evaluation (#6439)

This commit is contained in:
Piyush Gupta
2025-08-19 11:33:49 +05:30
committed by GitHub
parent 318f891540
commit 56e7106d6e
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -502,7 +502,11 @@ const getLeftOperandValue = (
const responseValue = data[leftOperand.value];
if (currentQuestion.type === "openText" && currentQuestion.inputType === "number") {
return Number(responseValue) || undefined;
if (responseValue === undefined) return undefined;
if (typeof responseValue === "string" && responseValue.trim() === "") return undefined;
const numberValue = typeof responseValue === "number" ? responseValue : Number(responseValue);
return isNaN(numberValue) ? undefined : numberValue;
}
if (currentQuestion.type === "multipleChoiceSingle" || currentQuestion.type === "multipleChoiceMulti") {
+5 -1
View File
@@ -99,7 +99,11 @@ const getLeftOperandValue = (
const responseValue = data[leftOperand.value];
if (currentQuestion.type === "openText" && currentQuestion.inputType === "number") {
return Number(responseValue) || undefined;
if (responseValue === undefined) return undefined;
if (typeof responseValue === "string" && responseValue.trim() === "") return undefined;
const numberValue = typeof responseValue === "number" ? responseValue : Number(responseValue);
return isNaN(numberValue) ? undefined : numberValue;
}
if (currentQuestion.type === "multipleChoiceSingle" || currentQuestion.type === "multipleChoiceMulti") {