Search in sources :

Example 26 with FeedbackSessionAttributes

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

the class InstructorFeedbackRemindParticularStudentsPageActionTest method testAccessControl.

@Test
@Override
protected void testAccessControl() throws Exception {
    CourseAttributes course = typicalBundle.courses.get("typicalCourse1");
    FeedbackSessionAttributes fsa = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, course.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fsa.getFeedbackSessionName() };
    verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 27 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes 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 28 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes 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)

Example 29 with FeedbackSessionAttributes

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

the class InstructorFeedbackResultsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    gaeSimulation.loginAsInstructor(typicalBundle.instructors.get("instructor1OfCourse1").googleId);
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session2InCourse1");
    String[] paramsWithoutSortType = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
    String[] paramsWithSortTypeQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "question" };
    String[] paramsWithSortTypeGiverRecipientQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "giver-recipient-question" };
    String[] paramsWithSortTypeRecipientGiverQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question" };
    String[] paramsWithSortTypeGiverQuestionRecipient = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "giver-question-recipient" };
    String[] paramsWithSortTypeRecipientQuestionGiver = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-question-giver" };
    String[] paramsWithSortTypeUndefined = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "undefined" };
    String[] paramsNeedAjax = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "undefined", Const.ParamsNames.FEEDBACK_RESULTS_NEED_AJAX, "true" };
    String[] paramsWithStartIndex = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "undefined", Const.ParamsNames.FEEDBACK_RESULTS_MAIN_INDEX, "1" };
    String[] paramsQuestionNumberOne = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1" };
    String[] paramsSectionOneByQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "question", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
    String[] paramsSectionOneByGrq = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "giver-recipient-question", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
    String[] paramsSectionOneByRgq = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
    String[] paramsNeedHtmlTableAllSections = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question", Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED, "true" };
    String[] paramsNeedHtmlTableSectionOne = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question", Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED, "true", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
    ______TS("Failure case: no params");
    this.verifyAssumptionFailure();
    this.verifyAssumptionFailure(new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId() });
    ______TS("Typical case: no sortType param");
    InstructorFeedbackResultsPageAction action = getAction(paramsWithoutSortType);
    ShowPageResult result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: sortType question");
    action = getAction(paramsWithSortTypeQuestion);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: sortType giver-recipient-question");
    action = getAction(paramsWithSortTypeGiverRecipientQuestion);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: sortType recipient-giver-question");
    action = getAction(paramsWithSortTypeRecipientGiverQuestion);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: sortType giver-question-recipient");
    action = getAction(paramsWithSortTypeGiverQuestionRecipient);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_QUESTION_RECIPIENT, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: sortType recipient-question-giver");
    action = getAction(paramsWithSortTypeRecipientQuestionGiver);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_QUESTION_GIVER, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: sortType undefined");
    action = getAction(paramsWithSortTypeUndefined);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: feedback result with start index");
    action = getAction(paramsWithStartIndex);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: feedback result needing ajax");
    action = getAction(paramsNeedAjax);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: specific question number");
    action = getAction(paramsQuestionNumberOne);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: view section 1 sortType question");
    action = getAction(paramsSectionOneByQuestion);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: view section 1 sortType GRQ");
    action = getAction(paramsSectionOneByGrq);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: view section 1 sortType RGQ");
    action = getAction(paramsSectionOneByRgq);
    result = getShowPageResult(action);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
    assertEquals("", result.getStatusMessage());
    assertFalse(result.isError);
    ______TS("Typical case: view HTML table all sections");
    action = getAction(paramsNeedHtmlTableAllSections);
    AjaxResult ajaxResult = getAjaxResult(action);
    assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), ajaxResult.getDestinationWithParams());
    assertEquals("", ajaxResult.getStatusMessage());
    assertFalse(ajaxResult.isError);
    ______TS("Typical case: view HTML table section 1");
    action = getAction(paramsNeedHtmlTableSectionOne);
    ajaxResult = getAjaxResult(action);
    assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), ajaxResult.getDestinationWithParams());
    assertEquals("", ajaxResult.getStatusMessage());
    assertFalse(ajaxResult.isError);
    ______TS("Typical case: filtering of feedbackResponses for access control");
    // accessControl--filtering of the result is tested in FeedbackSessionsLogicTest,
    // so the test here about filtering is not rigorous
    gaeSimulation.loginAsInstructor(typicalBundle.accounts.get("helperOfCourse1").googleId);
    action = getAction(paramsWithSortTypeQuestion);
    result = getShowPageResult(action);
    InstructorFeedbackResultsPageData pageData = (InstructorFeedbackResultsPageData) result.data;
    assertTrue(pageData.getBundle().responses.isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AjaxResult(teammates.ui.controller.AjaxResult) ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorFeedbackResultsPageAction(teammates.ui.controller.InstructorFeedbackResultsPageAction) InstructorFeedbackResultsPageData(teammates.ui.pagedata.InstructorFeedbackResultsPageData) Test(org.testng.annotations.Test)

Example 30 with FeedbackSessionAttributes

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

the class InstructorFeedbackSubmissionEditPageActionTest method testAccessControl.

@Override
@Test
protected void testAccessControl() throws Exception {
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
    verifyUnaccessibleWithoutSubmitSessionInSectionsPrivilege(submissionParams);
    verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) Test(org.testng.annotations.Test)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)205 Test (org.testng.annotations.Test)85 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)78 ArrayList (java.util.ArrayList)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)35 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)32 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)30 RedirectResult (teammates.ui.controller.RedirectResult)27 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)19 StatusMessage (teammates.common.util.StatusMessage)19 HashMap (java.util.HashMap)17 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)13 EmailWrapper (teammates.common.util.EmailWrapper)12 Text (com.google.appengine.api.datastore.Text)11 DataBundle (teammates.common.datatransfer.DataBundle)11 EmailGenerator (teammates.logic.api.EmailGenerator)10 List (java.util.List)9 TaskWrapper (teammates.common.util.TaskWrapper)9