Search in sources :

Example 31 with FeedbackResponseAttributes

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;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Const(teammates.common.util.Const) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle) DecimalFormat(java.text.DecimalFormat) Slots(teammates.common.util.Templates.FeedbackQuestion.Slots) SanitizationHelper(teammates.common.util.SanitizationHelper) HashMap(java.util.HashMap) StringHelper(teammates.common.util.StringHelper) Collectors(java.util.stream.Collectors) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) ArrayList(java.util.ArrayList) HttpRequestHelper(teammates.common.util.HttpRequestHelper) List(java.util.List) Templates(teammates.common.util.Templates) InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FormTemplates(teammates.common.util.Templates.FeedbackQuestion.FormTemplates) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) Map(java.util.Map) Assumption(teammates.common.util.Assumption) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) Comparator(java.util.Comparator) LinkedList(java.util.LinkedList) Logger(teammates.common.util.Logger) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) HashMap(java.util.HashMap) LinkedList(java.util.LinkedList)

Example 32 with FeedbackResponseAttributes

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;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList)

Example 33 with FeedbackResponseAttributes

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);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 34 with FeedbackResponseAttributes

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;
}
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) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) 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 35 with FeedbackResponseAttributes

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

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