Search in sources :

Example 26 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackContributionQuestionDetails method getQuestionResultStatisticsCsv.

@Override
public String getQuestionResultStatisticsCsv(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) {
    if (responses.isEmpty()) {
        return "";
    }
    List<FeedbackResponseAttributes> actualResponses = getActualResponses(question, bundle);
    // List of teams visible to the instructor and in the selected section
    List<String> teamNames = getTeamNames(bundle);
    // Each team's member(email) list
    Map<String, List<String>> teamMembersEmail = getTeamMembersEmail(bundle, teamNames);
    // Each team's responses
    Map<String, List<FeedbackResponseAttributes>> teamResponses = getTeamResponses(actualResponses, bundle, teamNames);
    // Get each team's submission array. -> int[teamSize][teamSize]
    // Where int[0][1] refers points from student 0 to student 1
    // Where student 0 is the 0th student in the list in teamMembersEmail
    Map<String, int[][]> teamSubmissionArray = getTeamSubmissionArray(teamNames, teamMembersEmail, teamResponses);
    // Each team's eval results.
    Map<String, TeamEvalResult> teamResults = getTeamResults(teamNames, teamSubmissionArray, teamMembersEmail);
    // Each person's results summary
    Map<String, StudentResultSummary> studentResults = getStudentResults(teamMembersEmail, teamResults);
    // Check visibility of recipient
    boolean hideRecipient = false;
    FeedbackParticipantType type = question.recipientType;
    for (FeedbackResponseAttributes response : actualResponses) {
        if (!bundle.visibilityTable.get(response.getId())[1] && type != FeedbackParticipantType.SELF && type != FeedbackParticipantType.NONE) {
            hideRecipient = true;
        }
    }
    StringBuilder contribFragments = new StringBuilder();
    Map<String, String> sortedMap = new LinkedHashMap<>();
    for (Map.Entry<String, StudentResultSummary> entry : studentResults.entrySet()) {
        StudentResultSummary summary = entry.getValue();
        String email = entry.getKey();
        String name = bundle.roster.getStudentForEmail(email).name;
        String team = bundle.roster.getStudentForEmail(email).team;
        List<String> teamEmails = teamMembersEmail.get(team);
        TeamEvalResult teamResult = teamResults.get(team);
        int studentIndx = teamEmails.indexOf(email);
        String displayName;
        String displayTeam;
        String displayEmail;
        if (hideRecipient) {
            displayName = FeedbackSessionResultsBundle.getAnonName(type, name);
            displayTeam = displayName + Const.TEAM_OF_EMAIL_OWNER;
            displayEmail = Const.USER_NOBODY_TEXT;
        } else {
            displayName = name;
            displayTeam = team;
            displayEmail = email;
        }
        int[] incomingPoints = new int[teamResult.normalizedPeerContributionRatio.length];
        for (int i = 0; i < incomingPoints.length; i++) {
            incomingPoints[i] = teamResult.normalizedPeerContributionRatio[i][studentIndx];
        }
        String contribFragmentString = SanitizationHelper.sanitizeForCsv(displayTeam) + "," + SanitizationHelper.sanitizeForCsv(displayName) + "," + SanitizationHelper.sanitizeForCsv(displayEmail) + "," + SanitizationHelper.sanitizeForCsv(Integer.toString(summary.claimedToInstructor)) + "," + SanitizationHelper.sanitizeForCsv(Integer.toString(summary.perceivedToInstructor)) + "," + SanitizationHelper.sanitizeForCsv(getNormalizedPointsListDescending(incomingPoints, studentIndx)) + System.lineSeparator();
        // Replace all Unset values
        contribFragmentString = contribFragmentString.replaceAll(Integer.toString(Const.INT_UNINITIALIZED), "N/A");
        contribFragmentString = contribFragmentString.replaceAll(Integer.toString(Const.POINTS_NOT_SURE), "Not Sure");
        contribFragmentString = contribFragmentString.replaceAll(Integer.toString(Const.POINTS_NOT_SUBMITTED), "Not Submitted");
        // For sorting purposes
        sortedMap.put(displayTeam + "-%-" + displayName, contribFragmentString);
    }
    sortedMap.forEach((key, value) -> contribFragments.append(value));
    String csvPointsExplanation = "In the points given below, an equal share is equal to 100 points. " + "e.g. 80 means \"Equal share - 20%\" and 110 means \"Equal share + 10%\"." + System.lineSeparator() + "Claimed Contribution (CC) = the contribution claimed by the student." + System.lineSeparator() + "Perceived Contribution (PC) = the average value of student's contribution " + "as perceived by the team members." + System.lineSeparator() + "Team, Name, Email, CC, PC, Ratings Recieved" + System.lineSeparator();
    return csvPointsExplanation + contribFragments + System.lineSeparator();
}
Also used : StudentResultSummary(teammates.common.datatransfer.StudentResultSummary) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) LinkedHashMap(java.util.LinkedHashMap) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TeamEvalResult(teammates.common.datatransfer.TeamEvalResult) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 27 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackContributionQuestionDetails method validateResponseAttributes.

@Override
public List<String> validateResponseAttributes(List<FeedbackResponseAttributes> responses, int numRecipients) {
    List<String> errors = new ArrayList<>();
    for (FeedbackResponseAttributes response : responses) {
        boolean validAnswer = false;
        FeedbackContributionResponseDetails frd = (FeedbackContributionResponseDetails) response.getResponseDetails();
        // Valid answers: 0, 10, 20, .... 190, 200
        boolean isValidRange = frd.getAnswer() >= 0 && frd.getAnswer() <= 200;
        boolean isMultipleOf10 = frd.getAnswer() % 10 == 0;
        if (isValidRange && isMultipleOf10) {
            validAnswer = true;
        }
        if (frd.getAnswer() == Const.POINTS_NOT_SURE || frd.getAnswer() == Const.POINTS_NOT_SUBMITTED) {
            validAnswer = true;
        }
        if (!validAnswer) {
            errors.add(Const.FeedbackQuestion.CONTRIB_ERROR_INVALID_OPTION);
        }
    }
    return errors;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList)

Example 28 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackContributionQuestionDetails method getQuestionResultsStatisticsHtmlQuestionView.

private String getQuestionResultsStatisticsHtmlQuestionView(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) {
    if (responses.isEmpty()) {
        return "";
    }
    List<FeedbackResponseAttributes> actualResponses = getActualResponses(question, bundle);
    // List of teams visible to the instructor and in the selected section
    List<String> teamNames = getTeamNames(bundle);
    // Each team's member(email) list
    Map<String, List<String>> teamMembersEmail = getTeamMembersEmail(bundle, teamNames);
    // Each team's responses
    Map<String, List<FeedbackResponseAttributes>> teamResponses = getTeamResponses(actualResponses, bundle, teamNames);
    // Get each team's submission array. -> int[teamSize][teamSize]
    // Where int[0][1] refers points from student 0 to student 1
    // Where student 0 is the 0th student in the list in teamMembersEmail
    Map<String, int[][]> teamSubmissionArray = getTeamSubmissionArray(teamNames, teamMembersEmail, teamResponses);
    // Each team's eval results.
    Map<String, TeamEvalResult> teamResults = getTeamResults(teamNames, teamSubmissionArray, teamMembersEmail);
    // Each person's results summary
    Map<String, StudentResultSummary> studentResults = getStudentResults(teamMembersEmail, teamResults);
    // Check visibility of recipient
    boolean hideRecipient = false;
    FeedbackParticipantType type = question.recipientType;
    for (FeedbackResponseAttributes response : actualResponses) {
        if (!bundle.visibilityTable.get(response.getId())[1] && type != FeedbackParticipantType.SELF && type != FeedbackParticipantType.NONE) {
            hideRecipient = true;
        }
    }
    StringBuilder contribFragments = new StringBuilder();
    for (Map.Entry<String, StudentResultSummary> entry : studentResults.entrySet()) {
        StudentResultSummary summary = entry.getValue();
        String email = entry.getKey();
        String name = bundle.roster.getStudentForEmail(email).name;
        String team = bundle.roster.getStudentForEmail(email).team;
        List<String> teamEmails = teamMembersEmail.get(team);
        TeamEvalResult teamResult = teamResults.get(team);
        int studentIndx = teamEmails.indexOf(email);
        String displayName = name;
        String displayTeam = team;
        if (hideRecipient) {
            displayName = FeedbackSessionResultsBundle.getAnonName(type, name);
            displayTeam = displayName + Const.TEAM_OF_EMAIL_OWNER;
        }
        int[] incomingPoints = new int[teamResult.normalizedPeerContributionRatio.length];
        for (int i = 0; i < incomingPoints.length; i++) {
            incomingPoints[i] = teamResult.normalizedPeerContributionRatio[i][studentIndx];
        }
        contribFragments.append(Templates.populateTemplate(FormTemplates.CONTRIB_RESULT_STATS_FRAGMENT, Slots.CONTRIB_STUDENT_TEAM, SanitizationHelper.sanitizeForHtml(displayTeam), Slots.CONTRIB_STUDENT_NAME, SanitizationHelper.sanitizeForHtml(displayName), Slots.CONTRIB_CC, getPointsAsColorizedHtml(summary.claimedToInstructor), Slots.CONTRIB_PC, getPointsAsColorizedHtml(summary.perceivedToInstructor), Slots.CONTRIB_DIFF, getPointsDiffAsHtml(summary), Slots.CONTRIB_RR, getNormalizedPointsListColorizedDescending(incomingPoints, studentIndx), Slots.CONTRIB_PARAM_STUDENT_NAME, Const.ParamsNames.STUDENT_NAME));
    }
    return Templates.populateTemplate(FormTemplates.CONTRIB_RESULT_STATS, Slots.CONTRIB_FRAGMENTS, contribFragments.toString(), Slots.CONTRIB_TOOLTIPS_CLAIMED, SanitizationHelper.sanitizeForHtml(Const.Tooltips.CLAIMED), Slots.CONTRIB_TOOLTIPS_PERCEIVED, Const.Tooltips.PERCEIVED, Slots.CONTRIB_TOOLTIPS_POINTS_RECEIVED, Const.Tooltips.FEEDBACK_CONTRIBUTION_POINTS_RECEIVED, Slots.CONTRIB_TOOLTIPS_DIFF, Const.Tooltips.FEEDBACK_CONTRIBUTION_DIFF);
}
Also used : StudentResultSummary(teammates.common.datatransfer.StudentResultSummary) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TeamEvalResult(teammates.common.datatransfer.TeamEvalResult) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 29 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackContributionResponseDetails method getContributionQuestionResponseAnswerCsv.

private String getContributionQuestionResponseAnswerCsv(FeedbackResponseAttributes response, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle feedbackSessionResultsBundle) {
    Map<String, TeamEvalResult> teamResults = getContribQnTeamEvalResult(question, feedbackSessionResultsBundle);
    Map<String, StudentResultSummary> stats = getContribQnStudentResultSummary(question, feedbackSessionResultsBundle);
    // Need to get actual team name and giver/recipient emails here,
    // only for getting the responseAnswer.
    FeedbackResponseAttributes actualResponse = feedbackSessionResultsBundle.getActualResponse(response);
    String giverTeamName = feedbackSessionResultsBundle.emailTeamNameTable.get(actualResponse.giver);
    TeamEvalResult teamResult = teamResults.get(giverTeamName);
    int giverIndex = teamResult.studentEmails.indexOf(actualResponse.giver);
    int recipientIndex = teamResult.studentEmails.indexOf(actualResponse.recipient);
    String responseAnswerCsv = "";
    if (giverIndex == -1 || recipientIndex == -1) {
        if (giverIndex == -1) {
            log.severe("getContributionQuestionResponseAnswerCsv - giverIndex is -1\n" + "Cannot find giver: " + actualResponse.giver + "\n" + "CourseId: " + feedbackSessionResultsBundle.feedbackSession.getCourseId() + "\n" + "Session Name: " + feedbackSessionResultsBundle.feedbackSession.getFeedbackSessionName() + "\n" + "Response Id: " + actualResponse.getId());
        }
        if (recipientIndex == -1) {
            log.severe("getContributionQuestionResponseAnswerCsv - recipientIndex is -1\n" + "Cannot find recipient: " + actualResponse.recipient + "\n" + "CourseId: " + feedbackSessionResultsBundle.feedbackSession.getCourseId() + "\n" + "Session Name: " + feedbackSessionResultsBundle.feedbackSession.getFeedbackSessionName() + "\n" + "Response Id: " + actualResponse.getId());
        }
    } else {
        responseAnswerCsv = SanitizationHelper.sanitizeForCsv(FeedbackContributionQuestionDetails.convertToEqualShareFormat(teamResult.normalizedPeerContributionRatio[giverIndex][recipientIndex]));
        if (response.giver.equals(response.recipient)) {
            StudentResultSummary studentResult = stats.get(response.giver);
            responseAnswerCsv = SanitizationHelper.sanitizeForCsv(FeedbackContributionQuestionDetails.convertToEqualShareFormat(studentResult.claimedToInstructor));
        }
    }
    return responseAnswerCsv;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TeamEvalResult(teammates.common.datatransfer.TeamEvalResult) StudentResultSummary(teammates.common.datatransfer.StudentResultSummary)

Example 30 with FeedbackResponseAttributes

use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.

the class FeedbackContributionResponseDetails method getContributionQuestionResponseAnswerHtml.

private String getContributionQuestionResponseAnswerHtml(FeedbackResponseAttributes response, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle feedbackSessionResultsBundle) {
    Map<String, TeamEvalResult> teamResults = getContribQnTeamEvalResult(question, feedbackSessionResultsBundle);
    // Need to get actual team name and giver/recipient emails here,
    // only for getting the responseAnswer.
    FeedbackResponseAttributes actualResponse = feedbackSessionResultsBundle.getActualResponse(response);
    String giverTeamName = feedbackSessionResultsBundle.emailTeamNameTable.get(actualResponse.giver);
    TeamEvalResult teamResult = teamResults.get(giverTeamName);
    int giverIndex = teamResult.studentEmails.indexOf(actualResponse.giver);
    int recipientIndex = teamResult.studentEmails.indexOf(actualResponse.recipient);
    if (giverIndex == -1 || recipientIndex == -1) {
        if (giverIndex == -1) {
            log.severe("getContributionQuestionResponseAnswerHtml - giverIndex is -1\n" + "Cannot find giver: " + actualResponse.giver + "\n" + "CourseId: " + feedbackSessionResultsBundle.feedbackSession.getCourseId() + "\n" + "Session Name: " + feedbackSessionResultsBundle.feedbackSession.getFeedbackSessionName() + "\n" + "Response Id: " + actualResponse.getId());
        }
        if (recipientIndex == -1) {
            log.severe("getContributionQuestionResponseAnswerHtml - recipientIndex is -1\n" + "Cannot find recipient: " + actualResponse.recipient + "\n" + "CourseId: " + feedbackSessionResultsBundle.feedbackSession.getCourseId() + "\n" + "Session Name: " + feedbackSessionResultsBundle.feedbackSession.getFeedbackSessionName() + "\n" + "Response Id: " + actualResponse.getId());
        }
        return "";
    }
    Map<String, StudentResultSummary> stats = getContribQnStudentResultSummary(question, feedbackSessionResultsBundle);
    if (response.giver.equals(response.recipient)) {
        StudentResultSummary studentResult = stats.get(response.giver);
        String responseAnswerHtml = FeedbackContributionQuestionDetails.convertToEqualShareFormatHtml(studentResult.claimedToInstructor);
        // For CONTRIB qns, We want to show PC if giver == recipient.
        int pc = studentResult.perceivedToInstructor;
        return responseAnswerHtml + FeedbackContributionQuestionDetails.getPerceivedContributionInEqualShareFormatHtml(pc);
    }
    return FeedbackContributionQuestionDetails.convertToEqualShareFormatHtml(teamResult.normalizedPeerContributionRatio[giverIndex][recipientIndex]);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TeamEvalResult(teammates.common.datatransfer.TeamEvalResult) StudentResultSummary(teammates.common.datatransfer.StudentResultSummary)

Aggregations

FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)143 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)70 ArrayList (java.util.ArrayList)63 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)36 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)35 List (java.util.List)29 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)28 HashMap (java.util.HashMap)27 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)22 HashSet (java.util.HashSet)20 LinkedHashMap (java.util.LinkedHashMap)20 Map (java.util.Map)18 Test (org.testng.annotations.Test)18 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)18 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)18 Text (com.google.appengine.api.datastore.Text)15 Set (java.util.Set)11 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)10 Comparator (java.util.Comparator)9 FeedbackParticipantType (teammates.common.datatransfer.FeedbackParticipantType)9