Search in sources :

Example 31 with FeedbackSessionAttributes

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

the class InstructorFeedbackSubmissionEditPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
    FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    ______TS("not enough parameters");
    String[] paramsWithoutCourseId = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
    String[] paramsWithoutFeedbackSessionName = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId() };
    verifyAssumptionFailure(paramsWithoutCourseId);
    verifyAssumptionFailure(paramsWithoutFeedbackSessionName);
    ______TS("Test null feedback session name parameter");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.USER_ID, instructor.googleId };
    InstructorFeedbackSubmissionEditPageAction a;
    ShowPageResult r;
    try {
        a = getAction(submissionParams);
        r = getShowPageResult(a);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_NAME), e.getMessage());
    }
    ______TS("Test null course id parameter");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
    try {
        a = getAction(submissionParams);
        r = getShowPageResult(a);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
    }
    ______TS("Test insufficient authorization");
    instructor = typicalBundle.instructors.get("helperOfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
    try {
        a = getAction(submissionParams);
        r = getShowPageResult(a);
        signalFailureToDetectException("Did not detect insufficient authorization.");
    } catch (UnauthorizedAccessException e) {
        assertEquals("Feedback session [First feedback session] is not accessible to instructor " + "[helper@course1.tmt] for this purpose", e.getMessage());
    }
    ______TS("Test feedback session that does not exist");
    instructor = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, "feedback session that does not exist", Const.ParamsNames.USER_ID, instructor.googleId };
    a = getAction(submissionParams);
    RedirectResult rr = getRedirectResult(a);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, false, instructor.googleId), rr.getDestinationWithParams());
    assertFalse(rr.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_DELETED_NO_ACCESS, rr.getStatusMessage());
    ______TS("typical success case");
    String[] params = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
    a = getAction(params);
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, r.getStatusMessage());
    ______TS("masquerade mode");
    gaeSimulation.loginAsAdmin("admin.user");
    a = getAction(params);
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, r.getStatusMessage());
    ______TS("closed session case");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    session = typicalBundle.feedbackSessions.get("closedSession");
    params = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
    a = getAction(params);
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_NOT_OPEN, r.getStatusMessage());
    ______TS("private session case");
    instructor = typicalBundle.instructors.get("instructor1OfCourse2");
    session = typicalBundle.feedbackSessions.get("session1InCourse2");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    params = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.USER_ID, instructor.googleId };
    a = getAction(params);
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_SUBMISSION_EDIT, false, instructor.googleId), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, r.getStatusMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ShowPageResult(teammates.ui.controller.ShowPageResult) NullPostParameterException(teammates.common.exception.NullPostParameterException) RedirectResult(teammates.ui.controller.RedirectResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackSubmissionEditPageAction(teammates.ui.controller.InstructorFeedbackSubmissionEditPageAction) Test(org.testng.annotations.Test)

Example 32 with FeedbackSessionAttributes

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

the class InstructorFeedbackSubmissionEditSaveActionTest method testGracePeriodAccessControlForInstructors.

private void testGracePeriodAccessControlForInstructors() throws Exception {
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("gracePeriodSession");
    closeSession(fs);
    assertFalse(fs.isOpened());
    assertTrue(fs.isInGracePeriod());
    assertFalse(fs.isClosed());
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
    verifyOnlyInstructorsOfTheSameCourseCanAccess(submissionParams);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes)

Example 33 with FeedbackSessionAttributes

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

the class InstructorFeedbackDeleteActionTest method testAccessControl.

@Override
@Test
protected void testAccessControl() throws Exception {
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session2InCourse1");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
    verifyUnaccessibleWithoutLogin(submissionParams);
    verifyUnaccessibleForUnregisteredUsers(submissionParams);
    verifyUnaccessibleForStudents(submissionParams);
    verifyUnaccessibleForInstructorsOfOtherCourses(submissionParams);
    verifyUnaccessibleWithoutModifySessionPrivilege(submissionParams);
    verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
    // recreate the entity
    FeedbackSessionsLogic.inst().createFeedbackSession(fs);
    verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) Test(org.testng.annotations.Test)

Example 34 with FeedbackSessionAttributes

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

the class InstructorFeedbackDeleteActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    FeedbackSessionsDb fsDb = new FeedbackSessionsDb();
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    assertNotNull(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()));
    InstructorFeedbackDeleteAction a = getAction(submissionParams);
    RedirectResult r = getRedirectResult(a);
    assertNull(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()));
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE, false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_SESSION_DELETED, r.getStatusMessage());
    assertFalse(r.isError);
}
Also used : FeedbackSessionsDb(teammates.storage.api.FeedbackSessionsDb) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorFeedbackDeleteAction(teammates.ui.controller.InstructorFeedbackDeleteAction) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 35 with FeedbackSessionAttributes

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

the class InstructorFeedbackEditCopyActionTest method testAccessControl.

@Override
@Test
protected void testAccessControl() throws Exception {
    String[] params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, "First feedback session", Const.ParamsNames.COURSE_ID, "idOfTypicalCourse1", Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "Session with valid name", Const.ParamsNames.COPIED_COURSES_ID, "idOfTypicalCourse2", Const.ParamsNames.COPIED_COURSES_ID, "idOfSampleCourse-demo" };
    verifyUnaccessibleWithoutViewSessionInSectionsPrivilege(params);
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("openSession");
    CourseAttributes course = dataBundle.courses.get("course");
    ______TS("Failure case: copying from course with insufficient permission");
    InstructorAttributes instructor = dataBundle.instructors.get("teammates.test.instructor3");
    String instructorId = instructor.googleId;
    gaeSimulation.loginAsInstructor(instructorId);
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, course.getId() };
    InstructorFeedbackEditCopyAction a = getAction(params);
    try {
        a.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        String expectedString = "Course [FeedbackEditCopy.CS2104] is not accessible to instructor " + "[tmms.instr.cust@course.tmt] for privilege [canviewsessioninsection]";
        assertEquals(expectedString, uae.getMessage());
    }
    gaeSimulation.logoutUser();
    ______TS("Failure case: copying to course with insufficient permission");
    instructor = dataBundle.instructors.get("teammates.test.instructor2");
    instructorId = instructor.googleId;
    gaeSimulation.loginAsInstructor(instructorId);
    params = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.COPIED_FEEDBACK_SESSION_NAME, "valid name", Const.ParamsNames.COPIED_COURSES_ID, "FeedbackEditCopy.CS2107" };
    a = getAction(params);
    try {
        a.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (UnauthorizedAccessException uae) {
        String expectedString = "Course [FeedbackEditCopy.CS2107] is not accessible to instructor " + "[tmms.instr@course.tmt] for privilege [canmodifysession]";
        assertEquals(expectedString, uae.getMessage());
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackEditCopyAction(teammates.ui.controller.InstructorFeedbackEditCopyAction) 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