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