Program: 62864
Project: 62864
Buggy source:
private FeedbackSessionResultsBundle getFeedbackSessionResultsForUserWithParams(String feedbackSessionName,String courseId,String userEmail,UserType.Role role,CourseRoster roster,Map<String,String> params) throws EntityDoesNotExistException {
  boolean isIncludeResponseStatus=Boolean.parseBoolean(params.get("String_Node_Str"));
  boolean isComplete=(params.get("String_Node_Str") != null) ? false : true;
  boolean isFromSection=Boolean.parseBoolean(params.get("String_Node_Str"));
  boolean isToSection=Boolean.parseBoolean(params.get("String_Node_Str"));
  boolean isInSection=Boolean.parseBoolean(params.get("String_Node_Str"));
  String section=params.get("String_Node_Str");
  FeedbackSessionAttributes session=fsDb.getFeedbackSession(courseId,feedbackSessionName);
  if (session == null) {
    throw new EntityDoesNotExistException("String_Node_Str");
  }
  List<FeedbackQuestionAttributes> allQuestions=fqLogic.getFeedbackQuestionsForSession(feedbackSessionName,courseId);
  List<FeedbackResponseAttributes> responses=new ArrayList<FeedbackResponseAttributes>();
  Map<String,FeedbackQuestionAttributes> relevantQuestions=new HashMap<String,FeedbackQuestionAttributes>();
  Map<String,String> emailNameTable=new HashMap<String,String>();
  Map<String,String> emailLastNameTable=new HashMap<String,String>();
  Map<String,String> emailTeamNameTable=new HashMap<String,String>();
  Map<String,boolean[]> visibilityTable=new HashMap<String,boolean[]>();
  Map<String,List<FeedbackResponseCommentAttributes>> responseComments=new HashMap<String,List<FeedbackResponseCommentAttributes>>();
  if (role == UserType.Role.INSTRUCTOR && !params.containsKey("String_Node_Str")) {
    for (    FeedbackQuestionAttributes question : allQuestions) {
      relevantQuestions.put(question.getId(),question);
    }
  }
  FeedbackSessionResponseStatus responseStatus=new FeedbackSessionResponseStatus();
  boolean isPrivateSessionNotCreatedByThisUser=session.isPrivateSession() && !session.isCreator(userEmail);
  if (isPrivateSessionNotCreatedByThisUser) {
    return new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments);
  }
  if (params.get("String_Node_Str") != null) {
    int questionNumber=Integer.parseInt(params.get("String_Node_Str"));
    FeedbackQuestionAttributes question=fqLogic.getFeedbackQuestion(feedbackSessionName,courseId,questionNumber);
    if (question != null) {
      List<FeedbackResponseAttributes> responsesForThisQn;
      boolean isPrivateSessionCreatedByThisUser=session.isCreator(userEmail) && session.isPrivateSession();
      if (isPrivateSessionCreatedByThisUser) {
        responsesForThisQn=frLogic.getFeedbackResponsesForQuestion(question.getId());
      }
 else {
        responsesForThisQn=frLogic.getViewableFeedbackResponsesForQuestionInSection(question,userEmail,Role.INSTRUCTOR,null);
      }
      boolean thisQuestionHasResponses=(!responsesForThisQn.isEmpty());
      if (thisQuestionHasResponses) {
        relevantQuestions.put(question.getId(),question);
        for (        FeedbackResponseAttributes response : responsesForThisQn) {
          boolean isVisibleResponse=false;
          if ((response.giverEmail.equals(userEmail)) || (response.recipientEmail.equals(userEmail) && question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) || (role == Role.INSTRUCTOR && question.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS))|| (role == Role.STUDENT && question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS))) {
            isVisibleResponse=true;
          }
          if (isVisibleResponse) {
            responses.add(response);
            addEmailNamePairsToTable(emailNameTable,response,question,roster);
            addEmailLastNamePairsToTable(emailLastNameTable,response,question,roster);
            addEmailTeamNamePairsToTable(emailTeamNameTable,response,question,roster);
            addVisibilityToTable(visibilityTable,question,response,userEmail,role,roster);
          }
          isVisibleResponse=false;
        }
      }
    }
    FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments,true);
    return results;
  }
  Map<String,FeedbackQuestionAttributes> allQuestionsMap=new HashMap<String,FeedbackQuestionAttributes>();
  for (  FeedbackQuestionAttributes qn : allQuestions) {
    allQuestionsMap.put(qn.getId(),qn);
  }
  List<FeedbackResponseAttributes> allResponses=new ArrayList<FeedbackResponseAttributes>();
  if (params.get("String_Node_Str") != null) {
    long range=Long.parseLong(params.get("String_Node_Str"));
    if (isInSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionInSectionWithinRange(feedbackSessionName,courseId,section,range);
    }
 else     if (isFromSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionFromSectionWithinRange(feedbackSessionName,courseId,section,range);
    }
 else     if (isToSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionToSectionWithinRange(feedbackSessionName,courseId,section,range);
    }
 else {
      Assumption.fail("String_Node_Str");
    }
    if (allResponses.size() <= range) {
      isComplete=true;
    }
 else {
      for (      FeedbackQuestionAttributes qn : allQuestions) {
        relevantQuestions.put(qn.getId(),qn);
      }
      FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments,isComplete);
      return results;
    }
  }
 else {
    if (isInSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionInSection(feedbackSessionName,courseId,section);
    }
 else     if (isFromSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionFromSection(feedbackSessionName,courseId,section);
    }
 else     if (isToSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionToSection(feedbackSessionName,courseId,section);
    }
 else {
      Assumption.fail("String_Node_Str");
    }
  }
  responseStatus=(section == null && isIncludeResponseStatus) ? getFeedbackSessionResponseStatus(session,roster,allQuestions,allResponses) : null;
  StudentAttributes student=null;
  Set<String> studentsEmailInTeam=new HashSet<String>();
  if (role == Role.STUDENT) {
    student=studentsLogic.getStudentForEmail(courseId,userEmail);
    List<StudentAttributes> studentsInTeam=studentsLogic.getStudentsForTeam(student.team,courseId);
    for (    StudentAttributes teammates : studentsInTeam) {
      studentsEmailInTeam.add(teammates.email);
    }
  }
  InstructorAttributes instructor=null;
  if (role == Role.INSTRUCTOR) {
    instructor=instructorsLogic.getInstructorForEmail(courseId,userEmail);
  }
  Map<String,FeedbackResponseAttributes> relevantResponse=new HashMap<String,FeedbackResponseAttributes>();
  for (  FeedbackResponseAttributes response : allResponses) {
    FeedbackQuestionAttributes relatedQuestion=allQuestionsMap.get(response.feedbackQuestionId);
    if (relatedQuestion != null) {
      boolean isVisibleResponse=isResponseVisibleForUser(userEmail,courseId,role,section,student,studentsEmailInTeam,response,relatedQuestion,instructor);
      if (isVisibleResponse) {
        responses.add(response);
        relevantResponse.put(response.getId(),response);
        relevantQuestions.put(relatedQuestion.getId(),relatedQuestion);
        addEmailNamePairsToTable(emailNameTable,response,relatedQuestion,roster);
        addEmailLastNamePairsToTable(emailLastNameTable,response,relatedQuestion,roster);
        addEmailTeamNamePairsToTable(emailTeamNameTable,response,relatedQuestion,roster);
        addVisibilityToTable(visibilityTable,relatedQuestion,response,userEmail,role,roster);
      }
      isVisibleResponse=false;
    }
  }
  if (params.get("String_Node_Str") == null || params.get("String_Node_Str").equals("String_Node_Str") || params.get("String_Node_Str").equals("String_Node_Str")) {
    List<FeedbackResponseCommentAttributes> allResponseComments=frcLogic.getFeedbackResponseCommentForSessionInSection(courseId,feedbackSessionName,section);
    for (    FeedbackResponseCommentAttributes frc : allResponseComments) {
      FeedbackResponseAttributes relatedResponse=relevantResponse.get(frc.feedbackResponseId);
      FeedbackQuestionAttributes relatedQuestion=relevantQuestions.get(frc.feedbackQuestionId);
      boolean isVisibleResponseComment=frcLogic.isResponseCommentVisibleForUser(userEmail,courseId,role,section,student,studentsEmailInTeam,relatedResponse,relatedQuestion,frc,instructor);
      if (isVisibleResponseComment) {
        if (!frcLogic.isNameVisibleTo(frc,relatedResponse,userEmail,roster)) {
          frc.giverEmail="String_Node_Str";
        }
        List<FeedbackResponseCommentAttributes> frcList=responseComments.get(frc.feedbackResponseId);
        if (frcList == null) {
          frcList=new ArrayList<FeedbackResponseCommentAttributes>();
          frcList.add(frc);
          responseComments.put(frc.feedbackResponseId,frcList);
        }
 else {
          frcList.add(frc);
        }
      }
    }
    for (    List<FeedbackResponseCommentAttributes> responseCommentList : responseComments.values()) {
      Collections.sort(responseCommentList,new ResponseCommentCreationDateComparator());
    }
  }
  FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments,isComplete);
  return results;
}

Fixed version (ground truth):
private FeedbackSessionResultsBundle getFeedbackSessionResultsForUserWithParams(String feedbackSessionName,String courseId,String userEmail,UserType.Role role,CourseRoster roster,Map<String,String> params) throws EntityDoesNotExistException {
  boolean isIncludeResponseStatus=Boolean.parseBoolean(params.get("String_Node_Str"));
  boolean isComplete=(params.get("String_Node_Str") != null) ? false : true;
  boolean isFromSection=Boolean.parseBoolean(params.get("String_Node_Str"));
  boolean isToSection=Boolean.parseBoolean(params.get("String_Node_Str"));
  boolean isInSection=Boolean.parseBoolean(params.get("String_Node_Str"));
  String section=params.get("String_Node_Str");
  FeedbackSessionAttributes session=fsDb.getFeedbackSession(courseId,feedbackSessionName);
  if (session == null) {
    throw new EntityDoesNotExistException("String_Node_Str");
  }
  List<FeedbackQuestionAttributes> allQuestions=fqLogic.getFeedbackQuestionsForSession(feedbackSessionName,courseId);
  List<FeedbackResponseAttributes> responses=new ArrayList<FeedbackResponseAttributes>();
  Map<String,FeedbackQuestionAttributes> relevantQuestions=new HashMap<String,FeedbackQuestionAttributes>();
  Map<String,String> emailNameTable=new HashMap<String,String>();
  Map<String,String> emailLastNameTable=new HashMap<String,String>();
  Map<String,String> emailTeamNameTable=new HashMap<String,String>();
  Map<String,boolean[]> visibilityTable=new HashMap<String,boolean[]>();
  Map<String,List<FeedbackResponseCommentAttributes>> responseComments=new HashMap<String,List<FeedbackResponseCommentAttributes>>();
  if (role == UserType.Role.INSTRUCTOR && !params.containsKey("String_Node_Str")) {
    for (    FeedbackQuestionAttributes question : allQuestions) {
      relevantQuestions.put(question.getId(),question);
    }
  }
  FeedbackSessionResponseStatus responseStatus=new FeedbackSessionResponseStatus();
  boolean isPrivateSessionNotCreatedByThisUser=session.isPrivateSession() && !session.isCreator(userEmail);
  if (isPrivateSessionNotCreatedByThisUser) {
    return new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments);
  }
  if (params.get("String_Node_Str") != null) {
    int questionNumber=Integer.parseInt(params.get("String_Node_Str"));
    FeedbackQuestionAttributes question=fqLogic.getFeedbackQuestion(feedbackSessionName,courseId,questionNumber);
    if (question != null) {
      List<FeedbackResponseAttributes> responsesForThisQn;
      boolean isPrivateSessionCreatedByThisUser=session.isCreator(userEmail) && session.isPrivateSession();
      if (isPrivateSessionCreatedByThisUser) {
        responsesForThisQn=frLogic.getFeedbackResponsesForQuestion(question.getId());
      }
 else {
        responsesForThisQn=frLogic.getViewableFeedbackResponsesForQuestionInSection(question,userEmail,Role.INSTRUCTOR,null);
      }
      boolean thisQuestionHasResponses=(!responsesForThisQn.isEmpty());
      if (thisQuestionHasResponses) {
        relevantQuestions.put(question.getId(),question);
        for (        FeedbackResponseAttributes response : responsesForThisQn) {
          boolean isVisibleResponse=false;
          if ((response.giverEmail.equals(userEmail)) || (response.recipientEmail.equals(userEmail) && question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) || (role == Role.INSTRUCTOR && question.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS))|| (role == Role.STUDENT && question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS))) {
            isVisibleResponse=true;
          }
          InstructorAttributes instructor=null;
          if (role == Role.INSTRUCTOR) {
            instructor=instructorsLogic.getInstructorForEmail(courseId,userEmail);
          }
          if (isVisibleResponse && instructor != null) {
            if (!(instructor.isAllowedForPrivilege(response.giverSection,response.feedbackSessionName,Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS)) || !(instructor.isAllowedForPrivilege(response.giverSection,response.feedbackSessionName,Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS))) {
              isVisibleResponse=false;
            }
          }
          if (isVisibleResponse) {
            responses.add(response);
            addEmailNamePairsToTable(emailNameTable,response,question,roster);
            addEmailLastNamePairsToTable(emailLastNameTable,response,question,roster);
            addEmailTeamNamePairsToTable(emailTeamNameTable,response,question,roster);
            addVisibilityToTable(visibilityTable,question,response,userEmail,role,roster);
          }
          isVisibleResponse=false;
        }
      }
    }
    FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments,true);
    return results;
  }
  Map<String,FeedbackQuestionAttributes> allQuestionsMap=new HashMap<String,FeedbackQuestionAttributes>();
  for (  FeedbackQuestionAttributes qn : allQuestions) {
    allQuestionsMap.put(qn.getId(),qn);
  }
  List<FeedbackResponseAttributes> allResponses=new ArrayList<FeedbackResponseAttributes>();
  if (params.get("String_Node_Str") != null) {
    long range=Long.parseLong(params.get("String_Node_Str"));
    if (isInSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionInSectionWithinRange(feedbackSessionName,courseId,section,range);
    }
 else     if (isFromSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionFromSectionWithinRange(feedbackSessionName,courseId,section,range);
    }
 else     if (isToSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionToSectionWithinRange(feedbackSessionName,courseId,section,range);
    }
 else {
      Assumption.fail("String_Node_Str");
    }
    if (allResponses.size() <= range) {
      isComplete=true;
    }
 else {
      for (      FeedbackQuestionAttributes qn : allQuestions) {
        relevantQuestions.put(qn.getId(),qn);
      }
      FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments,isComplete);
      return results;
    }
  }
 else {
    if (isInSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionInSection(feedbackSessionName,courseId,section);
    }
 else     if (isFromSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionFromSection(feedbackSessionName,courseId,section);
    }
 else     if (isToSection) {
      allResponses=frLogic.getFeedbackResponsesForSessionToSection(feedbackSessionName,courseId,section);
    }
 else {
      Assumption.fail("String_Node_Str");
    }
  }
  responseStatus=(section == null && isIncludeResponseStatus) ? getFeedbackSessionResponseStatus(session,roster,allQuestions,allResponses) : null;
  StudentAttributes student=null;
  Set<String> studentsEmailInTeam=new HashSet<String>();
  if (role == Role.STUDENT) {
    student=studentsLogic.getStudentForEmail(courseId,userEmail);
    List<StudentAttributes> studentsInTeam=studentsLogic.getStudentsForTeam(student.team,courseId);
    for (    StudentAttributes teammates : studentsInTeam) {
      studentsEmailInTeam.add(teammates.email);
    }
  }
  InstructorAttributes instructor=null;
  if (role == Role.INSTRUCTOR) {
    instructor=instructorsLogic.getInstructorForEmail(courseId,userEmail);
  }
  Map<String,FeedbackResponseAttributes> relevantResponse=new HashMap<String,FeedbackResponseAttributes>();
  for (  FeedbackResponseAttributes response : allResponses) {
    FeedbackQuestionAttributes relatedQuestion=allQuestionsMap.get(response.feedbackQuestionId);
    if (relatedQuestion != null) {
      boolean isVisibleResponse=isResponseVisibleForUser(userEmail,courseId,role,section,student,studentsEmailInTeam,response,relatedQuestion,instructor);
      if (isVisibleResponse) {
        responses.add(response);
        relevantResponse.put(response.getId(),response);
        relevantQuestions.put(relatedQuestion.getId(),relatedQuestion);
        addEmailNamePairsToTable(emailNameTable,response,relatedQuestion,roster);
        addEmailLastNamePairsToTable(emailLastNameTable,response,relatedQuestion,roster);
        addEmailTeamNamePairsToTable(emailTeamNameTable,response,relatedQuestion,roster);
        addVisibilityToTable(visibilityTable,relatedQuestion,response,userEmail,role,roster);
      }
      isVisibleResponse=false;
    }
  }
  if (params.get("String_Node_Str") == null || params.get("String_Node_Str").equals("String_Node_Str") || params.get("String_Node_Str").equals("String_Node_Str")) {
    List<FeedbackResponseCommentAttributes> allResponseComments=frcLogic.getFeedbackResponseCommentForSessionInSection(courseId,feedbackSessionName,section);
    for (    FeedbackResponseCommentAttributes frc : allResponseComments) {
      FeedbackResponseAttributes relatedResponse=relevantResponse.get(frc.feedbackResponseId);
      FeedbackQuestionAttributes relatedQuestion=relevantQuestions.get(frc.feedbackQuestionId);
      boolean isVisibleResponseComment=frcLogic.isResponseCommentVisibleForUser(userEmail,courseId,role,section,student,studentsEmailInTeam,relatedResponse,relatedQuestion,frc,instructor);
      if (isVisibleResponseComment) {
        if (!frcLogic.isNameVisibleTo(frc,relatedResponse,userEmail,roster)) {
          frc.giverEmail="String_Node_Str";
        }
        List<FeedbackResponseCommentAttributes> frcList=responseComments.get(frc.feedbackResponseId);
        if (frcList == null) {
          frcList=new ArrayList<FeedbackResponseCommentAttributes>();
          frcList.add(frc);
          responseComments.put(frc.feedbackResponseId,frcList);
        }
 else {
          frcList.add(frc);
        }
      }
    }
    for (    List<FeedbackResponseCommentAttributes> responseCommentList : responseComments.values()) {
      Collections.sort(responseCommentList,new ResponseCommentCreationDateComparator());
    }
  }
  FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailLastNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments,isComplete);
  return results;
}