Search in sources :

Example 81 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackSessionResultsBundle method hideResponsesGiverRecipient.

/**
 * Hides response names/emails and teams that are not visible to the current user.
 * Replaces the giver/recipient email in responses to an email with two "@@"s
 * to indicate it is invalid and should not be displayed.
 */
private void hideResponsesGiverRecipient() {
    for (FeedbackResponseAttributes response : responses) {
        // Hide recipient details if its not visible to the current user
        String name = emailNameTable.get(response.recipient);
        FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
        FeedbackParticipantType participantType = question.recipientType;
        if (participantType == FeedbackParticipantType.SELF) {
            // recipient type for self-feedback is the same as the giver type
            participantType = question.giverType;
        }
        if (!isRecipientVisible(response)) {
            String anonEmail = getAnonEmail(participantType, name);
            name = getAnonName(participantType, name);
            emailNameTable.put(anonEmail, name);
            emailTeamNameTable.put(anonEmail, name + Const.TEAM_OF_EMAIL_OWNER);
            response.recipient = anonEmail;
        }
        // Hide giver details if its not visible to the current user
        name = emailNameTable.get(response.giver);
        participantType = question.giverType;
        if (!isGiverVisible(response)) {
            String anonEmail = getAnonEmail(participantType, name);
            name = getAnonName(participantType, name);
            emailNameTable.put(anonEmail, name);
            emailTeamNameTable.put(anonEmail, name + Const.TEAM_OF_EMAIL_OWNER);
            if (participantType == FeedbackParticipantType.TEAMS) {
                emailTeamNameTable.put(anonEmail, name);
            }
            response.giver = anonEmail;
        }
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 82 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackSessionResultsBundle method getResponsesSortedByRecipient.

public Map<String, Map<String, List<FeedbackResponseAttributes>>> getResponsesSortedByRecipient(boolean sortByTeam) {
    Map<String, Map<String, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
    if (sortByTeam) {
        responses.sort(compareByTeamRecipientGiverQuestion);
    } else {
        responses.sort(compareByRecipientGiverQuestion);
    }
    for (FeedbackResponseAttributes response : responses) {
        String recipientName = this.getRecipientNameForResponse(response);
        String recipientTeamName = this.getTeamNameForEmail(response.recipient);
        String recipientNameWithTeam = this.appendTeamNameToName(recipientName, recipientTeamName);
        Map<String, List<FeedbackResponseAttributes>> responsesToOneRecipient = sortedMap.computeIfAbsent(recipientNameWithTeam, key -> new LinkedHashMap<>());
        String giverName = this.getGiverNameForResponse(response);
        String giverTeamName = this.getTeamNameForEmail(response.giver);
        String giverNameWithTeam = this.appendTeamNameToName(giverName, giverTeamName);
        responsesToOneRecipient.computeIfAbsent(giverNameWithTeam, key -> new ArrayList<>()).add(response);
    }
    return sortedMap;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) Set(java.util.Set) SanitizationHelper(teammates.common.util.SanitizationHelper) HashMap(java.util.HashMap) StringHelper(teammates.common.util.StringHelper) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) ZoneId(java.time.ZoneId) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Map(java.util.Map) Element(org.jsoup.nodes.Element) Text(com.google.appengine.api.datastore.Text) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) Comparator(java.util.Comparator) Logger(teammates.common.util.Logger) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 83 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackSessionResultsBundle method getQuestionResponseMap.

// TODO: make responses to the student calling this method always on top.
/**
 * Gets the questions and responses in this bundle as a map.
 *
 * @return An ordered {@code Map} with keys as {@link FeedbackQuestionAttributes}
 *         sorted by questionNumber.
 *         The mapped values for each key are the corresponding
 *         {@link FeedbackResponseAttributes} as a {@code List}.
 */
public Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> getQuestionResponseMap() {
    if (questions == null || responses == null) {
        return null;
    }
    Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> sortedMap = new LinkedHashMap<>();
    List<FeedbackQuestionAttributes> sortedQuestions = new ArrayList<>(questions.values());
    // sorts the questions by its natural ordering, which is by question number
    sortedQuestions.sort(null);
    for (FeedbackQuestionAttributes question : sortedQuestions) {
        sortedMap.put(question, new ArrayList<FeedbackResponseAttributes>());
    }
    for (FeedbackResponseAttributes response : responses) {
        FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
        List<FeedbackResponseAttributes> responsesForQuestion = sortedMap.get(question);
        responsesForQuestion.add(response);
    }
    for (List<FeedbackResponseAttributes> responsesForQuestion : sortedMap.values()) {
        responsesForQuestion.sort(compareByGiverRecipient);
    }
    return sortedMap;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap)

Example 84 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackSessionResultsBundle method getResponsesSortedByGiverRecipientQuestion.

/**
 * Returns the responses in this bundle as a {@code Tree} structure with no base node
 * using a {@code LinkedHashMap} implementation.
 * <br>The tree is sorted by giverName > recipientName > questionNumber.
 * <br>The key of each map represents the parent node, while the value represents the leaf.
 * <br>The top-most parent {@code String giverName} is the recipient's name of all it's leafs.
 * <br>The inner parent {@code String recipientName} is the giver's name of all it's leafs.
 * <br>The inner-most child is a {@code List<FeedbackResponseAttributes} of all the responses
 * <br>with attributes corresponding to it's parents.
 * @return The responses in this bundle sorted by giver's identifier > recipient's identifier > question number.
 * @see #getResponsesSortedByGiver
 */
public Map<String, Map<String, List<FeedbackResponseAttributes>>> getResponsesSortedByGiverRecipientQuestion(boolean sortByTeam) {
    if (sortByTeam) {
        responses.sort(compareByTeamGiverRecipientQuestion);
    } else {
        responses.sort(compareByGiverRecipientQuestion);
    }
    Map<String, Map<String, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
    for (FeedbackResponseAttributes response : responses) {
        String giverEmail = response.giver;
        Map<String, List<FeedbackResponseAttributes>> responsesFromOneGiver = sortedMap.computeIfAbsent(giverEmail, key -> new LinkedHashMap<>());
        String recipientEmail = response.recipient;
        responsesFromOneGiver.computeIfAbsent(recipientEmail, key -> new ArrayList<>()).add(response);
    }
    return sortedMap;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) Set(java.util.Set) SanitizationHelper(teammates.common.util.SanitizationHelper) HashMap(java.util.HashMap) StringHelper(teammates.common.util.StringHelper) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) ZoneId(java.time.ZoneId) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Map(java.util.Map) Element(org.jsoup.nodes.Element) Text(com.google.appengine.api.datastore.Text) Jsoup(org.jsoup.Jsoup) Elements(org.jsoup.select.Elements) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) Comparator(java.util.Comparator) Logger(teammates.common.util.Logger) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 85 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class InstructorSubmissionAdjustmentUiTest method getAllTeamResponsesForStudent.

private List<FeedbackResponseAttributes> getAllTeamResponsesForStudent(StudentAttributes student) {
    List<FeedbackResponseAttributes> returnList = new ArrayList<>();
    List<FeedbackResponseAttributes> studentReceiverResponses = BackDoor.getFeedbackResponsesForReceiverForCourse(student.course, student.email);
    for (FeedbackResponseAttributes response : studentReceiverResponses) {
        FeedbackQuestionAttributes question = BackDoor.getFeedbackQuestion(response.feedbackQuestionId);
        if (question.recipientType == FeedbackParticipantType.OWN_TEAM_MEMBERS) {
            returnList.add(response);
        }
    }
    List<FeedbackResponseAttributes> studentGiverResponses = BackDoor.getFeedbackResponsesFromGiverForCourse(student.course, student.email);
    for (FeedbackResponseAttributes response : studentGiverResponses) {
        FeedbackQuestionAttributes question = BackDoor.getFeedbackQuestion(response.feedbackQuestionId);
        if (question.giverType == FeedbackParticipantType.TEAMS || question.recipientType == FeedbackParticipantType.OWN_TEAM_MEMBERS) {
            returnList.add(response);
        }
    }
    return returnList;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Aggregations

FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)143 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)70 ArrayList (java.util.ArrayList)63 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)36 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)35 List (java.util.List)29 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)28 HashMap (java.util.HashMap)27 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)22 HashSet (java.util.HashSet)20 LinkedHashMap (java.util.LinkedHashMap)20 Map (java.util.Map)18 Test (org.testng.annotations.Test)18 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)18 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)18 Text (com.google.appengine.api.datastore.Text)15 Set (java.util.Set)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)10 Comparator (java.util.Comparator)9 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)9