Search in sources :

Example 51 with FeedbackResponseAttributes

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;
}
Also used : InstructorFeedbackResultsResponseRow(teammates.ui.template.InstructorFeedbackResultsResponseRow) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) InstructorFeedbackResultsModerationButton(teammates.ui.template.InstructorFeedbackResultsModerationButton)

Example 52 with FeedbackResponseAttributes

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);
}
Also used : FeedbackResultsResponse(teammates.ui.template.FeedbackResultsResponse) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) ArrayList(java.util.ArrayList) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) FeedbackResultsResponseTable(teammates.ui.template.FeedbackResultsResponseTable)

Example 53 with FeedbackResponseAttributes

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);
    }
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes)

Example 54 with FeedbackResponseAttributes

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);
    }
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 55 with FeedbackResponseAttributes

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);
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackResponse(teammates.storage.entity.FeedbackResponse) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

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