Search in sources :

Example 1 with InstructorFeedbackResultsResponsePanel

use of teammates.ui.template.InstructorFeedbackResultsResponsePanel 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 2 with InstructorFeedbackResultsResponsePanel

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

the class InstructorFeedbackResultsPageData method buildSecondaryParticipantPanels.

private List<InstructorFeedbackResultsSecondaryParticipantPanelBody> buildSecondaryParticipantPanels(String additionalInfoId, int primaryParticipantIndex, Map<String, List<FeedbackResponseAttributes>> secondaryParticipantToResponsesMap) {
    List<InstructorFeedbackResultsSecondaryParticipantPanelBody> secondaryParticipantPanels = new ArrayList<>();
    int secondaryParticipantIndex = 0;
    for (Map.Entry<String, List<FeedbackResponseAttributes>> secondaryParticipantResponses : secondaryParticipantToResponsesMap.entrySet()) {
        secondaryParticipantIndex += 1;
        String secondaryParticipantIdentifier = secondaryParticipantResponses.getKey();
        boolean isEmail = validator.getInvalidityInfoForEmail(secondaryParticipantIdentifier).isEmpty();
        String secondaryParticipantDisplayableName;
        if (isEmail && !bundle.getTeamNameForEmail(secondaryParticipantIdentifier).isEmpty()) {
            secondaryParticipantDisplayableName = bundle.getNameForEmail(secondaryParticipantIdentifier) + " (" + bundle.getTeamNameForEmail(secondaryParticipantIdentifier) + ")";
        } else {
            secondaryParticipantDisplayableName = bundle.getNameForEmail(secondaryParticipantIdentifier);
        }
        List<InstructorFeedbackResultsResponsePanel> responsePanels = buildResponsePanels(additionalInfoId, primaryParticipantIndex, secondaryParticipantIndex, secondaryParticipantResponses.getValue());
        InstructorFeedbackResultsSecondaryParticipantPanelBody secondaryParticipantPanel = new InstructorFeedbackResultsSecondaryParticipantPanelBody(secondaryParticipantIdentifier, secondaryParticipantDisplayableName, responsePanels);
        secondaryParticipantPanel.setProfilePictureLink(getProfilePictureIfEmailValid(secondaryParticipantIdentifier));
        if (!viewType.isPrimaryGroupingOfGiverType()) {
            String sectionName = bundle.getSectionFromRoster(secondaryParticipantIdentifier);
            boolean isAllowedToModerate = isAllowedToModerate(instructor, sectionName, feedbackSessionName);
            secondaryParticipantPanel.setModerationButton(isAllowedToModerate ? buildModerationButtonForGiver(null, secondaryParticipantIdentifier, "btn btn-default btn-xs", MODERATE_RESPONSES_FOR_GIVER) : null);
        }
        secondaryParticipantPanels.add(secondaryParticipantPanel);
    }
    return secondaryParticipantPanels;
}
Also used : InstructorFeedbackResultsResponsePanel(teammates.ui.template.InstructorFeedbackResultsResponsePanel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) InstructorFeedbackResultsSecondaryParticipantPanelBody(teammates.ui.template.InstructorFeedbackResultsSecondaryParticipantPanelBody) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)2 InstructorFeedbackResultsResponsePanel (teammates.ui.template.InstructorFeedbackResultsResponsePanel)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)1 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)1 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)1 InstructorFeedbackResultsSecondaryParticipantPanelBody (teammates.ui.template.InstructorFeedbackResultsSecondaryParticipantPanelBody)1