Search in sources :

Example 16 with InstructorAttributes

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

the class InstructorFeedbackQuestionEditActionTest method testExecuteAndPostProcessConstSumOption.

@Test
public void testExecuteAndPostProcessConstSumOption() {
    DataBundle dataBundle = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
    removeAndRestoreDataBundle(dataBundle);
    InstructorAttributes instructor1ofCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("constSumSession");
    FeedbackQuestionAttributes fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
    FeedbackResponsesDb frDb = new FeedbackResponsesDb();
    ______TS("Edit text");
    // There are already responses for this question
    assertFalse(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
    String[] editTextParams = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.giverType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, fq.recipientType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "CONSTSUM", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Split points among the options.(edited)", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTS, "100", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSFOREACHOPTION, "50", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSFOREACHRECIPIENT, "30", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSPEROPTION, "false", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "3", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-0", "Grades", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-1", "Fun", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMTORECIPIENTS, "false", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    InstructorFeedbackQuestionEditAction a = getAction(editTextParams);
    RedirectResult r = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, "FSQTT.idOfTypicalCourse1", "CONSTSUM+Session", "FSQTT.idOfInstructor1OfCourse1", false), r.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, r.getStatusMessage());
    assertFalse(r.isError);
    // All existing responses should remain
    assertFalse(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
    ______TS("Edit points");
    String[] editPointsParams = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.giverType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, fq.recipientType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "CONSTSUM", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Split points among the options.(edited)", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTS, "1000", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSFOREACHOPTION, "300", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSFOREACHRECIPIENT, "500", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSPEROPTION, "false", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "3", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-0", "Grades", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-1", "Fun", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMTORECIPIENTS, "false", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
    a = getAction(editPointsParams);
    r = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, "FSQTT.idOfTypicalCourse1", "CONSTSUM+Session", "FSQTT.idOfInstructor1OfCourse1", false), r.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, r.getStatusMessage());
    assertFalse(r.isError);
    // All existing responses should be deleted as the options are edited
    assertTrue(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackQuestionEditAction(teammates.ui.controller.InstructorFeedbackQuestionEditAction) DataBundle(teammates.common.datatransfer.DataBundle) RedirectResult(teammates.ui.controller.RedirectResult) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 17 with InstructorAttributes

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

the class InstructorFeedbackRemindParticularStudentsActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    StudentAttributes studentNotSubmitFeedback = typicalBundle.students.get("student5InCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    ______TS("Unsuccessful case: Not enough parameters");
    String[] paramsNoCourseId = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getSessionName() };
    verifyAssumptionFailure(paramsNoCourseId);
    String[] paramsNoFeedback = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId() };
    verifyAssumptionFailure(paramsNoFeedback);
    ______TS("Unsuccessful case: No user to remind, warning message generated");
    String[] paramsNoUserToRemind = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getSessionName() };
    InstructorFeedbackRemindParticularStudentsAction action = getAction(paramsNoUserToRemind);
    RedirectResult rr = getRedirectResult(action);
    assertTrue(rr.getStatusMessage().contains(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSEMPTYRECIPIENT));
    verifyNoTasksAdded(action);
    ______TS("Unsuccessful case: Feedback session not open, warning message generated");
    fs = typicalBundle.feedbackSessions.get("awaiting.session");
    String[] paramsFeedbackSessionNotOpen = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getSessionName(), Const.ParamsNames.SUBMISSION_REMIND_USERLIST, studentNotSubmitFeedback.getEmail() };
    action = getAction(paramsFeedbackSessionNotOpen);
    rr = getRedirectResult(action);
    assertTrue(rr.getStatusMessage().contains(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSSESSIONNOTOPEN));
    verifyNoTasksAdded(action);
    ______TS("Successful case: Typical case");
    fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] paramsTypical = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getSessionName(), Const.ParamsNames.SUBMISSION_REMIND_USERLIST, studentNotSubmitFeedback.getEmail() };
    action = getAction(paramsTypical);
    rr = getRedirectResult(action);
    assertTrue(rr.getStatusMessage().contains(Const.StatusMessages.FEEDBACK_SESSION_REMINDERSSENT));
    verifySpecifiedTasksAdded(action, TaskQueue.FEEDBACK_SESSION_REMIND_PARTICULAR_USERS_EMAIL_QUEUE_NAME, 1);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackRemindParticularStudentsAction(teammates.ui.controller.InstructorFeedbackRemindParticularStudentsAction) RedirectResult(teammates.ui.controller.RedirectResult) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 18 with InstructorAttributes

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

the class InstructorFeedbackRemindParticularStudentsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    String instructorId = instructor1OfCourse1.googleId;
    CourseAttributes course = typicalBundle.courses.get("typicalCourse1");
    FeedbackSessionAttributes fsa = typicalBundle.feedbackSessions.get("session1InCourse1");
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("Not enough parameters");
    verifyAssumptionFailure();
    ______TS("Typical case");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fsa.getFeedbackSessionName() };
    InstructorFeedbackRemindParticularStudentsPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    InstructorFeedbackRemindParticularStudentsPageData pageData = (InstructorFeedbackRemindParticularStudentsPageData) r.data;
    assertEquals(6, pageData.getResponseStatus().studentsWhoDidNotRespond.size());
    assertEquals(3, pageData.getResponseStatus().studentsWhoResponded.size());
    assertTrue(pageData.getResponseStatus().studentsWhoResponded.contains("student1InCourse1@gmail.tmt"));
    assertFalse(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("student2InCourse1@gmail.tmt"));
    assertTrue(pageData.getResponseStatus().studentsWhoResponded.contains("student3InCourse1@gmail.tmt"));
    assertTrue(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("student4InCourse1@gmail.tmt"));
    assertFalse(pageData.getResponseStatus().studentsWhoResponded.contains("student5InCourse1@gmail.tmt"));
    assertFalse(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("student6InCourse1@gmail.tmt"));
    assertFalse(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("instructor1@course1.tmt"));
    assertTrue(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("instructor2@course1.tmt"));
    assertTrue(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("instructor3@course1.tmt"));
    assertFalse(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("instructor4@course1.tmt"));
    assertTrue(pageData.getResponseStatus().studentsWhoDidNotRespond.contains("helper@course1.tmt"));
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorFeedbackRemindParticularStudentsPageData(teammates.ui.pagedata.InstructorFeedbackRemindParticularStudentsPageData) InstructorFeedbackRemindParticularStudentsPageAction(teammates.ui.controller.InstructorFeedbackRemindParticularStudentsPageAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 19 with InstructorAttributes

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

the class InstructorFeedbackResponseCommentDeleteActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    removeAndRestoreTypicalDataBundle();
    FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
    FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
    FeedbackResponseCommentsDb feedbackResponseCommentsDb = new FeedbackResponseCommentsDb();
    int questionNumber = 1;
    FeedbackQuestionAttributes feedbackQuestion = feedbackQuestionsDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
    String giverEmail = "student1InCourse1@gmail.tmt";
    String receiverEmail = "student1InCourse1@gmail.tmt";
    FeedbackResponseAttributes feedbackResponse = feedbackResponsesDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
    FeedbackResponseCommentAttributes feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
    feedbackResponseComment = feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
    assertNotNull("response comment not found", feedbackResponseComment);
    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, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.USER_ID, instructor.googleId };
    verifyAssumptionFailure(submissionParams);
    ______TS("Typical successful case");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
    InstructorFeedbackResponseCommentDeleteAction action = getAction(submissionParams);
    AjaxResult result = getAjaxResult(action);
    InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertNull(feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponseComment.feedbackResponseId, feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt));
    assertEquals("", result.getStatusMessage());
    ______TS("Non-existent feedback response comment");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, // non-existent feedback response comment id
    Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, "123123123123123", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertNull(feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponseComment.feedbackResponseId, feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt));
    assertEquals("", result.getStatusMessage());
    ______TS("Instructor is not feedback response comment giver");
    gaeSimulation.loginAsInstructor("idOfInstructor2OfCourse1");
    questionNumber = 2;
    feedbackQuestion = feedbackQuestionsDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
    giverEmail = "student2InCourse1@gmail.tmt";
    feedbackResponse = feedbackResponsesDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
    feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q2S1C1");
    feedbackResponseComment = feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
    assertNotNull("response comment not found", feedbackResponseComment);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertNull(feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponseComment.feedbackResponseId, feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt));
    assertEquals("", result.getStatusMessage());
}
Also used : FeedbackResponseCommentsDb(teammates.storage.api.FeedbackResponseCommentsDb) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) InstructorFeedbackResponseCommentDeleteAction(teammates.ui.controller.InstructorFeedbackResponseCommentDeleteAction) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) InstructorFeedbackResponseCommentAjaxPageData(teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) AjaxResult(teammates.ui.controller.AjaxResult) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

Example 20 with InstructorAttributes

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

the class InstructorFeedbackResponseCommentEditActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
    FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
    FeedbackResponseCommentsDb feedbackResponseCommentsDb = new FeedbackResponseCommentsDb();
    int questionNumber = 1;
    FeedbackQuestionAttributes feedbackQuestion = feedbackQuestionsDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
    String giverEmail = "student1InCourse1@gmail.tmt";
    String receiverEmail = "student1InCourse1@gmail.tmt";
    FeedbackResponseAttributes feedbackResponse = feedbackResponsesDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
    FeedbackResponseCommentAttributes feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
    feedbackResponseComment = feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
    assertNotNull("response comment not found", feedbackResponseComment);
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("Unsuccessful csae: not enough parameters");
    verifyAssumptionFailure();
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.USER_ID, instructor.googleId };
    verifyAssumptionFailure(submissionParams);
    ______TS("Typical successful case for unpublished session");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS" };
    InstructorFeedbackResponseCommentEditAction action = getAction(submissionParams);
    AjaxResult result = getAjaxResult(action);
    InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Null show comments and show giver permissions");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Empty show comments and show giver permissions");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Typical successful case for unpublished session public to various recipients");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "OWN_TEAM_MEMBERS" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER_TEAM_MEMBERS" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "STUDENTS" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Non-existent feedback response comment id");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, "123123123123123", Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS" };
    try {
        action = getAction(submissionParams);
        result = getAjaxResult(action);
    } catch (AssertionError e) {
        assertEquals("FeedbackResponseComment should not be null", e.getMessage());
    }
    ______TS("Instructor is not feedback response comment giver");
    gaeSimulation.loginAsInstructor("idOfInstructor2OfCourse1");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Typical successful case for published session");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    FeedbackSessionAttributes fs = FeedbackSessionsLogic.inst().getFeedbackSession(feedbackResponseComment.feedbackSessionName, feedbackResponseComment.courseId);
    FeedbackSessionsLogic.inst().publishFeedbackSession(fs);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited for published session)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertFalse(data.isError);
    assertEquals("", result.getStatusMessage());
    ______TS("Unsuccessful case: empty comment text");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
    action = getAction(submissionParams);
    result = getAjaxResult(action);
    assertEquals("", result.getStatusMessage());
    data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
    assertTrue(data.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY, data.errorMessage);
}
Also used : FeedbackResponseCommentsDb(teammates.storage.api.FeedbackResponseCommentsDb) FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) 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) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) InstructorFeedbackResponseCommentEditAction(teammates.ui.controller.InstructorFeedbackResponseCommentEditAction) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) Test(org.testng.annotations.Test)

Aggregations

InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)325 Test (org.testng.annotations.Test)127 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)84 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)77 ArrayList (java.util.ArrayList)58 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)46 RedirectResult (teammates.ui.controller.RedirectResult)46 StatusMessage (teammates.common.util.StatusMessage)34 ShowPageResult (teammates.ui.controller.ShowPageResult)31 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)29 HashMap (java.util.HashMap)25 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)24 InvalidParametersException (teammates.common.exception.InvalidParametersException)24 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)20 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)18 EmailWrapper (teammates.common.util.EmailWrapper)15 InstructorPrivileges (teammates.common.datatransfer.InstructorPrivileges)14 DataBundle (teammates.common.datatransfer.DataBundle)13