diff --git a/survey-frontend/src/ProgressBar.tsx b/survey-frontend/src/ProgressBar.tsx index 728abfc5c8ca5939245e8b1e5c06845c8100ebb8..25644d5505c2a5f55adff35b4455cee416aa1ac2 100644 --- a/survey-frontend/src/ProgressBar.tsx +++ b/survey-frontend/src/ProgressBar.tsx @@ -14,6 +14,18 @@ function ProgressBar({ surveyModel, pageNoSetter }) { const filterCallback = (question) => { + const typesWithLengthCheck = ["checkbox", "text","comment","multipletext"]; + if (typesWithLengthCheck.includes(question.getType())) { + if (question.value !== null && question.value !== undefined) { + if (question.value.length > 0) { + console.log("question.type len",question.getType()) + return true; // Non-empty array + } else if (Object.keys(question.value).length > 0 && question.getType()==="multipletext") { + return Object.values(question.value)[0]!== undefined; + }// Non-empty multitext object + } + return false; + } return question.value !== null && question.value !== undefined; }; @@ -31,6 +43,16 @@ function ProgressBar({ surveyModel, pageNoSetter }) { const answeredCount = sectionQuestions.filter(filterCallback).length; const unansweredCount = questionCount - answeredCount; const completionPercentage = answeredCount / questionCount; + // console.log("sectionQuestions:",sectionQuestions) + if(answeredCount>0){ + // console.log("answeredQuestion:",sectionQuestions.filter(filterCallback)) + // console.log("questionCount: ",questionCount) + // console.log("answeredCount: ",answeredCount) + } + + // console.log("unansweredCount: ",unansweredCount) + // console.log("completionPercentage: ",completionPercentage) + progressArray.push({