Search in sources :

Example 31 with FeedbackResponseCommentAttributes

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);
}
Also used : FeedbackResponseCommentsDb(teammates.storage.api.FeedbackResponseCommentsDb) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) ArrayList(java.util.ArrayList) FeedbackResponseCommentSearchResultBundle(teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 32 with FeedbackResponseCommentAttributes

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

Example 33 with FeedbackResponseCommentAttributes

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);
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) Text(com.google.appengine.api.datastore.Text) Test(org.testng.annotations.Test)

Example 34 with FeedbackResponseCommentAttributes

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);
}
Also used : FeedbackResponseCommentsDb(teammates.storage.api.FeedbackResponseCommentsDb) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) Text(com.google.appengine.api.datastore.Text) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

Example 35 with FeedbackResponseCommentAttributes

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);
}
Also used : FeedbackResponseCommentsDb(teammates.storage.api.FeedbackResponseCommentsDb) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

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