Search in sources :

Example 16 with FeedbackResponseCommentAttributes

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

the class FeedbackResponseCommentsDbTest method testGetFeedbackResponseCommentFromCommentDetails.

private void testGetFeedbackResponseCommentFromCommentDetails() {
    ______TS("null parameter");
    try {
        frcDb.getFeedbackResponseComment(null, "", Instant.now());
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    try {
        frcDb.getFeedbackResponseComment("", null, Instant.now());
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    try {
        frcDb.getFeedbackResponseComment("", "", null);
        signalFailureToDetectException();
    } catch (AssertionError ae) {
        assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage());
    }
    ______TS("typical success case");
    FeedbackResponseCommentAttributes frcaExpected = frcaData;
    FeedbackResponseCommentAttributes frca = frcDb.getFeedbackResponseComment(frId, frcaExpected.giverEmail, frcaExpected.createdAt);
    // fill back the Ids
    frcaExpected.feedbackResponseId = frId;
    frcaExpected.setId(frca.getId());
    frcaExpected.feedbackQuestionId = frca.feedbackQuestionId;
    assertEquals(frcaExpected.toString(), frca.toString());
    ______TS("non-existent comment");
    assertNull(frcDb.getFeedbackResponseComment("123", frca.giverEmail, frca.createdAt));
    ______TS("non-existent giver");
    assertNull(frcDb.getFeedbackResponseComment(frca.getId().toString(), "nonExistentGiverEmail", frca.createdAt));
    assertNull(frcDb.getFeedbackResponseComment(frcaData.courseId, frcaData.createdAt, "nonExistentGiverEmail"));
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)

Example 17 with FeedbackResponseCommentAttributes

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

the class FeedbackResponseCommentSearchTest method verifySearchResults.

/*
     * Verifies that search results match with expected output.
     * Compares the text for each comment as it is unique.
     *
     * @param actual the results from the search query.
     * @param expected the expected results for the search query.
     */
private static void verifySearchResults(FeedbackResponseCommentSearchResultBundle actual, FeedbackResponseCommentAttributes... expected) {
    assertEquals(expected.length, actual.numberOfResults);
    assertEquals(expected.length, actual.comments.size());
    FeedbackResponseCommentAttributes.sortFeedbackResponseCommentsByCreationTime(Arrays.asList(expected));
    FeedbackResponseCommentAttributes[] sortedComments = Arrays.asList(expected).toArray(new FeedbackResponseCommentAttributes[2]);
    int i = 0;
    for (String key : actual.comments.keySet()) {
        for (FeedbackResponseCommentAttributes comment : actual.comments.get(key)) {
            assertEquals(sortedComments[i].commentText, comment.commentText);
            i++;
        }
    }
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)

Example 18 with FeedbackResponseCommentAttributes

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

the class InstructorFeedbackResultsPageData method buildFeedbackResponseCommentAddForm.

private FeedbackResponseCommentRow buildFeedbackResponseCommentAddForm(FeedbackQuestionAttributes question, FeedbackResponseAttributes response, Map<FeedbackParticipantType, Boolean> responseVisibilityMap, String giverName, String recipientName) {
    FeedbackResponseCommentAttributes frca = FeedbackResponseCommentAttributes.builder(question.courseId, question.feedbackSessionName, "", new Text("")).withFeedbackResponseId(response.getId()).withFeedbackQuestionId(question.getId()).build();
    FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.GIVER, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
    frca.showCommentTo = new ArrayList<>();
    frca.showGiverNameTo = new ArrayList<>();
    for (FeedbackParticipantType type : relevantTypes) {
        if (isResponseCommentVisibleTo(question, type)) {
            frca.showCommentTo.add(type);
        }
        if (isResponseCommentGiverNameVisibleTo(question, type)) {
            frca.showGiverNameTo.add(type);
        }
    }
    return new FeedbackResponseCommentRow(frca, giverName, recipientName, getResponseCommentVisibilityString(question), getResponseCommentGiverNameVisibilityString(question), responseVisibilityMap, bundle.getTimeZone());
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow) Text(com.google.appengine.api.datastore.Text) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType)

Example 19 with FeedbackResponseCommentAttributes

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

the class InstructorFeedbackResultsPageData method buildResponseComments.

private List<FeedbackResponseCommentRow> buildResponseComments(String giverName, String recipientName, FeedbackQuestionAttributes question, FeedbackResponseAttributes response) {
    List<FeedbackResponseCommentRow> comments = new ArrayList<>();
    List<FeedbackResponseCommentAttributes> frcAttributesList = bundle.responseComments.get(response.getId());
    if (frcAttributesList != null) {
        for (FeedbackResponseCommentAttributes frcAttributes : frcAttributesList) {
            comments.add(buildResponseComment(giverName, recipientName, question, response, frcAttributes));
        }
    }
    return comments;
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) ArrayList(java.util.ArrayList) FeedbackResponseCommentRow(teammates.ui.template.FeedbackResponseCommentRow)

Example 20 with FeedbackResponseCommentAttributes

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

the class FeedbackResponseCommentsLogic method updateFeedbackResponseCommentsForChangingResponseId.

public void updateFeedbackResponseCommentsForChangingResponseId(String oldResponseId, String newResponseId) throws InvalidParametersException, EntityDoesNotExistException {
    List<FeedbackResponseCommentAttributes> responseComments = getFeedbackResponseCommentForResponse(oldResponseId);
    for (FeedbackResponseCommentAttributes responseComment : responseComments) {
        responseComment.feedbackResponseId = newResponseId;
        updateFeedbackResponseComment(responseComment);
    }
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)

Aggregations

FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)46 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)15 Test (org.testng.annotations.Test)13 Text (com.google.appengine.api.datastore.Text)12 ArrayList (java.util.ArrayList)12 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)9 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)9 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)9 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)6 FeedbackResponseCommentsDb (teammates.storage.api.FeedbackResponseCommentsDb)6 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)5 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)5 InstructorFeedbackResponseCommentAjaxPageData (teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData)4 FeedbackResponseCommentRow (teammates.ui.template.FeedbackResponseCommentRow)4 InvalidParametersException (teammates.common.exception.InvalidParametersException)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 FeedbackResponseCommentSearchResultBundle (teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle)2 FeedbackSessionResultsBundle (teammates.common.datatransfer.FeedbackSessionResultsBundle)2