Search in sources :

Example 1 with FeedbackResultsResponseTable

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

the class StudentFeedbackResultsPageData method createResponseTable.

/**
 * Creates a feedback results responses table for a recipient.
 * @param question  Question for which the responses are generated
 * @param responsesBundleForRecipient  All responses for the question having a particular recipient
 * @return Feedback results responses table for a question and a recipient
 */
private FeedbackResultsResponseTable createResponseTable(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responsesBundleForRecipient, String recipientNameParam) {
    List<FeedbackResultsResponse> responses = new ArrayList<>();
    FeedbackQuestionDetails questionDetails = question.getQuestionDetails();
    String recipientName = removeAnonymousHash(recipientNameParam);
    for (FeedbackResponseAttributes response : responsesBundleForRecipient) {
        String giverName = bundle.getGiverNameForResponse(response);
        String displayedGiverName;
        /* Change display name to 'You' or 'Your team' or 'Anonymous student' if necessary */
        boolean isUserGiver = student.email.equals(response.giver);
        boolean isUserPartOfGiverTeam = student.team.equals(giverName);
        if (question.giverType == FeedbackParticipantType.TEAMS && isUserPartOfGiverTeam) {
            displayedGiverName = "Your Team (" + giverName + ")";
        } else if (isUserGiver) {
            displayedGiverName = "You";
        } else {
            displayedGiverName = removeAnonymousHash(giverName);
        }
        boolean isUserRecipient = student.email.equals(response.recipient);
        if (isUserGiver && !isUserRecipient) {
            // If the giver is the user, show the real name of the recipient
            // since the giver would know which recipient he/she gave the response to
            recipientName = bundle.getNameForEmail(response.recipient);
        }
        String answer = response.getResponseDetails().getAnswerHtmlStudentView(questionDetails);
        List<FeedbackResponseCommentRow> comments = createStudentFeedbackResultsResponseComments(response.getId());
        responses.add(new FeedbackResultsResponse(displayedGiverName, answer, comments));
    }
    return new FeedbackResultsResponseTable(recipientName, responses);
}
Also used : FeedbackResultsResponse(teammates.ui.template.FeedbackResultsResponse) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) FeedbackResultsResponseTable(teammates.ui.template.FeedbackResultsResponseTable)

Example 2 with FeedbackResultsResponseTable

use of teammates.ui.template.FeedbackResultsResponseTable 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)

Example 3 with FeedbackResultsResponseTable

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

the class StudentFeedbackResultsPageData method createResponseTables.

/**
 * Creates feedback results responses tables for every recipient.
 * @param question  Question for which the responses are generated
 * @param responsesBundle  All responses for a question
 * @return List of feedback results response tables for a question
 */
private List<FeedbackResultsResponseTable> createResponseTables(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responsesBundle) {
    List<FeedbackResultsResponseTable> responseTables = new ArrayList<>();
    List<String> recipients = new ArrayList<>();
    for (FeedbackResponseAttributes singleResponse : responsesBundle) {
        if (!recipients.contains(singleResponse.recipient)) {
            recipients.add(singleResponse.recipient);
        }
    }
    for (String recipient : recipients) {
        List<FeedbackResponseAttributes> responsesForRecipient = filterResponsesByRecipientEmail(recipient, responsesBundle);
        boolean isUserRecipient = student.email.equals(recipient);
        boolean isUserTeamRecipient = question.recipientType == FeedbackParticipantType.TEAMS && student.team.equals(recipient);
        String recipientName;
        if (isUserRecipient) {
            recipientName = "You";
        } else if (isUserTeamRecipient) {
            recipientName = String.format("Your Team (%s)", bundle.getNameForEmail(recipient));
        } else {
            recipientName = bundle.getNameForEmail(recipient);
        }
        responseTables.add(createResponseTable(question, responsesForRecipient, recipientName));
    }
    return responseTables;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackResultsResponseTable(teammates.ui.template.FeedbackResultsResponseTable)

Aggregations

ArrayList (java.util.ArrayList)3 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)3 FeedbackResultsResponseTable (teammates.ui.template.FeedbackResultsResponseTable)3 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)2 List (java.util.List)1 Map (java.util.Map)1 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)1 FeedbackResultsQuestionDetails (teammates.ui.template.FeedbackResultsQuestionDetails)1 FeedbackResultsResponse (teammates.ui.template.FeedbackResultsResponse)1 StudentFeedbackResultsQuestionWithResponses (teammates.ui.template.StudentFeedbackResultsQuestionWithResponses)1