Search in sources :

Example 16 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackResponseRow method getTypeOfPeopleCanViewComment.

/**
 * Returns the type of people that can view the response comment.
 */
public String getTypeOfPeopleCanViewComment(FeedbackResponseCommentAttributes comment, FeedbackQuestionAttributes relatedQuestion) {
    StringBuilder peopleCanView = new StringBuilder(100);
    List<FeedbackParticipantType> showCommentTo;
    if (comment.isVisibilityFollowingFeedbackQuestion) {
        showCommentTo = relatedQuestion.showResponsesTo;
    } else {
        showCommentTo = comment.showCommentTo;
    }
    for (int i = 0; i < showCommentTo.size(); i++) {
        FeedbackParticipantType commentViewer = showCommentTo.get(i);
        if (i == showCommentTo.size() - 1 && showCommentTo.size() > 1) {
            peopleCanView.append("and ");
        }
        switch(commentViewer) {
            case GIVER:
                peopleCanView.append("response giver, ");
                break;
            case RECEIVER:
                peopleCanView.append("response recipient, ");
                break;
            case OWN_TEAM:
                peopleCanView.append("response giver's team, ");
                break;
            case RECEIVER_TEAM_MEMBERS:
                peopleCanView.append("response recipient's team, ");
                break;
            case STUDENTS:
                peopleCanView.append("other students in this course, ");
                break;
            case INSTRUCTORS:
                peopleCanView.append("instructors, ");
                break;
            default:
                break;
        }
    }
    String peopleCanViewString = peopleCanView.toString();
    return removeEndComma(peopleCanViewString);
}
Also used : FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 17 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackNumericalScaleQuestionDetails method getHiddenRecipients.

private List<String> getHiddenRecipients(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) {
    // List of recipients to hide
    List<String> hiddenRecipients = new ArrayList<>();
    FeedbackParticipantType type = question.recipientType;
    for (FeedbackResponseAttributes response : responses) {
        if (!bundle.visibilityTable.get(response.getId())[1] && type != FeedbackParticipantType.SELF && type != FeedbackParticipantType.NONE) {
            hiddenRecipients.add(response.recipient);
        }
    }
    return hiddenRecipients;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 18 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackQuestionAttributes method getVisibilityMessage.

// TODO: move following methods to PageData?
// Answer: OK to move to the respective PageData class. Unit test this thoroughly.
public List<String> getVisibilityMessage() {
    List<String> message = new ArrayList<>();
    for (FeedbackParticipantType participant : showResponsesTo) {
        StringBuilder line = new StringBuilder(100);
        // Exceptional case: self feedback
        if (participant == FeedbackParticipantType.RECEIVER && recipientType == FeedbackParticipantType.SELF) {
            message.add("You can see your own feedback in the results page later on.");
            continue;
        }
        // Front fragment: e.g. Other students in the course..., The receiving.., etc.
        line.append(participant.toVisibilityString()).append(' ');
        // Recipient fragment: e.g. student, instructor, etc.
        if (participant == FeedbackParticipantType.RECEIVER) {
            line.append(recipientType.toSingularFormString());
            if (numberOfEntitiesToGiveFeedbackTo > 1) {
                line.append('s');
            }
            line.append(' ');
        }
        line.append("can see your response");
        // Visibility fragment: e.g. can see your name, but not...
        if (showRecipientNameTo.contains(participant)) {
            if (participant != FeedbackParticipantType.RECEIVER && recipientType != FeedbackParticipantType.NONE) {
                line.append(", the name of the recipient");
            }
            if (showGiverNameTo.contains(participant)) {
                line.append(", and your name");
            } else {
                line.append(", but not your name");
            }
        } else {
            if (showGiverNameTo.contains(participant)) {
                line.append(", and your name");
            }
            if (recipientType == FeedbackParticipantType.NONE) {
                if (!showGiverNameTo.contains(participant)) {
                    line.append(", but not your name");
                }
            } else {
                line.append(", but not the name of the recipient");
                if (!showGiverNameTo.contains(participant)) {
                    line.append(", or your name");
                }
            }
        }
        line.append('.');
        message.add(line.toString());
    }
    if (message.isEmpty()) {
        message.add("No-one can see your responses.");
    }
    return message;
}
Also used : ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 19 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackRubricQuestionDetails method getQuestionResultStatisticsHtml.

@Override
public String getQuestionResultStatisticsHtml(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, String studentEmail, FeedbackSessionResultsBundle bundle, String view) {
    List<FeedbackResponseAttributes> responsesForStatistics = filterResponsesForStatistics(responses, question, studentEmail, bundle, view);
    FeedbackRubricQuestionDetails fqd = (FeedbackRubricQuestionDetails) question.getQuestionDetails();
    FeedbackParticipantType recipientType = question.getRecipientType();
    boolean isExcludingSelfOptionAvailable = recipientType.equals(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF);
    DecimalFormat weightFormat = new DecimalFormat("#.##");
    // Create table row header fragments
    StringBuilder tableHeaderFragmentHtml = new StringBuilder();
    String tableHeaderFragmentTemplate = FormTemplates.RUBRIC_RESULT_STATS_HEADER_FRAGMENT;
    for (int i = 0; i < numOfRubricChoices; i++) {
        String header = SanitizationHelper.sanitizeForHtml(rubricChoices.get(i)) + (fqd.hasAssignedWeights ? "<span style=\"font-weight:normal;\"> (Weight: " + weightFormat.format(rubricWeights.get(i)) + ")</span>" : "");
        String tableHeaderCell = Templates.populateTemplate(tableHeaderFragmentTemplate, Slots.RUBRIC_CHOICE_VALUE, header);
        tableHeaderFragmentHtml.append(tableHeaderCell).append(System.lineSeparator());
    }
    if (fqd.hasAssignedWeights) {
        String tableHeaderAverageCell = Templates.populateTemplate(tableHeaderFragmentTemplate, Slots.RUBRIC_CHOICE_VALUE, "Average");
        tableHeaderFragmentHtml.append(tableHeaderAverageCell).append(System.lineSeparator());
    }
    int[][] responseFrequency = RubricStatistics.calculateResponseFrequency(responsesForStatistics, fqd);
    float[][] rubricStats = RubricStatistics.calculatePercentageFrequencyAndAverage(fqd, responseFrequency);
    StringBuilder tableBodyHtml = getQuestionResultsStatisticsBodyHtml(fqd, responseFrequency, rubricStats);
    StringBuilder tableBodyExcludingSelfHtml;
    if (isExcludingSelfOptionAvailable) {
        int[][] responseFrequencyExcludingSelf = RubricStatistics.calculateResponseFrequencyExcludingSelf(responsesForStatistics, fqd);
        float[][] rubricStatsExcludingSelf = RubricStatistics.calculatePercentageFrequencyAndAverage(fqd, responseFrequencyExcludingSelf);
        tableBodyExcludingSelfHtml = getQuestionResultsStatisticsBodyHtml(fqd, responseFrequencyExcludingSelf, rubricStatsExcludingSelf);
    } else {
        tableBodyExcludingSelfHtml = new StringBuilder();
        tableBodyExcludingSelfHtml.append(System.lineSeparator());
    }
    String statsTitle = "Response Summary";
    if ("student".equals(view)) {
        if (responses.size() == responsesForStatistics.size()) {
            statsTitle = "Response Summary (of visible responses)";
        } else {
            statsTitle = "Response Summary (of received responses)";
        }
    }
    String recipientStatsHtml = "";
    if (hasAssignedWeights) {
        List<Map.Entry<String, RubricRecipientStatistics>> recipientStatsList = getPerRecipientStatisticsSorted(responses, bundle);
        StringBuilder bodyBuilder = new StringBuilder(100);
        for (Map.Entry<String, RubricRecipientStatistics> entry : recipientStatsList) {
            RubricRecipientStatistics stats = entry.getValue();
            bodyBuilder.append(stats.getHtmlForAllSubQuestions());
        }
        recipientStatsHtml = Templates.populateTemplate(FormTemplates.RUBRIC_RESULT_RECIPIENT_STATS, Slots.TABLE_HEADER_ROW_FRAGMENT_HTML, getRecipientStatsHeaderHtml(), Slots.TABLE_BODY_HTML, bodyBuilder.toString());
    }
    return Templates.populateTemplate(FormTemplates.RUBRIC_RESULT_STATS, Slots.STATS_TITLE, statsTitle, Slots.TABLE_HEADER_ROW_FRAGMENT_HTML, tableHeaderFragmentHtml.toString(), Slots.TABLE_BODY_HTML, tableBodyHtml.toString(), Slots.TABLE_BODY_EXCLUDING_SELF_HTML, tableBodyExcludingSelfHtml.toString(), Slots.EXCLUDING_SELF_OPTION_VISIBLE, isExcludingSelfOptionAvailable ? "" : "hidden", Slots.RUBRIC_RECIPIENT_STATS_HTML, recipientStatsHtml);
}
Also used : DecimalFormat(java.text.DecimalFormat) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with FeedbackParticipantType

use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.

the class FeedbackRubricQuestionDetails method filterResponsesForStatistics.

/**
 * Returns a list of FeedbackResponseAttributes filtered according to view, question recipient type
 * for the Statistics Table.
 */
private List<FeedbackResponseAttributes> filterResponsesForStatistics(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, String studentEmail, FeedbackSessionResultsBundle bundle, String view) {
    boolean isViewedByStudent = "student".equals(view);
    if (!isViewedByStudent) {
        return responses;
    }
    FeedbackParticipantType recipientType = question.getRecipientType();
    boolean isFilteringSkipped = recipientType.equals(FeedbackParticipantType.INSTRUCTORS) || recipientType.equals(FeedbackParticipantType.NONE) || recipientType.equals(FeedbackParticipantType.SELF);
    if (isFilteringSkipped) {
        return responses;
    }
    boolean isFilteringByTeams = recipientType.equals(FeedbackParticipantType.OWN_TEAM) || recipientType.equals(FeedbackParticipantType.TEAMS);
    List<FeedbackResponseAttributes> receivedResponses = new ArrayList<>();
    String recipientString = isFilteringByTeams ? bundle.getTeamNameForEmail(studentEmail) : studentEmail;
    for (FeedbackResponseAttributes response : responses) {
        boolean isReceivedResponse = response.recipient.equals(recipientString);
        if (isReceivedResponse) {
            receivedResponses.add(response);
        }
    }
    return receivedResponses;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Aggregations

FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)25 ArrayList (java.util.ArrayList)8 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)8 HashMap (java.util.HashMap)7 Text (com.google.appengine.api.datastore.Text)4 LinkedHashMap (java.util.LinkedHashMap)4 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)4 Map (java.util.Map)3 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)3 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 StudentResultSummary (teammates.common.datatransfer.StudentResultSummary)2 TeamEvalResult (teammates.common.datatransfer.TeamEvalResult)2 DecimalFormat (java.text.DecimalFormat)1 Matcher (java.util.regex.Matcher)1 WebElement (org.openqa.selenium.WebElement)1 Test (org.testng.annotations.Test)1 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)1