use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageData method buildResponseRowsForQuestionForSingleParticipant.
private List<InstructorFeedbackResultsResponseRow> buildResponseRowsForQuestionForSingleParticipant(FeedbackQuestionAttributes question, List<FeedbackResponseAttributes> responses, String participantIdentifier, boolean isFirstGroupedByGiver) {
List<InstructorFeedbackResultsResponseRow> responseRows = new ArrayList<>();
List<String> possibleParticipantsWithoutResponses = isFirstGroupedByGiver ? bundle.getPossibleRecipients(question, participantIdentifier) : bundle.getPossibleGivers(question, participantIdentifier);
for (FeedbackResponseAttributes response : responses) {
if (!bundle.isGiverVisible(response) || !bundle.isRecipientVisible(response)) {
possibleParticipantsWithoutResponses.clear();
}
// keep track of possible participant who did not give/receive a response to/from the participantIdentifier
String participantWithResponse = isFirstGroupedByGiver ? response.recipient : response.giver;
removeParticipantIdentifierFromList(possibleParticipantsWithoutResponses, participantWithResponse);
InstructorFeedbackResultsModerationButton moderationButton = buildModerationButtonForExistingResponse(question, response);
InstructorFeedbackResultsResponseRow responseRow = new InstructorFeedbackResultsResponseRow(bundle.getGiverNameForResponse(response), bundle.getTeamNameForEmail(response.giver), bundle.getRecipientNameForResponse(response), bundle.getTeamNameForEmail(response.recipient), bundle.getResponseAnswerHtml(response, question), moderationButton);
configureResponseRow(response.giver, response.recipient, responseRow);
responseRows.add(responseRow);
}
if (isMissingResponsesShown) {
if (isFirstGroupedByGiver) {
responseRows.addAll(buildMissingResponseRowsBetweenGiverAndPossibleRecipients(question, possibleParticipantsWithoutResponses, participantIdentifier, bundle.getNameForEmail(participantIdentifier), bundle.getTeamNameForEmail(participantIdentifier)));
} else {
responseRows.addAll(buildMissingResponseRowsBetweenRecipientAndPossibleGivers(question, possibleParticipantsWithoutResponses, participantIdentifier, bundle.getNameForEmail(participantIdentifier), bundle.getTeamNameForEmail(participantIdentifier)));
}
}
return responseRows;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes 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);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponseCommentsLogic method updateFeedbackResponseCommentsForResponse.
// right now this method only updates comment's giverSection and receiverSection for a given response
public void updateFeedbackResponseCommentsForResponse(String feedbackResponseId) throws InvalidParametersException, EntityDoesNotExistException {
List<FeedbackResponseCommentAttributes> comments = getFeedbackResponseCommentForResponse(feedbackResponseId);
FeedbackResponseAttributes response = frLogic.getFeedbackResponse(feedbackResponseId);
for (FeedbackResponseCommentAttributes comment : comments) {
comment.giverSection = response.giverSection;
comment.receiverSection = response.recipientSection;
frcDb.updateFeedbackResponseComment(comment);
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method updateFeedbackResponse.
/**
* Updates a {@link FeedbackResponse} using a {@link FeedbackResponseAttributes} <br>
* If the giver/recipient field is changed, the {@link FeedbackResponse} is
* updated by recreating the response<br>
* in order to prevent an id clash if the previous email is reused later on.
* @param oldResponseEntity a FeedbackResponse retrieved from the database
* @throws EntityAlreadyExistsException if trying to prevent an id clash by recreating a response,
* a response with the same id already exist.
*/
public void updateFeedbackResponse(FeedbackResponseAttributes updatedResponse, FeedbackResponse oldResponseEntity) throws InvalidParametersException, EntityAlreadyExistsException, EntityDoesNotExistException {
Assumption.assertNotNull(oldResponseEntity);
// Create a copy.
FeedbackResponseAttributes newResponse = new FeedbackResponseAttributes(updatedResponse);
FeedbackResponseAttributes oldResponse = new FeedbackResponseAttributes(oldResponseEntity);
// Copy values that cannot be changed to defensively avoid invalid
// parameters.
copyFixedValuesFromOldToNew(newResponse, oldResponse);
if (newResponse.recipient.equals(oldResponse.recipient) && newResponse.giver.equals(oldResponse.giver)) {
try {
frDb.updateFeedbackResponseOptimized(newResponse, oldResponseEntity);
} catch (EntityDoesNotExistException e) {
Assumption.fail();
}
} else {
// Recreate response to prevent possible future id conflict.
recreateResponse(newResponse, oldResponse);
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method updateFeedbackResponse.
/**
* Updates a {@link FeedbackResponse} based on it's {@code id}.<br>
* If the giver/recipient field is changed, the {@link FeedbackResponse} is
* updated by recreating the response<br>
* in order to prevent an id clash if the previous email is reused later on.
*/
public void updateFeedbackResponse(FeedbackResponseAttributes responseToUpdate) throws InvalidParametersException, EntityDoesNotExistException, EntityAlreadyExistsException {
// Create a copy.
FeedbackResponseAttributes newResponse = new FeedbackResponseAttributes(responseToUpdate);
FeedbackResponse oldResponseEntity = null;
if (newResponse.getId() == null) {
oldResponseEntity = frDb.getFeedbackResponseEntityWithCheck(newResponse.feedbackQuestionId, newResponse.giver, newResponse.recipient);
} else {
oldResponseEntity = frDb.getFeedbackResponseEntityWithCheck(newResponse.getId());
}
FeedbackResponseAttributes oldResponse = null;
if (oldResponseEntity != null) {
oldResponse = new FeedbackResponseAttributes(oldResponseEntity);
}
if (oldResponse == null) {
throw new EntityDoesNotExistException("Trying to update a feedback response that does not exist.");
}
updateFeedbackResponse(newResponse, oldResponseEntity);
}
Aggregations