Search in sources :

Example 1 with FeedbackSessionStatsPageData

use of teammates.ui.pagedata.FeedbackSessionStatsPageData in project teammates by TEAMMATES.

the class FeedbackSessionStatsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    String instructorId = instructor1OfCourse1.googleId;
    String[] submissionParams;
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("typical: instructor accesses feedback stats of his/her course");
    FeedbackSessionAttributes accessableFeedbackSession = typicalBundle.feedbackSessions.get("session1InCourse1");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, accessableFeedbackSession.getFeedbackSessionName(), Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    FeedbackSessionStatsPageAction a = getAction(addUserIdToParams(instructorId, submissionParams));
    AjaxResult r = getAjaxResult(a);
    FeedbackSessionStatsPageData data = (FeedbackSessionStatsPageData) r.data;
    assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), r.getDestinationWithParams());
    assertEquals(10, data.sessionDetails.stats.expectedTotal);
    assertEquals(4, data.sessionDetails.stats.submittedTotal);
    assertEquals("", r.getStatusMessage());
    ______TS("fail: instructor accesses stats of non-existent feedback session");
    String nonexistentFeedbackSession = "nonexistentFeedbackSession";
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, nonexistentFeedbackSession, Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    boolean hasThrownUnauthorizedAccessException = false;
    String exceptionMessage = "";
    a = getAction(addUserIdToParams(instructorId, submissionParams));
    try {
        r = getAjaxResult(a);
    } catch (UnauthorizedAccessException e) {
        hasThrownUnauthorizedAccessException = true;
        exceptionMessage = e.getMessage();
    }
    assertTrue(hasThrownUnauthorizedAccessException);
    assertEquals("Trying to access system using a non-existent feedback session entity", exceptionMessage);
    assertEquals("", r.getStatusMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) AjaxResult(teammates.ui.controller.AjaxResult) FeedbackSessionStatsPageAction(teammates.ui.controller.FeedbackSessionStatsPageAction) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) FeedbackSessionStatsPageData(teammates.ui.pagedata.FeedbackSessionStatsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 2 with FeedbackSessionStatsPageData

use of teammates.ui.pagedata.FeedbackSessionStatsPageData in project teammates by TEAMMATES.

the class FeedbackSessionStatsPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    FeedbackSessionStatsPageData data = new FeedbackSessionStatsPageData(account, sessionToken);
    FeedbackSessionAttributes fsa = logic.getFeedbackSession(feedbackSessionName, courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, fsa, false);
    data.sessionDetails = logic.getFeedbackSessionDetails(feedbackSessionName, courseId);
    return createAjaxResult(data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionStatsPageData(teammates.ui.pagedata.FeedbackSessionStatsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 FeedbackSessionStatsPageData (teammates.ui.pagedata.FeedbackSessionStatsPageData)2 Test (org.testng.annotations.Test)1 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)1 AjaxResult (teammates.ui.controller.AjaxResult)1 FeedbackSessionStatsPageAction (teammates.ui.controller.FeedbackSessionStatsPageAction)1