Search in sources :

Example 16 with FeedbackQuestionsDb

use of teammates.storage.api.FeedbackQuestionsDb in project teammates by TEAMMATES.

the class InstructorFeedbackResponseCommentAddActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
    FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
    int questionNumber = 1;
    FeedbackQuestionAttributes question = feedbackQuestionsDb.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), questionNumber);
    String giverEmail = "student1InCourse1@gmail.tmt";
    String receiverEmail = "student1InCourse1@gmail.tmt";
    FeedbackResponseAttributes response = feedbackResponsesDb.getFeedbackResponse(question.getId(), giverEmail, receiverEmail);
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("Unsuccessful case: not enough parameters");
    verifyAssumptionFailure();
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response" };
    verifyAssumptionFailure(submissionParams);
    ______TS("typical successful case for unpublished session");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    InstructorFeedbackResponseCommentAddAction action = getAction(submissionParams);
    ShowPageResult result = getShowPageResult(action);
    InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("typical successful case for unpublished session empty giver permissions");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty giver permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("typical successful case for unpublished session shown to various recipients");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Null comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to giver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to own team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "OWN_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to students", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "STUDENTS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("typical successful case for published session");
    FeedbackSessionsLogic.inst().publishFeedbackSession(session);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response, published session", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    result = getShowPageResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Unsuccessful case: empty comment text");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
    action = getAction(submissionParams);
    AjaxResult ajaxResult = getAjaxResult(action);
    assertEquals("", ajaxResult.getStatusMessage());
    data = (InstructorFeedbackResponseCommentAjaxPageData) ajaxResult.data;
    assertTrue(data.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY, data.errorMessage);
}
Also used : FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) InstructorFeedbackResponseCommentAjaxPageData(teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AjaxResult(teammates.ui.controller.AjaxResult) ShowPageResult(teammates.ui.controller.ShowPageResult) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) InstructorFeedbackResponseCommentAddAction(teammates.ui.controller.InstructorFeedbackResponseCommentAddAction) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

Example 17 with FeedbackQuestionsDb

use of teammates.storage.api.FeedbackQuestionsDb 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)

Example 18 with FeedbackQuestionsDb

use of teammates.storage.api.FeedbackQuestionsDb in project teammates by TEAMMATES.

the class InstructorFeedbackResponseCommentEditActionTest method testAccessControl.

@Override
@Test
protected void testAccessControl() throws Exception {
    final FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
    final FeedbackResponsesDb frDb = new FeedbackResponsesDb();
    final FeedbackResponseCommentsDb frcDb = new FeedbackResponseCommentsDb();
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    int questionNumber = 1;
    FeedbackQuestionAttributes feedbackQuestion = fqDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
    String giverEmail = "student1InCourse1@gmail.tmt";
    String receiverEmail = "student1InCourse1@gmail.tmt";
    FeedbackResponseAttributes feedbackResponse = frDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
    FeedbackResponseCommentAttributes feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
    feedbackResponseComment = frcDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponse.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "comment", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
    // this person is not the giver. so not accessible
    verifyUnaccessibleWithoutModifySessionCommentInSectionsPrivilege(submissionParams);
    verifyOnlyInstructorsCanAccess(submissionParams);
}
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) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

Aggregations

FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)18 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)18 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)18 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)18 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)13 Test (org.testng.annotations.Test)8 RedirectResult (teammates.ui.controller.RedirectResult)8 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)6 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)5 FeedbackResponseCommentsDb (teammates.storage.api.FeedbackResponseCommentsDb)5 InstructorEditInstructorFeedbackSaveAction (teammates.ui.controller.InstructorEditInstructorFeedbackSaveAction)5 NullPostParameterException (teammates.common.exception.NullPostParameterException)4 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)4 InstructorEditStudentFeedbackSaveAction (teammates.ui.controller.InstructorEditStudentFeedbackSaveAction)4 AjaxResult (teammates.ui.controller.AjaxResult)3 InstructorFeedbackResponseCommentAjaxPageData (teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData)3 DataBundle (teammates.common.datatransfer.DataBundle)2 FeedbackNumericalScaleQuestionDetails (teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails)2 EmailWrapper (teammates.common.util.EmailWrapper)2 Text (com.google.appengine.api.datastore.Text)1