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());
}
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);
}
Aggregations