use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionResultsForQuestionInCsvFormat.
private StringBuilder getFeedbackSessionResultsForQuestionInCsvFormat(FeedbackSessionResultsBundle fsrBundle, Map.Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> entry, boolean isMissingResponsesShown, boolean isStatsShown, String section) {
FeedbackQuestionAttributes question = entry.getKey();
FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
List<FeedbackResponseAttributes> allResponses = entry.getValue();
StringBuilder exportBuilder = new StringBuilder();
exportBuilder.append("Question " + Integer.toString(question.questionNumber) + "," + SanitizationHelper.sanitizeForCsv(questionDetails.getQuestionText()) + System.lineSeparator() + System.lineSeparator());
String statistics = questionDetails.getQuestionResultStatisticsCsv(allResponses, question, fsrBundle);
if (!statistics.isEmpty() && isStatsShown) {
exportBuilder.append("Summary Statistics,").append(System.lineSeparator());
exportBuilder.append(statistics).append(System.lineSeparator());
}
List<String> possibleGiversWithoutResponses = fsrBundle.getPossibleGiversInSection(question, section);
List<String> possibleRecipientsForGiver = new ArrayList<>();
String prevGiver = "";
int maxNumOfResponseComments = getMaxNumberOfResponseComments(allResponses, fsrBundle.getResponseComments());
exportBuilder.append(questionDetails.getCsvDetailedResponsesHeader(maxNumOfResponseComments));
for (FeedbackResponseAttributes response : allResponses) {
if (!fsrBundle.isRecipientVisible(response) || !fsrBundle.isGiverVisible(response)) {
possibleGiversWithoutResponses.clear();
possibleRecipientsForGiver.clear();
}
// keep track of possible recipients with no responses
removeParticipantIdentifierFromList(question.giverType, possibleGiversWithoutResponses, response.giver, fsrBundle);
boolean isNewGiver = !prevGiver.equals(response.giver);
// print missing responses from the current giver
if (isNewGiver && isMissingResponsesShown) {
exportBuilder.append(getRowsOfPossibleRecipientsInCsvFormat(fsrBundle, question, questionDetails, possibleRecipientsForGiver, prevGiver));
String giverIdentifier = question.giverType == FeedbackParticipantType.TEAMS ? fsrBundle.getFullNameFromRoster(response.giver) : response.giver;
possibleRecipientsForGiver = fsrBundle.getPossibleRecipients(question, giverIdentifier);
}
removeParticipantIdentifierFromList(question.recipientType, possibleRecipientsForGiver, response.recipient, fsrBundle);
prevGiver = response.giver;
// do not show all possible givers and recipients if there are anonymous givers and recipients
boolean hasCommentsForResponses = fsrBundle.responseComments.containsKey(response.getId());
exportBuilder.append(questionDetails.getCsvDetailedResponsesRow(fsrBundle, response, question, hasCommentsForResponses));
}
// add the rows for the possible givers and recipients who have missing responses
if (isMissingResponsesShown) {
exportBuilder.append(getRemainingRowsInCsvFormat(fsrBundle, entry, question, questionDetails, possibleGiversWithoutResponses, possibleRecipientsForGiver, prevGiver));
}
exportBuilder.append(System.lineSeparator() + System.lineSeparator());
return exportBuilder;
}
use of teammates.common.datatransfer.questions.FeedbackQuestionDetails 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;
}
use of teammates.common.datatransfer.questions.FeedbackQuestionDetails in project teammates by TEAMMATES.
the class StudentFeedbackResultsPageData method createFeedbackResultsQuestionsWithResponses.
/**
* Parses the contents of the map and keeps only those data which will be displayed on the browser.
* @param questionsWithResponses Question with all responses
*/
private void createFeedbackResultsQuestionsWithResponses(Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionsWithResponses) {
feedbackResultsQuestionsWithResponses = new ArrayList<>();
int questionIndex = 1;
for (Map.Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionWithResponses : questionsWithResponses.entrySet()) {
FeedbackQuestionAttributes question = questionWithResponses.getKey();
List<FeedbackResponseAttributes> responsesBundle = questionWithResponses.getValue();
FeedbackQuestionDetails questionDetailsBundle = question.getQuestionDetails();
/* Contain only those attributes which will be displayed on the page */
FeedbackResultsQuestionDetails questionDetails = createQuestionDetails(questionIndex, question, questionDetailsBundle, responsesBundle);
List<FeedbackResultsResponseTable> responseTables = createResponseTables(question, responsesBundle);
feedbackResultsQuestionsWithResponses.add(new StudentFeedbackResultsQuestionWithResponses(questionDetails, responseTables));
questionIndex++;
}
}
Aggregations