Search in sources :

Example 16 with FeedbackQuestionDetails

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;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 17 with FeedbackQuestionDetails

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;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton) ElementTag(teammates.ui.template.ElementTag)

Example 18 with FeedbackQuestionDetails

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++;
    }
}
Also used : FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) FeedbackResultsQuestionDetails(teammates.ui.template.FeedbackResultsQuestionDetails) StudentFeedbackResultsQuestionWithResponses(teammates.ui.template.StudentFeedbackResultsQuestionWithResponses) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) ArrayList(java.util.ArrayList) List(java.util.List) FeedbackResultsResponseTable(teammates.ui.template.FeedbackResultsResponseTable) Map(java.util.Map)

Aggregations

FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)18 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)10 ArrayList (java.util.ArrayList)9 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)5 Text (com.google.appengine.api.datastore.Text)4 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)3 ElementTag (teammates.ui.template.ElementTag)3 InstructorFeedbackResultsResponseRow (teammates.ui.template.InstructorFeedbackResultsResponseRow)3 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)2 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)2 StatusMessage (teammates.common.util.StatusMessage)2 FeedbackResultsResponseTable (teammates.ui.template.FeedbackResultsResponseTable)2 InstructorFeedbackResultsModerationButton (teammates.ui.template.InstructorFeedbackResultsModerationButton)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1