Ejemplo n.º 1
0
  public List<FeedbackResponseAttributes> getViewableFeedbackResponsesForQuestionInSection(
      FeedbackQuestionAttributes question, String userEmail, UserType.Role role, String section)
      throws EntityDoesNotExistException {

    List<FeedbackResponseAttributes> viewableResponses =
        new ArrayList<FeedbackResponseAttributes>();

    // Add responses that the user submitted himself
    addNewResponses(
        viewableResponses,
        getFeedbackResponsesFromGiverForQuestionInSection(question.getId(), userEmail, section));

    // Add responses that user is a receiver of when question is visible to
    // receiver.
    if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) {
      addNewResponses(
          viewableResponses,
          getFeedbackResponsesForReceiverForQuestionInSection(
              question.getId(), userEmail, section));
    }

    switch (role) {
      case STUDENT:
        addNewResponses(
            viewableResponses,
            // many queries
            getViewableFeedbackResponsesForStudentForQuestion(question, userEmail));
        break;
      case INSTRUCTOR:
        if (question.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS)) {
          addNewResponses(
              viewableResponses,
              getFeedbackResponsesForQuestionInSection(question.getId(), section));
        }
        break;
      default:
        Assumption.fail("The role of the requesting use has to be Student or Instructor");
    }

    return viewableResponses;
  }
Ejemplo n.º 2
0
  private List<FeedbackResponseAttributes> getViewableFeedbackResponsesForStudentForQuestion(
      FeedbackQuestionAttributes question, String studentEmail) {

    List<FeedbackResponseAttributes> viewableResponses =
        new ArrayList<FeedbackResponseAttributes>();

    StudentAttributes student = studentsLogic.getStudentForEmail(question.courseId, studentEmail);

    if (question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS)) {
      addNewResponses(viewableResponses, getFeedbackResponsesForQuestion(question.getId()));

      // Early return as STUDENTS covers all other student types.
      return viewableResponses;
    }

    if (question.recipientType == FeedbackParticipantType.TEAMS
        && question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) {
      addNewResponses(
          viewableResponses,
          getFeedbackResponsesForReceiverForQuestion(question.getId(), student.team));
    }

    if (question.giverType == FeedbackParticipantType.TEAMS
        || question.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) {
      addNewResponses(
          viewableResponses,
          getFeedbackResponsesFromTeamForQuestion(
              question.getId(), question.courseId, student.team));
    }
    if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS)) {
      addNewResponses(
          viewableResponses,
          getFeedbackResponsesForTeamMembersOfStudent(question.getId(), student));
    }

    return viewableResponses;
  }