use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.
the class FeedbackResponseCommentSearchTest method allTests.
@Test
public void allTests() {
FeedbackResponseCommentsDb commentsDb = new FeedbackResponseCommentsDb();
FeedbackResponseCommentAttributes frc1I1Q1S1C1 = dataBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
FeedbackResponseCommentAttributes frc1I1Q2S1C1 = dataBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q2S1C1");
FeedbackResponseCommentAttributes frc1I3Q1S1C2 = dataBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C2");
ArrayList<InstructorAttributes> instructors = new ArrayList<InstructorAttributes>();
______TS("success: search for comments; no results found as instructor doesn't have privileges");
instructors.add(dataBundle.instructors.get("helperOfCourse1"));
FeedbackResponseCommentSearchResultBundle bundle = commentsDb.search("\"self-feedback\"", instructors);
assertEquals(0, bundle.numberOfResults);
assertTrue(bundle.comments.isEmpty());
______TS("success: search for comments; query string does not match any comment");
instructors.clear();
instructors.add(dataBundle.instructors.get("instructor3OfCourse1"));
instructors.add(dataBundle.instructors.get("instructor3OfCourse2"));
bundle = commentsDb.search("non-existent", instructors);
assertEquals(0, bundle.numberOfResults);
assertTrue(bundle.comments.isEmpty());
______TS("success: search for comments; query string matches single comment");
bundle = commentsDb.search("\"Instructor 3 comment to instr1C2 response to student1C2\"", instructors);
verifySearchResults(bundle, frc1I3Q1S1C2);
______TS("success: search for comments in instructor's course; query string matches some comments");
bundle = commentsDb.search("\"self feedback\"", instructors);
verifySearchResults(bundle, frc1I1Q1S1C1, frc1I1Q2S1C1);
______TS("success: search for comments in instructor's course; confirms query string is case insensitive");
bundle = commentsDb.search("\"Instructor 1 COMMENT to student 1 self feedback Question 2\"", instructors);
verifySearchResults(bundle, frc1I1Q2S1C1);
______TS("success: search for comments using feedbackSessionName");
bundle = commentsDb.search("\"First feedback session\"", instructors);
verifySearchResults(bundle, frc1I1Q2S1C1, frc1I1Q1S1C1);
______TS("success: search for comments using Instructor's email");
bundle = commentsDb.search("instructor1@course1.tmt", instructors);
verifySearchResults(bundle, frc1I1Q2S1C1, frc1I1Q1S1C1);
______TS("success: search for comments using Student name");
bundle = commentsDb.search("\"student2 In Course1\"", instructors);
verifySearchResults(bundle, frc1I1Q2S1C1);
______TS("success: search for comments; confirms deleted comments are not included in results");
commentsDb.deleteDocument(frc1I3Q1S1C2);
bundle = commentsDb.search("\"Instructor 3 comment to instr1C2 response to student1C2\"", instructors);
verifySearchResults(bundle);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.
the class FeedbackSessionResultsBundle method getCsvDetailedFeedbackResponseCommentsRow.
public StringBuilder getCsvDetailedFeedbackResponseCommentsRow(FeedbackResponseAttributes response) {
List<FeedbackResponseCommentAttributes> frcList = this.responseComments.get(response.getId());
StringBuilder commentRow = new StringBuilder(200);
for (FeedbackResponseCommentAttributes frc : frcList) {
commentRow.append("," + instructorEmailNameTable.get(frc.giverEmail) + "," + getTextFromComment(frc.commentText));
}
return commentRow;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.
the class FeedbackResponseCommentAttributesTest method testBuilderWithNullValues.
@Test
public void testBuilderWithNullValues() {
FeedbackResponseCommentAttributes feedbackAttributes = FeedbackResponseCommentAttributes.builder("course", "name", "email", new Text("")).withFeedbackResponseId(null).withFeedbackQuestionId(null).withShowGiverNameTo(null).withShowCommentTo(null).withLastEditorEmail(null).withReceiverSection(null).withGiverSection(null).withCreatedAt(Instant.now()).withLastEditedAt(null).withFeedbackResponseCommentId(null).withVisibilityFollowingFeedbackQuestion(null).build();
// Default values for following fields
assertEquals(feedbackAttributes.giverSection, "None");
assertEquals(feedbackAttributes.receiverSection, "None");
assertEquals(feedbackAttributes.lastEditorEmail, feedbackAttributes.giverEmail);
assertEquals(feedbackAttributes.lastEditedAt, feedbackAttributes.createdAt);
assertTrue(feedbackAttributes.isVisibilityFollowingFeedbackQuestion);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentAddActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
final FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
final FeedbackResponsesDb frDb = new FeedbackResponsesDb();
final FeedbackResponseCommentsDb frcDb = new FeedbackResponseCommentsDb();
int questionNumber = 1;
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackQuestionAttributes question = fqDb.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes response = frDb.getFeedbackResponse(question.getId(), giverEmail, receiverEmail);
FeedbackResponseCommentAttributes comment = FeedbackResponseCommentAttributes.builder(fs.getCourseId(), fs.getFeedbackSessionName(), giverEmail, new Text("")).withFeedbackQuestionId(question.getId()).withFeedbackResponseId(response.getId()).build();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, comment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, comment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.FEEDBACK_QUESTION_ID, comment.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_ID, comment.feedbackResponseId, Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
verifyUnaccessibleWithoutSubmitSessionInSectionsPrivilege(submissionParams);
verifyUnaccessibleWithoutLogin(submissionParams);
verifyUnaccessibleForUnregisteredUsers(submissionParams);
verifyUnaccessibleForStudents(submissionParams);
verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
// remove the comment
frcDb.deleteEntity(comment);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentDeleteActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
final FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
final FeedbackResponsesDb frDb = new FeedbackResponsesDb();
final FeedbackResponseCommentsDb frcDb = new FeedbackResponseCommentsDb();
int questionNumber = 2;
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackResponseCommentAttributes comment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q2S1C1");
FeedbackResponseAttributes response = typicalBundle.feedbackResponses.get("response1ForQ2S1C1");
FeedbackQuestionAttributes question = fqDb.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), questionNumber);
response = frDb.getFeedbackResponse(question.getId(), response.giver, response.recipient);
comment = frcDb.getFeedbackResponseComment(response.getId(), comment.giverEmail, comment.createdAt);
comment.feedbackResponseId = response.getId();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, String.valueOf(comment.getId()) };
verifyUnaccessibleWithoutSubmitSessionInSectionsPrivilege(submissionParams);
verifyUnaccessibleWithoutLogin(submissionParams);
verifyUnaccessibleForUnregisteredUsers(submissionParams);
verifyUnaccessibleForStudents(submissionParams);
verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
}
Aggregations