Program: 62875
Project: 62875
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> emailTeamNameTable=new HashMap<String,String>();
  Map<String,boolean[]> visibilityTable=new HashMap<String,boolean[]>();
  Map<String,List<FeedbackResponseCommentAttributes>> responseComments=new HashMap<String,List<FeedbackResponseCommentAttributes>>();
  FeedbackSessionResponseStatus responseStatus=new FeedbackSessionResponseStatus();
  boolean isPrivateSessionNotCreatedByThisUser=session.isPrivateSession() && !session.isCreator(userEmail);
  if (isPrivateSessionNotCreatedByThisUser) {
    return new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,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);
        responses.addAll(responsesForThisQn);
        for (        FeedbackResponseAttributes response : responsesForThisQn) {
          addEmailNamePairsToTable(emailNameTable,response,question,roster);
          addEmailTeamNamePairsToTable(emailTeamNameTable,response,question,roster);
          addVisibilityToTable(visibilityTable,question,response,userEmail,roster);
        }
      }
    }
    FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments);
    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,allQuestionsMap,emailNameTable,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);
    }
  }
  for (  FeedbackResponseAttributes response : allResponses) {
    FeedbackQuestionAttributes relatedQuestion=allQuestionsMap.get(response.feedbackQuestionId);
    if (relatedQuestion != null) {
      Boolean isVisibleResponse=false;
      if ((response.giverEmail.equals(userEmail) && (section == null || response.recipientSection.equals(section))) || (response.recipientEmail.equals(userEmail) && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.RECEIVER) && (section == null || response.giverSection.equals(section))) || (role == Role.INSTRUCTOR && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS) && (section == null || (response.giverSection.equals(section) && response.recipientSection.equals(section))))|| (role == Role.STUDENT && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.STUDENTS))) {
        isVisibleResponse=true;
      }
 else       if (role == Role.STUDENT && ((relatedQuestion.recipientType == FeedbackParticipantType.TEAMS && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.RECEIVER) && response.recipientEmail.equals(student.team)) || ((relatedQuestion.giverType == FeedbackParticipantType.TEAMS || relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) && studentsEmailInTeam.contains(response.giverEmail)) || (relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS) && studentsEmailInTeam.contains(response.recipientEmail)))) {
        isVisibleResponse=true;
      }
      if (isVisibleResponse) {
        responses.add(response);
        relevantQuestions.put(relatedQuestion.getId(),relatedQuestion);
        addEmailNamePairsToTable(emailNameTable,response,relatedQuestion,roster);
        addEmailTeamNamePairsToTable(emailTeamNameTable,response,relatedQuestion,roster);
        addVisibilityToTable(visibilityTable,relatedQuestion,response,userEmail,roster);
      }
      isVisibleResponse=false;
    }
  }
  List<FeedbackResponseCommentAttributes> allResponseComments=frcLogic.getFeedbackResponseCommentForSession(courseId,feedbackSessionName);
  for (  FeedbackResponseCommentAttributes frc : allResponseComments) {
    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,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> emailTeamNameTable=new HashMap<String,String>();
  Map<String,boolean[]> visibilityTable=new HashMap<String,boolean[]>();
  Map<String,List<FeedbackResponseCommentAttributes>> responseComments=new HashMap<String,List<FeedbackResponseCommentAttributes>>();
  FeedbackSessionResponseStatus responseStatus=new FeedbackSessionResponseStatus();
  boolean isPrivateSessionNotCreatedByThisUser=session.isPrivateSession() && !session.isCreator(userEmail);
  if (isPrivateSessionNotCreatedByThisUser) {
    return new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,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);
        responses.addAll(responsesForThisQn);
        for (        FeedbackResponseAttributes response : responsesForThisQn) {
          addEmailNamePairsToTable(emailNameTable,response,question,roster);
          addEmailTeamNamePairsToTable(emailTeamNameTable,response,question,roster);
          addVisibilityToTable(visibilityTable,question,response,userEmail,roster);
        }
      }
    }
    FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,emailTeamNameTable,visibilityTable,responseStatus,responseComments);
    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) {
        if (qn.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS)) {
          relevantQuestions.put(qn.getId(),qn);
        }
      }
      FeedbackSessionResultsBundle results=new FeedbackSessionResultsBundle(session,responses,relevantQuestions,emailNameTable,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);
    }
  }
  for (  FeedbackResponseAttributes response : allResponses) {
    FeedbackQuestionAttributes relatedQuestion=allQuestionsMap.get(response.feedbackQuestionId);
    if (relatedQuestion != null) {
      Boolean isVisibleResponse=false;
      if ((response.giverEmail.equals(userEmail)) || (response.recipientEmail.equals(userEmail) && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) || (role == Role.INSTRUCTOR && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS))|| (role == Role.STUDENT && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.STUDENTS))) {
        isVisibleResponse=true;
      }
 else       if (role == Role.STUDENT && ((relatedQuestion.recipientType == FeedbackParticipantType.TEAMS && relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.RECEIVER) && response.recipientEmail.equals(student.team)) || ((relatedQuestion.giverType == FeedbackParticipantType.TEAMS || relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) && studentsEmailInTeam.contains(response.giverEmail)) || (relatedQuestion.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS) && studentsEmailInTeam.contains(response.recipientEmail)))) {
        isVisibleResponse=true;
      }
      if (isVisibleResponse) {
        responses.add(response);
        relevantQuestions.put(relatedQuestion.getId(),relatedQuestion);
        addEmailNamePairsToTable(emailNameTable,response,relatedQuestion,roster);
        addEmailTeamNamePairsToTable(emailTeamNameTable,response,relatedQuestion,roster);
        addVisibilityToTable(visibilityTable,relatedQuestion,response,userEmail,roster);
      }
      isVisibleResponse=false;
    }
  }
  List<FeedbackResponseCommentAttributes> allResponseComments=frcLogic.getFeedbackResponseCommentForSession(courseId,feedbackSessionName);
  for (  FeedbackResponseCommentAttributes frc : allResponseComments) {
    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,emailTeamNameTable,visibilityTable,responseStatus,responseComments,isComplete);
  return results;
}