Search in sources :

Example 11 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildResponseRowsForQuestion.

/**
 * Builds response rows for a given question. This not only builds response rows for existing responses, but includes
 * the missing responses between pairs of givers and recipients.
 * @param responses  existing responses for the question
 */
private List<InstructorFeedbackResultsResponseRow> buildResponseRowsForQuestion(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses) {
    List<InstructorFeedbackResultsResponseRow> responseRows = new ArrayList<>();
    List<String> possibleGiversWithoutResponses = bundle.getPossibleGivers(question);
    List<String> possibleReceiversWithoutResponsesForGiver = new ArrayList<>();
    String prevGiver = "";
    int responseRecipientIndex = 0;
    int responseGiverIndex = 0;
    int userIndex = 0;
    Map<String, Integer> userIndexesForComments = new HashMap<String, Integer>();
    for (FeedbackResponseAttributes response : responses) {
        if (!bundle.isGiverVisible(response) || !bundle.isRecipientVisible(response)) {
            possibleGiversWithoutResponses.clear();
            possibleReceiversWithoutResponsesForGiver.clear();
        }
        // keep track of possible givers who did not give a response
        removeParticipantIdentifierFromList(possibleGiversWithoutResponses, response.giver);
        boolean isNewGiver = !prevGiver.equals(response.giver);
        if (isNewGiver) {
            if (isMissingResponsesShown) {
                responseRows.addAll(buildMissingResponseRowsBetweenGiverAndPossibleRecipients(question, possibleReceiversWithoutResponsesForGiver, prevGiver, bundle.getNameForEmail(prevGiver), bundle.getTeamNameForEmail(prevGiver)));
            }
            String giverIdentifier = response.giver;
            possibleReceiversWithoutResponsesForGiver = bundle.getPossibleRecipients(question, giverIdentifier);
        }
        // keep track of possible recipients without a response from the current giver
        removeParticipantIdentifierFromList(possibleReceiversWithoutResponsesForGiver, response.recipient);
        prevGiver = response.giver;
        InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForExistingResponse(question, response);
        InstructorFeedbackResultsResponseRow responseRow = new InstructorFeedbackResultsResponseRow(bundle.getGiverNameForResponse(response), bundle.getTeamNameForEmail(response.giver), bundle.getRecipientNameForResponse(response), bundle.getTeamNameForEmail(response.recipient), bundle.getResponseAnswerHtml(response, question), moderationButton);
        configureResponseRow(prevGiver, response.recipient, responseRow);
        String giverName = bundle.getNameForEmail(response.giver);
        String recipientName = bundle.getNameForEmail(response.recipient);
        String giverTeam = bundle.getTeamNameForEmail(response.giver);
        String recipientTeam = bundle.getTeamNameForEmail(response.recipient);
        giverName = bundle.appendTeamNameToName(giverName, giverTeam);
        recipientName = bundle.appendTeamNameToName(recipientName, recipientTeam);
        List<FeedbackResponseCommentRow> comments = buildResponseComments(giverName, recipientName, question, response);
        if (!comments.isEmpty()) {
            responseRow.setCommentsOnResponses(comments);
        }
        Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
        boolean isCommentsOnResponsesAllowed = question.getQuestionDetails().isCommentsOnResponsesAllowed();
        if (isCommentsOnResponsesAllowed) {
            FeedbackResponseCommentRow addCommentForm = buildFeedbackResponseCommentAddForm(question, response, responseVisibilityMap, giverName, recipientName);
            responseRow.setAddCommentButton(addCommentForm);
            if (userIndexesForComments.get(response.giver) == null) {
                userIndex = generateIndexForUser(response.giver, userIndex, userIndexesForComments);
            }
            responseGiverIndex = userIndexesForComments.get(response.giver);
            if (userIndexesForComments.get(response.recipient) == null) {
                userIndex = generateIndexForUser(response.recipient, userIndex, userIndexesForComments);
            }
            responseRecipientIndex = userIndexesForComments.get(response.recipient);
            responseRow.setResponseRecipientIndex(responseRecipientIndex);
            responseRow.setResponseGiverIndex(responseGiverIndex);
            responseRow.setCommentsOnResponsesAllowed(isCommentsOnResponsesAllowed);
        }
        responseRows.add(responseRow);
    }
    if (!responses.isEmpty()) {
        responseRows.addAll(getRemainingMissingResponseRows(question, possibleGiversWithoutResponses, possibleReceiversWithoutResponsesForGiver, prevGiver));
    }
    return responseRows;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton)

Example 12 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackResponseCommentsLogic method isFeedbackParticipantNameVisibleToUser.

private boolean isFeedbackParticipantNameVisibleToUser(FeedbackResponseAttributes response, String userEmail, CourseRoster roster, List<FeedbackParticipantType> showNameTo) {
    String responseGiverTeam = "giverTeam";
    if (roster.getStudentForEmail(response.giver) != null) {
        responseGiverTeam = roster.getStudentForEmail(response.giver).team;
    }
    String responseRecipientTeam = "recipientTeam";
    if (roster.getStudentForEmail(response.recipient) != null) {
        responseRecipientTeam = roster.getStudentForEmail(response.recipient).team;
    }
    String currentUserTeam = "currentUserTeam";
    if (roster.getStudentForEmail(userEmail) != null) {
        currentUserTeam = roster.getStudentForEmail(userEmail).team;
    }
    for (FeedbackParticipantType type : showNameTo) {
        switch(type) {
            case INSTRUCTORS:
                if (roster.getInstructorForEmail(userEmail) != null) {
                    return true;
                }
                break;
            case OWN_TEAM_MEMBERS:
                if (responseGiverTeam.equals(currentUserTeam)) {
                    return true;
                }
                break;
            case RECEIVER:
                if (userEmail.equals(response.recipient)) {
                    return true;
                }
                break;
            case RECEIVER_TEAM_MEMBERS:
                if (responseRecipientTeam.equals(currentUserTeam)) {
                    return true;
                }
                break;
            case STUDENTS:
                if (roster.getStudentForEmail(userEmail) != null) {
                    return true;
                }
                break;
            case GIVER:
                if (userEmail.equals(response.giver)) {
                    return true;
                }
                break;
            default:
                break;
        }
    }
    return false;
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 13 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class InstructorFeedbackEditPageDataTest method verifyMapContains.

private void verifyMapContains(Map<String, Boolean> map, List<FeedbackParticipantType> list) {
    for (FeedbackParticipantType participant : list) {
        assertTrue(map.get(participant.name()));
    }
    Set<FeedbackParticipantType> nonParticipants = new HashSet<>(Arrays.asList(FeedbackParticipantType.values()));
    nonParticipants.removeAll(list);
    for (FeedbackParticipantType nonParticipant : nonParticipants) {
        assertFalse(map.containsKey(nonParticipant.name()));
    }
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) HashSet(java.util.HashSet)

Example 14 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackQuestionAttributesTest method testRemoveIrrelevantVisibilityOptions.

@Test
public void testRemoveIrrelevantVisibilityOptions() {
    ______TS("test teams->none");
    FeedbackQuestionAttributes question = new FeedbackQuestionAttributes();
    List<FeedbackParticipantType> participants = new ArrayList<>();
    question.feedbackSessionName = "test session";
    question.courseId = "some course";
    question.creatorEmail = "test@case.com";
    question.questionMetaData = new Text("test qn from teams->none.");
    question.questionNumber = 1;
    question.questionType = FeedbackQuestionType.TEXT;
    question.giverType = FeedbackParticipantType.TEAMS;
    question.recipientType = FeedbackParticipantType.NONE;
    question.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertTrue(question.showGiverNameTo.isEmpty());
    assertTrue(question.showRecipientNameTo.isEmpty());
    // check that other types are not removed
    assertTrue(question.showResponsesTo.contains(FeedbackParticipantType.STUDENTS));
    assertEquals(question.showResponsesTo.size(), 1);
    ______TS("test students->teams");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.TEAMS;
    participants.clear();
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    question.showGiverNameTo = new ArrayList<>(participants);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 2);
    assertEquals(question.showRecipientNameTo.size(), 3);
    assertEquals(question.showResponsesTo.size(), 3);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    ______TS("test students->team members including giver");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF;
    participants.clear();
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    question.showGiverNameTo = new ArrayList<>(participants);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 3);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF));
    ______TS("test students->instructors");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.INSTRUCTORS;
    participants.clear();
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 4);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    ______TS("test students->own team");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.OWN_TEAM;
    participants.clear();
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 4);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    ______TS("test students->own team members");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS;
    participants.clear();
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 4);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
}
Also used : ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) Test(org.testng.annotations.Test)

Example 15 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackQuestionEditForm method getDefaultVisibilityOptions.

private static FeedbackQuestionVisibilitySettings getDefaultVisibilityOptions() {
    Map<String, Boolean> isGiverNameVisible = new HashMap<>();
    Map<String, Boolean> isRecipientNameVisible = new HashMap<>();
    Map<String, Boolean> isResponsesVisible = new HashMap<>();
    FeedbackParticipantType[] participantTypes = { FeedbackParticipantType.INSTRUCTORS, FeedbackParticipantType.RECEIVER };
    for (FeedbackParticipantType participant : participantTypes) {
        isGiverNameVisible.put(participant.name(), true);
        isRecipientNameVisible.put(participant.name(), true);
        isResponsesVisible.put(participant.name(), true);
    }
    return new FeedbackQuestionVisibilitySettings(new ArrayList<String>(), isResponsesVisible, isGiverNameVisible, isRecipientNameVisible, "Please select a visibility option <span class='caret'></span>");
}
Also used : HashMap(java.util.HashMap) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Aggregations

FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)25 ArrayList (java.util.ArrayList)8 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)8 HashMap (java.util.HashMap)7 Text (com.google.appengine.api.datastore.Text)4 LinkedHashMap (java.util.LinkedHashMap)4 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)4 Map (java.util.Map)3 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 StudentResultSummary (teammates.common.datatransfer.StudentResultSummary)2 TeamEvalResult (teammates.common.datatransfer.TeamEvalResult)2 DecimalFormat (java.text.DecimalFormat)1 Matcher (java.util.regex.Matcher)1 WebElement (org.openqa.selenium.WebElement)1 Test (org.testng.annotations.Test)1 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)1