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