use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackRubricQuestionDetails method getPerRecipientStatisticsSorted.
public List<Map.Entry<String, RubricRecipientStatistics>> getPerRecipientStatisticsSorted(List<FeedbackResponseAttributes> responses, FeedbackSessionResultsBundle bundle) {
Map<String, RubricRecipientStatistics> recipientToRecipientStats = new HashMap<>();
for (FeedbackResponseAttributes response : responses) {
recipientToRecipientStats.computeIfAbsent(response.recipient, recipient -> {
String recipientTeam = bundle.getTeamNameForEmail(recipient);
String recipientName = bundle.getNameForEmail(recipient);
return new RubricRecipientStatistics(recipient, recipientName, recipientTeam);
}).addResponseToRecipientStats(response);
}
List<Map.Entry<String, RubricRecipientStatistics>> recipientStatsList = new LinkedList<>(recipientToRecipientStats.entrySet());
recipientStatsList.sort(Comparator.comparing((Map.Entry<String, RubricRecipientStatistics> obj) -> obj.getValue().recipientTeam.toLowerCase()).thenComparing(obj -> obj.getValue().recipientName));
return recipientStatsList;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackMsqQuestionDetails method validateResponseAttributes.
@Override
public List<String> validateResponseAttributes(List<FeedbackResponseAttributes> responses, int numRecipients) {
List<String> errors = new ArrayList<>();
for (FeedbackResponseAttributes response : responses) {
FeedbackMsqResponseDetails frd = (FeedbackMsqResponseDetails) response.getResponseDetails();
if (!otherEnabled) {
List<String> validChoices = msqChoices;
validChoices.add("");
if (!validChoices.containsAll(frd.answers) && generateOptionsFor == FeedbackParticipantType.NONE) {
errors.add(frd.getAnswerString() + Const.FeedbackQuestion.MSQ_ERROR_INVALID_OPTION);
}
}
if (maxSelectableChoices != Integer.MIN_VALUE && frd.answers.size() > maxSelectableChoices) {
errors.add(Const.FeedbackQuestion.MSQ_ERROR_MAX_SELECTABLE_EXCEEDED_TOTAL + maxSelectableChoices);
}
}
return errors;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackSessionQuestionsBundle method hideUnmoderatableQuestions.
/**
* Removes question from the bundle if the question has givers or recipients that are anonymous to the instructor
* or responses that are hidden from the instructor.
*/
public void hideUnmoderatableQuestions() {
List<FeedbackQuestionAttributes> questionsToHide = new ArrayList<>();
for (FeedbackQuestionAttributes question : questionResponseBundle.keySet()) {
boolean isGiverVisibleToInstructor = question.showGiverNameTo.contains(FeedbackParticipantType.INSTRUCTORS);
boolean isRecipientVisibleToInstructor = question.showRecipientNameTo.contains(FeedbackParticipantType.INSTRUCTORS);
boolean isResponseVisibleToInstructor = question.showResponsesTo.contains(FeedbackParticipantType.INSTRUCTORS);
if (!isResponseVisibleToInstructor || !isGiverVisibleToInstructor || !isRecipientVisibleToInstructor) {
questionsToHide.add(question);
questionResponseBundle.put(question, new ArrayList<FeedbackResponseAttributes>());
}
}
questionResponseBundle.keySet().removeAll(questionsToHide);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes 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.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method getResponsesSortedByRecipientGiverQuestion.
/**
* 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 recipientName > giverName > questionNumber.
* <br>The key of each map represents the parent node, while the value represents the leaf.
* <br>The top-most parent {@code String recipientName} is the recipient's name of all it's leafs.
* <br>The inner parent {@code String giverName} 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 recipient identifier > giver identifier > question number.
* @see #getResponsesSortedByRecipient
*/
public Map<String, Map<String, List<FeedbackResponseAttributes>>> getResponsesSortedByRecipientGiverQuestion(boolean sortByTeam) {
LinkedHashMap<String, Map<String, List<FeedbackResponseAttributes>>> sortedMap = new LinkedHashMap<>();
if (sortByTeam) {
responses.sort(compareByTeamRecipientGiverQuestion);
} else {
responses.sort(compareByRecipientGiverQuestion);
}
for (FeedbackResponseAttributes response : responses) {
String recipientEmail = response.recipient;
Map<String, List<FeedbackResponseAttributes>> responsesToOneRecipient = sortedMap.computeIfAbsent(recipientEmail, key -> new LinkedHashMap<>());
String giverEmail = response.giver;
responsesToOneRecipient.computeIfAbsent(giverEmail, key -> new ArrayList<>()).add(response);
}
return sortedMap;
}
Aggregations