use of teammates.ui.template.InstructorFeedbackResultsResponseRow 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.InstructorFeedbackResultsResponseRow 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;
}
use of teammates.ui.template.InstructorFeedbackResultsResponseRow 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;
}
use of teammates.ui.template.InstructorFeedbackResultsResponseRow in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageData method buildQuestionTableAndResponseRows.
/**
* Builds a question table for given question, and response rows for the given responses.
*
* @param participantIdentifier for viewTypes * > Question > *, constructs missing response rows
* only for the given participant
* @param isShowingResponseRows if false, hides the response rows
*/
private InstructorFeedbackResultsQuestionTable buildQuestionTableAndResponseRows(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses, String additionalInfoId, String participantIdentifier, boolean isShowingResponseRows) {
List<ElementTag> columnTags = new ArrayList<>();
Map<String, Boolean> isSortable = new HashMap<>();
boolean isCollapsible = true;
List<InstructorFeedbackResultsResponseRow> responseRows = null;
FeedbackQuestionDetails questionDetails = questionToDetailsMap.get(question);
if (isShowingResponseRows) {
switch(viewType) {
case QUESTION:
buildTableColumnHeaderForQuestionView(columnTags, isSortable);
responseRows = buildResponseRowsForQuestion(question, responses);
break;
case GIVER_QUESTION_RECIPIENT:
buildTableColumnHeaderForGiverQuestionRecipientView(columnTags, isSortable);
responseRows = buildResponseRowsForQuestionForSingleGiver(question, responses, participantIdentifier);
isCollapsible = false;
break;
case RECIPIENT_QUESTION_GIVER:
buildTableColumnHeaderForRecipientQuestionGiverView(columnTags, isSortable);
responseRows = buildResponseRowsForQuestionForSingleRecipient(question, responses, participantIdentifier);
isCollapsible = false;
break;
default:
Assumption.fail("View type should not involve question tables");
break;
}
// by default order (first by team name, then by display name)
if (questionDetails.isQuestionSpecificSortingRequired()) {
responseRows.sort(questionDetails.getResponseRowsSortOrder());
} else {
responseRows = InstructorFeedbackResultsResponseRow.sortListWithDefaultOrder(responseRows);
}
}
String studentEmail = student == null ? null : student.email;
String statisticsTable = questionDetails.getQuestionResultStatisticsHtml(responses, question, studentEmail, bundle, viewType.toString());
String questionText = questionDetails.getQuestionText();
String additionalInfoText = questionDetails.getQuestionAdditionalInfoHtml(question.questionNumber, additionalInfoId);
InstructorFeedbackResultsQuestionTable questionTable = new InstructorFeedbackResultsQuestionTable(!responses.isEmpty(), statisticsTable, responseRows, question, questionText, additionalInfoText, columnTags, isSortable);
if (viewType == InstructorFeedbackResultsPageViewType.QUESTION) {
// setup classes, for loading responses by ajax
// ajax_submit: user needs to click on the panel to load
// ajax_auto: responses are loaded automatically
questionTable.setAjaxClass(isLargeNumberOfResponses() ? " ajax_submit" : " ajax_auto");
}
questionTable.setShowResponseRows(isShowingResponseRows);
questionTable.setCollapsible(isCollapsible);
return questionTable;
}
use of teammates.ui.template.InstructorFeedbackResultsResponseRow 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;
}
Aggregations