use of teammates.ui.template.FeedbackResultsResponse 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);
}
Aggregations