Search in sources :

Example 1 with FeedbackResponseCommentRow

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

the class InstructorFeedbackResultsPageData method buildFeedbackResponseCommentAddForm.

private FeedbackResponseCommentRow buildFeedbackResponseCommentAddForm(FeedbackQuestionAttributes question, FeedbackResponseAttributes response, Map<FeedbackParticipantType, Boolean> responseVisibilityMap, String giverName, String recipientName) {
    FeedbackResponseCommentAttributes frca = FeedbackResponseCommentAttributes.builder(question.courseId, question.feedbackSessionName, "", new Text("")).withFeedbackResponseId(response.getId()).withFeedbackQuestionId(question.getId()).build();
    FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.GIVER, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
    frca.showCommentTo = new ArrayList<>();
    frca.showGiverNameTo = new ArrayList<>();
    for (FeedbackParticipantType type : relevantTypes) {
        if (isResponseCommentVisibleTo(question, type)) {
            frca.showCommentTo.add(type);
        }
        if (isResponseCommentGiverNameVisibleTo(question, type)) {
            frca.showGiverNameTo.add(type);
        }
    }
    return new FeedbackResponseCommentRow(frca, giverName, recipientName, getResponseCommentVisibilityString(question), getResponseCommentGiverNameVisibilityString(question), responseVisibilityMap, bundle.getTimeZone());
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) Text(com.google.appengine.api.datastore.Text) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 2 with FeedbackResponseCommentRow

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

the class InstructorFeedbackResultsPageData method buildResponsePanels.

private List<InstructorFeedbackResultsResponsePanel> buildResponsePanels(final String additionalInfoId, int primaryParticipantIndex, int secondaryRecipientIndex, List<FeedbackResponseAttributes> giverResponses) {
    List<InstructorFeedbackResultsResponsePanel> responsePanels = new ArrayList<>();
    for (int responseIndex = 0; responseIndex < giverResponses.size(); responseIndex++) {
        FeedbackResponseAttributes response = giverResponses.get(responseIndex);
        String questionId = response.feedbackQuestionId;
        FeedbackQuestionAttributes question = bundle.questions.get(questionId);
        String questionText = bundle.getQuestionText(questionId);
        int giverIndex = viewType.isPrimaryGroupingOfGiverType() ? primaryParticipantIndex : secondaryRecipientIndex;
        int recipientIndex = viewType.isPrimaryGroupingOfGiverType() ? secondaryRecipientIndex : primaryParticipantIndex;
        String additionalInfoText = questionToDetailsMap.get(question).getQuestionAdditionalInfoHtml(question.getQuestionNumber(), String.format(additionalInfoId, giverIndex, recipientIndex));
        String displayableResponse = bundle.getResponseAnswerHtml(response, question);
        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);
        boolean isAllowedToSubmitSessionsInBothSection = instructor.isAllowedForPrivilege(response.giverSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS) && instructor.isAllowedForPrivilege(response.recipientSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
        boolean isCommentsOnResponsesAllowed = question.getQuestionDetails().isCommentsOnResponsesAllowed();
        Matcher matcher = sectionIdPattern.matcher(additionalInfoId);
        if (matcher.find()) {
            sectionId = Integer.parseInt(matcher.group(1));
        }
        InstructorFeedbackResultsResponsePanel responsePanel = new InstructorFeedbackResultsResponsePanel(question, response, questionText, sectionId, additionalInfoText, null, displayableResponse, comments, isAllowedToSubmitSessionsInBothSection, isCommentsOnResponsesAllowed);
        responsePanel.setCommentsIndexes(recipientIndex, giverIndex, responseIndex + 1);
        if (isCommentsOnResponsesAllowed) {
            Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
            FeedbackResponseCommentRow frcForAdding = buildFeedbackResponseCommentAddForm(question, response, responseVisibilityMap, giverName, recipientName);
            responsePanel.setFrcForAdding(frcForAdding);
        }
        responsePanels.add(responsePanel);
    }
    return responsePanels;
}
Also used : InstructorFeedbackResultsResponsePanel(teammates.ui.template.InstructorFeedbackResultsResponsePanel) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow)

Example 3 with FeedbackResponseCommentRow

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

the class InstructorFeedbackResultsPageData method buildResponseComment.

private FeedbackResponseCommentRow buildResponseComment(String giverName, String recipientName, FeedbackQuestionAttributes question, FeedbackResponseAttributes response, FeedbackResponseCommentAttributes frcAttributes) {
    boolean isInstructorGiver = instructor.email.equals(frcAttributes.giverEmail);
    boolean isInstructorWithPrivilegesToModify = instructor.isAllowedForPrivilege(response.giverSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS) && instructor.isAllowedForPrivilege(response.recipientSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS);
    boolean isInstructorAllowedToEditAndDeleteComment = isInstructorGiver || isInstructorWithPrivilegesToModify;
    Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
    String whoCanSeeComment = null;
    boolean isVisibilityIconShown = false;
    if (bundle.feedbackSession.isPublished()) {
        boolean isResponseCommentPublicToRecipient = !frcAttributes.showCommentTo.isEmpty();
        isVisibilityIconShown = isResponseCommentPublicToRecipient;
        if (isVisibilityIconShown) {
            whoCanSeeComment = getTypeOfPeopleCanViewComment(frcAttributes, question);
        }
    }
    FeedbackResponseCommentRow frc = new FeedbackResponseCommentRow(frcAttributes, frcAttributes.giverEmail, giverName, recipientName, getResponseCommentVisibilityString(frcAttributes, question), getResponseCommentGiverNameVisibilityString(frcAttributes, question), responseVisibilityMap, bundle.instructorEmailNameTable, bundle.getTimeZone());
    frc.setVisibilityIcon(isVisibilityIconShown, whoCanSeeComment);
    if (isInstructorAllowedToEditAndDeleteComment) {
        frc.enableEditDelete();
    }
    return frc;
}
Also used : FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 4 with FeedbackResponseCommentRow

use of teammates.ui.template.FeedbackResponseCommentRow 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 5 with FeedbackResponseCommentRow

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

the class InstructorFeedbackResultsPageData method buildResponseComments.

private List<FeedbackResponseCommentRow> buildResponseComments(String giverName, String recipientName, FeedbackQuestionAttributes question, FeedbackResponseAttributes response) {
    List<FeedbackResponseCommentRow> comments = new ArrayList<>();
    List<FeedbackResponseCommentAttributes> frcAttributesList = bundle.responseComments.get(response.getId());
    if (frcAttributesList != null) {
        for (FeedbackResponseCommentAttributes frcAttributes : frcAttributesList) {
            comments.add(buildResponseComment(giverName, recipientName, question, response, frcAttributes));
        }
    }
    return comments;
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) ArrayList(java.util.ArrayList) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow)

Aggregations

FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)9 ArrayList (java.util.ArrayList)6 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)4 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)4 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)3 Text (com.google.appengine.api.datastore.Text)1 ZoneId (java.time.ZoneId)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)1 FeedbackResultsResponse (teammates.ui.template.FeedbackResultsResponse)1 FeedbackResultsResponseTable (teammates.ui.template.FeedbackResultsResponseTable)1 InstructorFeedbackResultsModerationButton (teammates.ui.template.InstructorFeedbackResultsModerationButton)1 InstructorFeedbackResultsResponsePanel (teammates.ui.template.InstructorFeedbackResultsResponsePanel)1 InstructorFeedbackResultsResponseRow (teammates.ui.template.InstructorFeedbackResultsResponseRow)1