a little bug – part 1

The Bug: Certain questions that were supposed to be included due to server-side logic were not being properly included.

There was an odd chain of events… The deeply embedded process (shown below) did not seem to behave properly. A couple of developers set about to test a bit more thoroughly. They discovered that the order of the choices for the questions that were supposed to be included affected whether they were successfully included or not. Mind you… there are only two choices: INCLUDE and EXCLUDE.

Context: The application is very loosely a Questionnaire app…. just so happens that some of the questions get processed by this third-party black box which determines if some of the questions should be required/included or not. Required in the sever process world means “included” in the UI world.

I’ll start you off with some code to peruse, full comments and all:

for each (var qstnTO : QuestionTO in processedQuestionArray) {

  for each (var qstn : QuestionVO in __localQuestionsToProcess) {

    if (qstn.questionID == qstnTO.questionID) {

        if (qstnTO.required) {

        for each (choice in qstn.choices) {

          choice.selected = (choice.displayText == "INCLUDE") ? true : false;

          changedQuestions.addItem(qstn);

          // ?? Not sure if the following is necessary or not

          choice.enabled  = true;

          choice.visible  = true;

          qstn.section.visible = true;

          qstn.section.enabled = true;

          // ??

          break;

        }

      }

    }

  }

Can you spot anything that might point to why the testers saw different behavior based on the order of choices?

I’ll be back later to elaborate…