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;
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations