use of teammates.common.exception.ExceedingRangeException in project teammates by TEAMMATES.
the class InstructorFeedbackResultsDownloadAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
String section = getRequestParamValue(Const.ParamsNames.SECTION_NAME);
boolean isMissingResponsesShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_INDICATE_MISSING_RESPONSES);
boolean isStatsShown = getRequestParamAsBoolean(Const.ParamsNames.FEEDBACK_RESULTS_SHOWSTATS);
String questionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
String questionNumber = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_NUMBER);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
boolean isCreatorOnly = true;
gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly);
String fileContent;
String fileName;
try {
String questionName = "";
if (questionNumber != null) {
questionName = "_question" + questionNumber;
}
if (section == null || "All".equals(section)) {
fileContent = logic.getFeedbackSessionResultSummaryAsCsv(courseId, feedbackSessionName, instructor.email, isMissingResponsesShown, isStatsShown, questionId);
fileName = courseId + "_" + feedbackSessionName + questionName;
statusToAdmin = "Summary data for Feedback Session " + feedbackSessionName + " in Course " + courseId + " was downloaded";
} else {
fileContent = logic.getFeedbackSessionResultSummaryInSectionAsCsv(courseId, feedbackSessionName, instructor.email, section, questionId, isMissingResponsesShown, isStatsShown);
fileName = courseId + "_" + feedbackSessionName + "_" + section + questionName;
statusToAdmin = "Summary data for Feedback Session " + feedbackSessionName + " in Course " + courseId + " within " + section + " was downloaded";
}
} catch (ExceedingRangeException e) {
// not tested as the test file is not large enough to reach this catch block
statusToUser.add(new StatusMessage("This session has more responses than that can be downloaded in one go. " + "Please download responses for " + (questionNumber == null ? "one question at a time instead. " + "To download responses for a specific question, click on the corresponding question number." : "section instead."), StatusMessageColor.DANGER));
isError = true;
RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_FEEDBACK_RESULTS_PAGE);
result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
result.addResponseParam(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
return result;
}
return createFileDownloadResult(fileName, fileContent);
}
use of teammates.common.exception.ExceedingRangeException in project teammates by TEAMMATES.
the class GenerateFeedbackReport method doOperation.
@Override
protected void doOperation() {
Logic logic = new Logic();
try {
String fileContent = logic.getFeedbackSessionResultSummaryAsCsv("CourseID", "Session Name", "instructor@email.com", true, true, null);
writeToFile("result.csv", fileContent);
} catch (EntityDoesNotExistException | ExceedingRangeException e) {
e.printStackTrace();
}
}
use of teammates.common.exception.ExceedingRangeException in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionResultsSummaryInSectionAsCsv.
public String getFeedbackSessionResultsSummaryInSectionAsCsv(String feedbackSessionName, String courseId, String userEmail, String section, String questionId, boolean isMissingResponsesShown, boolean isStatsShown) throws EntityDoesNotExistException, ExceedingRangeException {
FeedbackSessionResultsBundle results;
int indicatedRange = section == null ? Const.INSTRUCTOR_VIEW_RESPONSE_LIMIT : -1;
if (questionId == null) {
results = getFeedbackSessionResultsForInstructorInSectionWithinRangeFromView(feedbackSessionName, courseId, userEmail, section, indicatedRange, Const.FeedbackSessionResults.GRQ_SORT_TYPE);
} else if (section == null) {
results = getFeedbackSessionResultsForInstructorFromQuestion(feedbackSessionName, courseId, userEmail, questionId);
} else {
results = getFeedbackSessionResultsForInstructorFromQuestionInSection(feedbackSessionName, courseId, userEmail, questionId, section);
}
if (!results.isComplete) {
throw new ExceedingRangeException(ERROR_NUMBER_OF_RESPONSES_EXCEEDS_RANGE);
}
// sort responses by giver > recipient > qnNumber
results.responses.sort(results.compareByGiverRecipientQuestion);
StringBuilder exportBuilder = new StringBuilder(100);
exportBuilder.append(String.format("Course,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getCourseId()))).append(System.lineSeparator()).append(String.format("Session Name,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getFeedbackSessionName()))).append(System.lineSeparator());
if (section != null) {
exportBuilder.append(String.format("Section Name,%s", SanitizationHelper.sanitizeForCsv(section))).append(System.lineSeparator());
}
exportBuilder.append(System.lineSeparator()).append(System.lineSeparator());
Set<Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> entrySet = results.getQuestionResponseMap().entrySet();
for (Map.Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> entry : entrySet) {
exportBuilder.append(getFeedbackSessionResultsForQuestionInCsvFormat(results, entry, isMissingResponsesShown, isStatsShown, section));
}
return exportBuilder.toString();
}
Aggregations