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();
}
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;
}
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);
}
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;
}
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]);
}
Aggregations