Search in sources :

Example 1 with InstructorFeedbackResultsModerationButton

use of teammates.ui.template.InstructorFeedbackResultsModerationButton in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildResponseRowsForQuestion.

/**
 * Builds response rows for a given question. This not only builds response rows for existing responses, but includes
 * the missing responses between pairs of givers and recipients.
 * @param responses  existing responses for the question
 */
private List<InstructorFeedbackResultsResponseRow> buildResponseRowsForQuestion(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses) {
    List<InstructorFeedbackResultsResponseRow> responseRows = new ArrayList<>();
    List<String> possibleGiversWithoutResponses = bundle.getPossibleGivers(question);
    List<String> possibleReceiversWithoutResponsesForGiver = new ArrayList<>();
    String prevGiver = "";
    int responseRecipientIndex = 0;
    int responseGiverIndex = 0;
    int userIndex = 0;
    Map<String, Integer> userIndexesForComments = new HashMap<String, Integer>();
    for (FeedbackResponseAttributes response : responses) {
        if (!bundle.isGiverVisible(response) || !bundle.isRecipientVisible(response)) {
            possibleGiversWithoutResponses.clear();
            possibleReceiversWithoutResponsesForGiver.clear();
        }
        // keep track of possible givers who did not give a response
        removeParticipantIdentifierFromList(possibleGiversWithoutResponses, response.giver);
        boolean isNewGiver = !prevGiver.equals(response.giver);
        if (isNewGiver) {
            if (isMissingResponsesShown) {
                responseRows.addAll(buildMissingResponseRowsBetweenGiverAndPossibleRecipients(question, possibleReceiversWithoutResponsesForGiver, prevGiver, bundle.getNameForEmail(prevGiver), bundle.getTeamNameForEmail(prevGiver)));
            }
            String giverIdentifier = response.giver;
            possibleReceiversWithoutResponsesForGiver = bundle.getPossibleRecipients(question, giverIdentifier);
        }
        // keep track of possible recipients without a response from the current giver
        removeParticipantIdentifierFromList(possibleReceiversWithoutResponsesForGiver, response.recipient);
        prevGiver = response.giver;
        InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForExistingResponse(question, response);
        InstructorFeedbackResultsResponseRow responseRow = new InstructorFeedbackResultsResponseRow(bundle.getGiverNameForResponse(response), bundle.getTeamNameForEmail(response.giver), bundle.getRecipientNameForResponse(response), bundle.getTeamNameForEmail(response.recipient), bundle.getResponseAnswerHtml(response, question), moderationButton);
        configureResponseRow(prevGiver, response.recipient, responseRow);
        String giverName = bundle.getNameForEmail(response.giver);
        String recipientName = bundle.getNameForEmail(response.recipient);
        String giverTeam = bundle.getTeamNameForEmail(response.giver);
        String recipientTeam = bundle.getTeamNameForEmail(response.recipient);
        giverName = bundle.appendTeamNameToName(giverName, giverTeam);
        recipientName = bundle.appendTeamNameToName(recipientName, recipientTeam);
        List<FeedbackResponseCommentRow> comments = buildResponseComments(giverName, recipientName, question, response);
        if (!comments.isEmpty()) {
            responseRow.setCommentsOnResponses(comments);
        }
        Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
        boolean isCommentsOnResponsesAllowed = question.getQuestionDetails().isCommentsOnResponsesAllowed();
        if (isCommentsOnResponsesAllowed) {
            FeedbackResponseCommentRow addCommentForm = buildFeedbackResponseCommentAddForm(question, response, responseVisibilityMap, giverName, recipientName);
            responseRow.setAddCommentButton(addCommentForm);
            if (userIndexesForComments.get(response.giver) == null) {
                userIndex = generateIndexForUser(response.giver, userIndex, userIndexesForComments);
            }
            responseGiverIndex = userIndexesForComments.get(response.giver);
            if (userIndexesForComments.get(response.recipient) == null) {
                userIndex = generateIndexForUser(response.recipient, userIndex, userIndexesForComments);
            }
            responseRecipientIndex = userIndexesForComments.get(response.recipient);
            responseRow.setResponseRecipientIndex(responseRecipientIndex);
            responseRow.setResponseGiverIndex(responseGiverIndex);
            responseRow.setCommentsOnResponsesAllowed(isCommentsOnResponsesAllowed);
        }
        responseRows.add(responseRow);
    }
    if (!responses.isEmpty()) {
        responseRows.addAll(getRemainingMissingResponseRows(question, possibleGiversWithoutResponses, possibleReceiversWithoutResponsesForGiver, prevGiver));
    }
    return responseRows;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton)

Example 2 with InstructorFeedbackResultsModerationButton

use of teammates.ui.template.InstructorFeedbackResultsModerationButton in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildGroupByParticipantPanel.

private InstructorFeedbackResultsGroupByParticipantPanel buildGroupByParticipantPanel(String primaryParticipantIdentifier, Entry<String, Map<String, List<FeedbackResponseAttributes>>> recipientToGiverToResponsesMap, String additionalInfoId, int primaryParticipantIndex) {
    // first build secondary participant panels for the primary participant panel
    Map<String, List<FeedbackResponseAttributes>> giverToResponsesMap = recipientToGiverToResponsesMap.getValue();
    List<InstructorFeedbackResultsSecondaryParticipantPanelBody> secondaryParticipantPanels = buildSecondaryParticipantPanels(additionalInfoId, primaryParticipantIndex, giverToResponsesMap);
    // construct the primary participant panel
    String primaryParticipantNameWithTeamName = bundle.appendTeamNameToName(bundle.getNameForEmail(primaryParticipantIdentifier), bundle.getTeamNameForEmail(primaryParticipantIdentifier));
    InstructorFeedbackResultsModerationButton moderationButton;
    if (viewType.isPrimaryGroupingOfGiverType()) {
        moderationButton = buildModerationButtonForGiver(null, primaryParticipantIdentifier, "btn btn-primary btn-xs", MODERATE_RESPONSES_FOR_GIVER);
    } else {
        moderationButton = null;
    }
    return buildInstructorFeedbackResultsGroupBySecondaryParticipantPanel(primaryParticipantIdentifier, primaryParticipantNameWithTeamName, secondaryParticipantPanels, moderationButton);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton) InstructorFeedbackResultsSecondaryParticipantPanelBody(teammates.ui.template.InstructorFeedbackResultsSecondaryParticipantPanelBody)

Example 3 with InstructorFeedbackResultsModerationButton

use of teammates.ui.template.InstructorFeedbackResultsModerationButton in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildResponseRowsForQuestionForSingleParticipant.

private List<InstructorFeedbackResultsResponseRow> buildResponseRowsForQuestionForSingleParticipant(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses, String participantIdentifier, boolean isFirstGroupedByGiver) {
    List<InstructorFeedbackResultsResponseRow> responseRows = new ArrayList<>();
    List<String> possibleParticipantsWithoutResponses = isFirstGroupedByGiver ? bundle.getPossibleRecipients(question, participantIdentifier) : bundle.getPossibleGivers(question, participantIdentifier);
    for (FeedbackResponseAttributes response : responses) {
        if (!bundle.isGiverVisible(response) || !bundle.isRecipientVisible(response)) {
            possibleParticipantsWithoutResponses.clear();
        }
        // keep track of possible participant who did not give/receive a response to/from the participantIdentifier
        String participantWithResponse = isFirstGroupedByGiver ? response.recipient : response.giver;
        removeParticipantIdentifierFromList(possibleParticipantsWithoutResponses, participantWithResponse);
        InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForExistingResponse(question, response);
        InstructorFeedbackResultsResponseRow responseRow = new InstructorFeedbackResultsResponseRow(bundle.getGiverNameForResponse(response), bundle.getTeamNameForEmail(response.giver), bundle.getRecipientNameForResponse(response), bundle.getTeamNameForEmail(response.recipient), bundle.getResponseAnswerHtml(response, question), moderationButton);
        configureResponseRow(response.giver, response.recipient, responseRow);
        responseRows.add(responseRow);
    }
    if (isMissingResponsesShown) {
        if (isFirstGroupedByGiver) {
            responseRows.addAll(buildMissingResponseRowsBetweenGiverAndPossibleRecipients(question, possibleParticipantsWithoutResponses, participantIdentifier, bundle.getNameForEmail(participantIdentifier), bundle.getTeamNameForEmail(participantIdentifier)));
        } else {
            responseRows.addAll(buildMissingResponseRowsBetweenRecipientAndPossibleGivers(question, possibleParticipantsWithoutResponses, participantIdentifier, bundle.getNameForEmail(participantIdentifier), bundle.getTeamNameForEmail(participantIdentifier)));
        }
    }
    return responseRows;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton)

Example 4 with InstructorFeedbackResultsModerationButton

use of teammates.ui.template.InstructorFeedbackResultsModerationButton in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildMissingResponseRowsBetweenRecipientAndPossibleGivers.

/**
 * Construct missing response rows between the recipient identified by {@code recipientIdentifier} and
 * {@code possibleGivers}.
 */
private List<InstructorFeedbackResultsResponseRow> buildMissingResponseRowsBetweenRecipientAndPossibleGivers(FeedbackQuestionAttributes question, List<String> possibleGivers, String recipientIdentifier, String recipientName, String recipientTeam) {
    List<InstructorFeedbackResultsResponseRow> missingResponses = new ArrayList<>();
    FeedbackQuestionDetails questionDetails = questionToDetailsMap.get(question);
    for (String possibleGiver : possibleGivers) {
        String possibleGiverName = bundle.getFullNameFromRoster(possibleGiver);
        String possibleGiverTeam = bundle.getTeamNameFromRoster(possibleGiver);
        String textToDisplay = questionDetails.getNoResponseTextInHtml(recipientIdentifier, possibleGiver, bundle, question);
        if (questionDetails.shouldShowNoResponseText(question)) {
            InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForGiver(question, possibleGiver, "btn btn-default btn-xs", MODERATE_SINGLE_RESPONSE);
            InstructorFeedbackResultsResponseRow missingResponse = new InstructorFeedbackResultsResponseRow(possibleGiverName, possibleGiverTeam, recipientName, recipientTeam, textToDisplay, moderationButton, true);
            missingResponse.setRowAttributes(new ElementTag("class", "pending_response_row"));
            configureResponseRow(possibleGiver, recipientIdentifier, missingResponse);
            missingResponses.add(missingResponse);
        }
    }
    return missingResponses;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton) ElementTag(teammates.ui.template.ElementTag)

Example 5 with InstructorFeedbackResultsModerationButton

use of teammates.ui.template.InstructorFeedbackResultsModerationButton in project teammates by TEAMMATES.

the class InstructorFeedbackResultsPageData method buildMissingResponseRowsBetweenGiverAndPossibleRecipients.

/**
 * Construct missing response rows between the giver identified by {@code giverIdentifier} and
 * {@code possibleReceivers}.
 */
private List<InstructorFeedbackResultsResponseRow> buildMissingResponseRowsBetweenGiverAndPossibleRecipients(FeedbackQuestionAttributes question, List<String> possibleReceivers, String giverIdentifier, String giverName, String giverTeam) {
    List<InstructorFeedbackResultsResponseRow> missingResponses = new ArrayList<>();
    FeedbackQuestionDetails questionDetails = questionToDetailsMap.get(question);
    for (String possibleRecipient : possibleReceivers) {
        if (questionDetails.shouldShowNoResponseText(question)) {
            String textToDisplay = questionDetails.getNoResponseTextInHtml(giverIdentifier, possibleRecipient, bundle, question);
            String possibleRecipientName = bundle.getFullNameFromRoster(possibleRecipient);
            String possibleRecipientTeam = bundle.getTeamNameFromRoster(possibleRecipient);
            InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForGiver(question, giverIdentifier, "btn btn-default btn-xs", MODERATE_SINGLE_RESPONSE);
            InstructorFeedbackResultsResponseRow missingResponse = new InstructorFeedbackResultsResponseRow(giverName, giverTeam, possibleRecipientName, possibleRecipientTeam, textToDisplay, moderationButton, true);
            missingResponse.setRowAttributes(new ElementTag("class", "pending_response_row"));
            configureResponseRow(giverIdentifier, possibleRecipient, missingResponse);
            missingResponses.add(missingResponse);
        }
    }
    return missingResponses;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton) ElementTag(teammates.ui.template.ElementTag)

Aggregations

InstructorFeedbackResultsModerationButton (teammates.ui.template.InstructorFeedbackResultsModerationButton)8 ArrayList (java.util.ArrayList)7 InstructorFeedbackResultsResponseRow (teammates.ui.template.InstructorFeedbackResultsResponseRow)4 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)2 ElementTag (teammates.ui.template.ElementTag)2 InstructorFeedbackResultsGroupByQuestionPanel (teammates.ui.template.InstructorFeedbackResultsGroupByQuestionPanel)2 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)1 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)1 InstructorFeedbackResultsParticipantPanel (teammates.ui.template.InstructorFeedbackResultsParticipantPanel)1 InstructorFeedbackResultsQuestionTable (teammates.ui.template.InstructorFeedbackResultsQuestionTable)1 InstructorFeedbackResultsSecondaryParticipantPanelBody (teammates.ui.template.InstructorFeedbackResultsSecondaryParticipantPanelBody)1