use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method getResponsesSortedByGiverQuestionRecipient.
/**
* Returns responses as a {@code Map<giverName, Map<question, List<response>>>}
* Where the responses are sorted in the order of giver, question, recipient.
* @return responses sorted by Giver > Question > Recipient
*/
public Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> getResponsesSortedByGiverQuestionRecipient(boolean sortByTeam) {
Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
if (sortByTeam) {
responses.sort(compareByTeamGiverQuestionTeamRecipient);
} else {
responses.sort(compareByGiverQuestionTeamRecipient);
}
for (FeedbackResponseAttributes response : responses) {
String giverEmail = response.giver;
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> responsesFromOneGiver = sortedMap.computeIfAbsent(giverEmail, key -> new LinkedHashMap<>());
FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
responsesFromOneGiver.computeIfAbsent(question, key -> new ArrayList<>()).add(response);
}
return sortedMap;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method isFeedbackParticipantVisible.
/**
* Checks if the giver/recipient for a response is visible/hidden from the current user.
*/
public boolean isFeedbackParticipantVisible(boolean isGiver, FeedbackResponseAttributes response) {
FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
FeedbackParticipantType participantType;
String responseId = response.getId();
boolean isVisible;
if (isGiver) {
isVisible = visibilityTable.get(responseId)[Const.VISIBILITY_TABLE_GIVER];
participantType = question.giverType;
} else {
isVisible = visibilityTable.get(responseId)[Const.VISIBILITY_TABLE_RECIPIENT];
participantType = question.recipientType;
}
boolean isTypeNone = participantType == FeedbackParticipantType.NONE;
return isVisible || isTypeNone;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method getQuestionResponseMapByRecipientTeam.
/**
* Returns an ordered Map with {@code recipientTeam} name as key
* sorted by recipientTeam > question > recipientName > giverTeam > giverName.
*/
public Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> getQuestionResponseMapByRecipientTeam() {
LinkedHashMap<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
responses.sort(compareByTeamQuestionRecipientTeamGiver);
for (FeedbackResponseAttributes response : responses) {
String recipientTeam = getTeamNameForEmail(response.recipient);
if (recipientTeam.isEmpty()) {
recipientTeam = getNameForEmail(response.recipient);
}
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> responsesForOneRecipient = sortedMap.computeIfAbsent(recipientTeam, key -> new LinkedHashMap<>());
FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
List<FeedbackResponseAttributes> responsesForOneRecipientOneQuestion = responsesForOneRecipient.computeIfAbsent(question, key -> new ArrayList<>());
responsesForOneRecipientOneQuestion.add(response);
}
return sortedMap;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method getQuestionResponseMapSortedByRecipient.
public Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> getQuestionResponseMapSortedByRecipient() {
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(compareByRecipientNameEmailGiverNameEmail);
}
return sortedMap;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method getResponsesSortedByRecipientQuestionGiver.
/**
* Returns responses as a {@code Map<recipientName, Map<question, List<response>>>}
* Where the responses are sorted in the order of recipient, question, giver.
* @return responses sorted by Recipient > Question > Giver
*/
public Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> getResponsesSortedByRecipientQuestionGiver(boolean sortByTeam) {
Map<String, Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
if (sortByTeam) {
responses.sort(compareByTeamRecipientQuestionTeamGiver);
} else {
responses.sort(compareByRecipientQuestionTeamGiver);
}
for (FeedbackResponseAttributes response : responses) {
String recipientEmail = response.recipient;
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> responsesForOneRecipient = sortedMap.computeIfAbsent(recipientEmail, key -> new LinkedHashMap<>());
FeedbackQuestionAttributes question = questions.get(response.feedbackQuestionId);
responsesForOneRecipient.computeIfAbsent(question, key -> new ArrayList<>()).add(response);
}
return sortedMap;
}
Aggregations