use of teammates.ui.pagedata.InstructorFeedbackResultsPageData 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());
}
use of teammates.ui.pagedata.InstructorFeedbackResultsPageData in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String showStats = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_SHOWSTATS);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
statusToAdmin = "Show instructor feedback result page<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
boolean isCreatorOnly = true;
gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly);
InstructorFeedbackResultsPageData data = new InstructorFeedbackResultsPageData(account, sessionToken);
String selectedSection = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION);
if (selectedSection == null) {
selectedSection = ALL_SECTION_OPTION;
}
boolean isMissingResponsesShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES);
// this is for ajax loading of the html table in the modal
// "(Non-English characters not displayed properly in the downloaded file? click here)"
// TODO move into another action and another page data class
boolean isLoadingCsvResultsAsHtml = getRequestParamAsBoolean(Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED);
if (isLoadingCsvResultsAsHtml) {
return createAjaxResultForCsvTableLoadedInHtml(courseId, feedbackSessionName, instructor, data, selectedSection, isMissingResponsesShown, Boolean.valueOf(showStats));
}
data.setSessionResultsHtmlTableAsString("");
data.setAjaxStatus("");
String groupByTeam = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYTEAM);
String sortType = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE);
String startIndex = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_MAIN_INDEX);
if (startIndex != null) {
data.setStartIndex(Integer.parseInt(startIndex));
}
if (sortType == null) {
// default view: sort by question, statistics shown, grouped by team.
showStats = "on";
groupByTeam = "on";
sortType = Const.FeedbackSessionResults.QUESTION_SORT_TYPE;
isMissingResponsesShown = true;
}
String questionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
String isTestingAjax = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESULTS_NEED_AJAX);
if (ALL_SECTION_OPTION.equals(selectedSection) && questionId == null && !Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType)) {
// bundle for all questions and all sections
data.setBundle(logic.getFeedbackSessionResultsForInstructorWithinRangeFromView(feedbackSessionName, courseId, instructor.email, DEFAULT_SECTION_QUERY_RANGE, sortType));
} else if (Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType)) {
data.setBundle(getBundleForQuestionView(isTestingAjax, courseId, feedbackSessionName, instructor, data, selectedSection, sortType, questionId));
} else if (Const.FeedbackSessionResults.GQR_SORT_TYPE.equals(sortType) || Const.FeedbackSessionResults.GRQ_SORT_TYPE.equals(sortType)) {
data.setBundle(logic.getFeedbackSessionResultsForInstructorFromSectionWithinRange(feedbackSessionName, courseId, instructor.email, selectedSection, DEFAULT_SECTION_QUERY_RANGE));
} else if (Const.FeedbackSessionResults.RQG_SORT_TYPE.equals(sortType) || Const.FeedbackSessionResults.RGQ_SORT_TYPE.equals(sortType)) {
data.setBundle(logic.getFeedbackSessionResultsForInstructorToSectionWithinRange(feedbackSessionName, courseId, instructor.email, selectedSection, DEFAULT_SECTION_QUERY_RANGE));
}
if (data.getBundle() == null) {
throw new EntityDoesNotExistException("Feedback session " + feedbackSessionName + " does not exist in " + courseId + ".");
}
// Warning for section wise viewing in case of many responses.
boolean isShowSectionWarningForQuestionView = data.isLargeNumberOfRespondents() && Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType);
boolean isShowSectionWarningForParticipantView = !data.getBundle().isComplete && !Const.FeedbackSessionResults.QUESTION_SORT_TYPE.equals(sortType);
// Warning for section wise does not make sense if there are no multiple sections.
boolean isMultipleSectionAvailable = data.getBundle().getRosterSectionTeamNameTable().size() > 1;
if (selectedSection.equals(ALL_SECTION_OPTION) && (isShowSectionWarningForParticipantView || isShowSectionWarningForQuestionView)) {
if (isMultipleSectionAvailable) {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_SECTIONVIEWWARNING, StatusMessageColor.WARNING));
} else {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_QUESTIONVIEWWARNING, StatusMessageColor.WARNING));
}
isError = true;
}
switch(sortType) {
case Const.FeedbackSessionResults.QUESTION_SORT_TYPE:
data.initForViewByQuestion(instructor, selectedSection, showStats, groupByTeam, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, data);
case Const.FeedbackSessionResults.RGQ_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_GIVER_QUESTION, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, data);
case Const.FeedbackSessionResults.GRQ_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.GIVER_RECIPIENT_QUESTION, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, data);
case Const.FeedbackSessionResults.RQG_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_QUESTION_GIVER, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_QUESTION_GIVER, data);
case Const.FeedbackSessionResults.GQR_SORT_TYPE:
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.GIVER_QUESTION_RECIPIENT, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_QUESTION_RECIPIENT, data);
default:
sortType = Const.FeedbackSessionResults.RGQ_SORT_TYPE;
data.initForSectionPanelViews(instructor, selectedSection, showStats, groupByTeam, InstructorFeedbackResultsPageViewType.RECIPIENT_GIVER_QUESTION, isMissingResponsesShown);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, data);
}
}
Aggregations