use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class StudentFeedbackResultsPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
if (courseId == null || feedbackSessionName == null) {
return createRedirectResult(Const.ActionURIs.STUDENT_HOME_PAGE);
}
if (!isJoinedCourse(courseId)) {
return createPleaseJoinCourseResponse(courseId);
}
gateKeeper.verifyAccessible(getCurrentStudent(courseId), logic.getFeedbackSession(feedbackSessionName, courseId));
StudentFeedbackResultsPageData data = new StudentFeedbackResultsPageData(account, student, sessionToken);
data.student = getCurrentStudent(courseId);
data.setBundle(logic.getFeedbackSessionResultsForStudent(feedbackSessionName, courseId, data.student.email));
if (data.getBundle() == null) {
// leave this here as a safety net on the off cases that GateKeeper fails to catch the Exception
throw new EntityDoesNotExistException("Feedback session " + feedbackSessionName + " does not exist in " + courseId + ".");
}
if (!data.getBundle().feedbackSession.isPublished()) {
throw new UnauthorizedAccessException("This feedback session is not yet visible.");
}
if (data.getBundle().isStudentHasSomethingNewToSee(data.student)) {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_SOMETHINGNEW, StatusMessageColor.INFO));
} else {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_RESULTS_NOTHINGNEW, StatusMessageColor.WARNING));
}
statusToAdmin = "Show student feedback result page<br>" + "Session Name: " + feedbackSessionName + "<br>" + "Course ID: " + courseId;
Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionsWithResponses = data.getBundle().getQuestionResponseMapSortedByRecipient();
data.init(questionsWithResponses);
return createShowPageResult(Const.ViewURIs.STUDENT_FEEDBACK_RESULTS, data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class StudentHomePageAction method execute.
@Override
public ActionResult execute() {
gateKeeper.verifyLoggedInUserPrivileges();
String recentlyJoinedCourseId = getRequestParamValue(Const.ParamsNames.CHECK_PERSISTENCE_COURSE);
List<CourseDetailsBundle> courses = new ArrayList<>();
Map<FeedbackSessionAttributes, Boolean> sessionSubmissionStatusMap = new HashMap<>();
try {
courses = logic.getCourseDetailsListForStudent(account.googleId);
sessionSubmissionStatusMap = generateFeedbackSessionSubmissionStatusMap(courses, account.googleId);
CourseDetailsBundle.sortDetailedCoursesByCourseId(courses);
statusToAdmin = "studentHome Page Load<br>" + "Total courses: " + courses.size();
boolean isDataConsistent = isCourseIncluded(recentlyJoinedCourseId, courses);
if (!isDataConsistent) {
addPlaceholderCourse(courses, recentlyJoinedCourseId, sessionSubmissionStatusMap);
}
for (CourseDetailsBundle course : courses) {
FeedbackSessionDetailsBundle.sortFeedbackSessionsByCreationTime(course.feedbackSessions);
}
} catch (EntityDoesNotExistException e) {
if (recentlyJoinedCourseId == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_FIRST_TIME, StatusMessageColor.WARNING));
statusToAdmin = Const.ACTION_RESULT_FAILURE + " :" + e.getMessage();
} else {
addPlaceholderCourse(courses, recentlyJoinedCourseId, sessionSubmissionStatusMap);
}
}
StudentHomePageData data = new StudentHomePageData(account, sessionToken, courses, sessionSubmissionStatusMap);
return createShowPageResult(Const.ViewURIs.STUDENT_HOME, data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class StudentProfilePictureEditAction method validatePostParameters.
/**
* Checks that the information given via POST is valid.
*/
private boolean validatePostParameters() {
if (leftXString.isEmpty() || topYString.isEmpty() || rightXString.isEmpty() || bottomYString.isEmpty()) {
isError = true;
statusToUser.add(new StatusMessage("Given crop locations were not valid. Please try again", StatusMessageColor.DANGER));
statusToAdmin = Const.ACTION_RESULT_FAILURE + " : One or more of the given coords were empty.";
return false;
} else if (heightString.isEmpty() || widthString.isEmpty()) {
isError = true;
statusToUser.add(new StatusMessage("Given crop locations were not valid. Please try again", StatusMessageColor.DANGER));
statusToAdmin = Const.ACTION_RESULT_FAILURE + " : One or both of the image dimensions were empty.";
return false;
} else if (Double.parseDouble(widthString) == 0 || Double.parseDouble(heightString) == 0) {
isError = true;
statusToUser.add(new StatusMessage("Given crop locations were not valid. Please try again", StatusMessageColor.DANGER));
statusToAdmin = Const.ACTION_RESULT_FAILURE + " : One or both of the image dimensions were zero.";
return false;
}
return true;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class StudentProfilePictureUploadAction method execute.
/*
* This class is not tested in ActionTests as it is difficult to
* reproduce the upload action done by Google Blobstore API
* without the server running.
* This class is covered in UiTests.
*/
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
gateKeeper.verifyLoggedInUserPrivileges();
String pictureKey = "";
BlobKey blobKey = new BlobKey("");
RedirectResult r = createRedirectResult(Const.ActionURIs.STUDENT_PROFILE_PAGE);
try {
BlobInfo blobInfo = extractProfilePictureKey();
if (!isError) {
blobKey = blobInfo.getBlobKey();
pictureKey = renameFileToGoogleId(blobInfo);
logic.updateStudentProfilePicture(account.googleId, pictureKey);
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_PICTURE_SAVED, StatusMessageColor.SUCCESS));
r.addResponseParam(Const.ParamsNames.STUDENT_PROFILE_PHOTOEDIT, "true");
}
} catch (BlobstoreFailureException | IOException bfe) {
deletePicture(blobKey);
updateStatusesForBlobstoreFailure();
isError = true;
} catch (Exception e) {
/*
* This is for other exceptions like EntityNotFound, IllegalState, etc
* that occur rarely and are handled higher up.
*/
deletePicture(new BlobKey(pictureKey));
statusToUser.clear();
throw e;
}
return r;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class StudentProfilePictureUploadAction method updateStatusesForBlobstoreFailure.
private void updateStatusesForBlobstoreFailure() {
statusToAdmin += Const.ACTION_RESULT_FAILURE + " : Could not delete profile picture for account (" + account.googleId + ")" + System.lineSeparator();
statusToUser.clear();
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_PIC_SERVICE_DOWN, StatusMessageColor.DANGER));
}
Aggregations