예제 #1
0
  private void populateRecipientEmailsForGiver(
      CourseRoster roster,
      Map<String, List<StudentAttributes>> teamStudentTable,
      Set<String> recipientEmailsList,
      Map<String, Set<String>> responseCommentsAddedTable,
      FeedbackResponseCommentAttributes frc,
      FeedbackQuestionAttributes relatedQuestion,
      FeedbackResponseAttributes relatedResponse) {
    StudentAttributes giver = roster.getStudentForEmail(relatedResponse.giver);
    if (giver == null) {
      return;
    }

    if (frc.isVisibleTo(FeedbackParticipantType.GIVER)) {
      addRecipientEmailsToList(
          responseCommentsAddedTable,
          recipientEmailsList,
          frc.getId().toString(),
          relatedResponse.giver);
    }

    if (relatedQuestion.giverType == FeedbackParticipantType.TEAMS
        || frc.isVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) {
      addRecipientEmailsForTeam(
          teamStudentTable,
          recipientEmailsList,
          responseCommentsAddedTable,
          frc.getId().toString(),
          giver.team);
    }
  }
예제 #2
0
 private void populateRecipientEmailsForReceiver(
     CourseRoster roster,
     Map<String, List<StudentAttributes>> teamStudentTable,
     Set<String> recipientEmailsList,
     Map<String, Set<String>> responseCommentsAddedTable,
     FeedbackResponseCommentAttributes frc,
     FeedbackResponseAttributes relatedResponse) {
   if (frc.isVisibleTo(FeedbackParticipantType.RECEIVER)) {
     // recipientEmail is email
     if (roster.getStudentForEmail(relatedResponse.recipient) == null) {
       addRecipientEmailsForTeam(
           teamStudentTable,
           recipientEmailsList,
           responseCommentsAddedTable,
           frc.getId().toString(),
           relatedResponse.recipient);
     } else {
       addRecipientEmailsToList(
           responseCommentsAddedTable,
           recipientEmailsList,
           frc.getId().toString(),
           relatedResponse.recipient);
     }
   }
 }
예제 #3
0
 private void populateRecipientEmailsForTeamMember(
     CourseRoster roster,
     Map<String, List<StudentAttributes>> teamStudentTable,
     Set<String> recipientEmailsList,
     Map<String, Set<String>> responseCommentsAddedTable,
     FeedbackResponseCommentAttributes frc,
     FeedbackResponseAttributes relatedResponse) {
   if (frc.isVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS)) {
     StudentAttributes studentOfThisEmail = roster.getStudentForEmail(relatedResponse.recipient);
     if (studentOfThisEmail == null) {
       addRecipientEmailsForTeam(
           teamStudentTable,
           recipientEmailsList,
           responseCommentsAddedTable,
           frc.getId().toString(),
           relatedResponse.recipient);
     } else {
       addRecipientEmailsForTeam(
           teamStudentTable,
           recipientEmailsList,
           responseCommentsAddedTable,
           frc.getId().toString(),
           studentOfThisEmail.team);
     }
   }
 }
예제 #4
0
 private void populateRecipientEmailsForTeam(
     Set<String> recipientEmailList,
     CourseRoster roster,
     Map<String, List<StudentAttributes>> teamStudentTable,
     Map<String, Set<String>> studentCommentsAddedTable,
     CommentAttributes pendingComment) {
   String commentId = pendingComment.getCommentId().toString();
   if (pendingComment.isVisibleTo(CommentParticipantType.TEAM)) {
     if (pendingComment.recipientType == CommentParticipantType.PERSON) {
       for (String recipientEmail : pendingComment.recipients) {
         StudentAttributes student = roster.getStudentForEmail(recipientEmail);
         if (student == null) {
           continue;
         }
         addRecipientEmailsForTeam(
             teamStudentTable,
             recipientEmailList,
             studentCommentsAddedTable,
             commentId,
             student.team);
       }
     } else if (pendingComment.recipientType == CommentParticipantType.TEAM) {
       for (String team : pendingComment.recipients) {
         addRecipientEmailsForTeam(
             teamStudentTable, recipientEmailList, studentCommentsAddedTable, commentId, team);
       }
     }
   } else { // not visible to TEAM
     if (pendingComment.recipientType == CommentParticipantType.PERSON) {
       for (String recipientEmail : pendingComment.recipients) {
         StudentAttributes student = roster.getStudentForEmail(recipientEmail);
         if (student == null) {
           continue;
         }
         preventAddRecipientEmailsForTeam(
             teamStudentTable, studentCommentsAddedTable, commentId, student.team);
       }
     } else if (pendingComment.recipientType == CommentParticipantType.TEAM) {
       for (String team : pendingComment.recipients) {
         preventAddRecipientEmailsForTeam(
             teamStudentTable, studentCommentsAddedTable,
             commentId, team);
       }
     }
   }
 }
예제 #5
0
  @Test
  public void allTests() {

    ______TS("No students");

    CourseRoster roster = new CourseRoster(null, null);
    assertFalse(roster.isStudentInCourse("studentEmail"));

    ______TS("only 1 student, no instructors");

    roster = new CourseRoster(createStudentList("team 1", "*****@*****.**"), null);
    assertFalse(roster.isStudentInCourse("*****@*****.**"));
    assertTrue(roster.isStudentInCourse("*****@*****.**"));

    assertFalse(roster.isStudentInTeam("*****@*****.**", "team 1"));
    assertFalse(roster.isStudentInTeam("*****@*****.**", "team 123"));
    assertTrue(roster.isStudentInTeam("*****@*****.**", "team 1"));

    assertFalse(roster.isStudentsInSameTeam("*****@*****.**", "*****@*****.**"));
    assertFalse(roster.isStudentsInSameTeam("*****@*****.**", "*****@*****.**"));
    assertTrue(roster.isStudentsInSameTeam("*****@*****.**", "*****@*****.**"));

    assertEquals(roster.getStudentForEmail("*****@*****.**").email, "*****@*****.**");
    assertEquals(roster.getStudentForEmail("*****@*****.**").team, "team 1");
    assertEquals(roster.getInstructorForEmail("*****@*****.**"), null);

    ______TS("only 1 instructor, no students");

    roster = new CourseRoster(null, createInstructorList("John", "*****@*****.**"));
    assertEquals(roster.getInstructorForEmail("*****@*****.**").email, "*****@*****.**");
    assertEquals(roster.getInstructorForEmail("*****@*****.**").name, "John");

    assertEquals(roster.getInstructorForEmail("*****@*****.**"), null);

    ______TS("multiple students, multiple instructors");

    roster =
        new CourseRoster(
            createStudentList(
                "team 1", "*****@*****.**", "team 1", "*****@*****.**", "team 2", "*****@*****.**"),
            createInstructorList("John", "*****@*****.**", "Jean", "*****@*****.**"));

    assertFalse(roster.isStudentInCourse("*****@*****.**"));
    assertTrue(roster.isStudentInCourse("*****@*****.**"));

    assertFalse(roster.isStudentInTeam("*****@*****.**", "team 1"));
    assertFalse(roster.isStudentInTeam("*****@*****.**", "team 1"));
    assertTrue(roster.isStudentInTeam("*****@*****.**", "team 1"));
    assertTrue(roster.isStudentInTeam("*****@*****.**", "team 1"));
    assertTrue(roster.isStudentInTeam("*****@*****.**", "team 2"));

    assertFalse(roster.isStudentsInSameTeam("*****@*****.**", "*****@*****.**"));
    assertFalse(roster.isStudentsInSameTeam("*****@*****.**", "*****@*****.**"));
    assertTrue(roster.isStudentsInSameTeam("*****@*****.**", "*****@*****.**"));

    assertEquals(roster.getInstructorForEmail("*****@*****.**").email, "*****@*****.**");
    assertEquals(roster.getInstructorForEmail("*****@*****.**").name, "John");
    assertEquals(roster.getInstructorForEmail("*****@*****.**").email, "*****@*****.**");
    assertEquals(roster.getInstructorForEmail("*****@*****.**").name, "Jean");
  }
예제 #6
0
  public boolean isNameVisibleTo(
      FeedbackQuestionAttributes question,
      FeedbackResponseAttributes response,
      String userEmail,
      UserType.Role role,
      boolean isGiverName,
      CourseRoster roster) {

    if (question == null) {
      return false;
    }

    List<FeedbackParticipantType> showNameTo =
        isGiverName ? question.showGiverNameTo : question.showRecipientNameTo;

    // Giver can always see giver and recipient.(because he answered.)
    if (response.giverEmail.equals(userEmail)) {
      return true;
    }

    for (FeedbackParticipantType type : showNameTo) {
      switch (type) {
        case INSTRUCTORS:
          if (roster.getInstructorForEmail(userEmail) != null && role == UserType.Role.INSTRUCTOR) {
            return true;
          } else {
            break;
          }
        case OWN_TEAM_MEMBERS:
        case OWN_TEAM_MEMBERS_INCLUDING_SELF:
          // Refers to Giver's Team Members
          if (roster.isStudentsInSameTeam(response.giverEmail, userEmail)) {
            return true;
          } else {
            break;
          }
        case RECEIVER:
          // Response to team
          if (question.recipientType == FeedbackParticipantType.TEAMS) {
            if (roster.isStudentInTeam(
                userEmail, /* this is a team name */ response.recipientEmail)) {
              return true;
            }
            // Response to individual
          } else if (response.recipientEmail.equals(userEmail)) {
            return true;
          } else {
            break;
          }
        case RECEIVER_TEAM_MEMBERS:
          // Response to team; recipient = teamName
          if (question.recipientType == FeedbackParticipantType.TEAMS) {
            if (roster.isStudentInTeam(
                userEmail, /* this is a team name */ response.recipientEmail)) {
              return true;
            }
            // Response to individual
          } else if (roster.isStudentsInSameTeam(response.recipientEmail, userEmail)) {
            return true;
          } else {
            break;
          }
        case STUDENTS:
          if (roster.isStudentInCourse(userEmail)) {
            return true;
          } else {
            break;
          }
        default:
          Assumption.fail(
              "Invalid FeedbackPariticipantType for showNameTo in "
                  + "FeedbackResponseLogic.isNameVisible()");
          break;
      }
    }
    return false;
  }