use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class ErrorUserReportLogAction method execute.
@Override
protected ActionResult execute() {
emailContent = getRequestParamValue(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_CONTENT);
Assumption.assertPostParamNotNull(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_CONTENT, emailContent);
emailSubject = getRequestParamValue(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_SUBJECT);
Assumption.assertPostParamNotNull(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_SUBJECT, emailSubject);
requestedUrl = getRequestParamValue(Const.ParamsNames.ERROR_FEEDBACK_URL_REQUESTED);
log.severe(getUserErrorReportLogMessage());
PageData data = new PageData(account, sessionToken);
statusToUser.add(new StatusMessage(Const.StatusMessages.ERROR_FEEDBACK_SUBMIT_SUCCESS, StatusMessageColor.SUCCESS));
return createAjaxResult(data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class FeedbackSubmissionEditPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
if (!isSpecificUserJoinedCourse()) {
return createPleaseJoinCourseResponse(courseId);
}
FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackSessionName, courseId);
if (feedbackSession == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_DELETED_NO_ACCESS, StatusMessageColor.WARNING));
return createSpecificRedirectResult();
}
verifyAccessibleForSpecificUser(feedbackSession);
String regKey = getRequestParamValue(Const.ParamsNames.REGKEY);
String email = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
String userEmailForCourse = getUserEmailForCourse();
data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
data.bundle = getDataBundle(userEmailForCourse);
data.setSessionOpenForSubmission(isSessionOpenForSpecificUser(data.bundle.feedbackSession));
data.init(regKey, email, courseId);
setStatusToAdmin();
// TODO: implement this in another way so there is no dependence on status messages from another page
addFeedbackSubmissionStatusMessageIfNotRedirected();
return createSpecificShowPageResult();
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class FeedbackSubmissionEditPageAction method addFeedbackSubmissionStatusMessageIfNotRedirected.
private void addFeedbackSubmissionStatusMessageIfNotRedirected() {
// Add status messages only if accessing the page directly, otherwise use only status messages from original page
if (isRedirectedFromFeedbackSubmissionEditSave()) {
return;
}
if (data.isSessionOpenForSubmission()) {
// Side effect of only adding status message when accessing the page directly means that the status message
// following is only shown the first time and not when submitting
StatusMessage statusMessage = new StatusMessage(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, StatusMessageColor.INFO);
statusToUser.add(statusMessage);
} else {
// Side effect of only adding status message when accessing the page directly means that the status message
// following will not show double submission statuses, such as the following (non-exhaustive):
// - FEEDBACK_SUBMISSIONS_NOT_OPEN from FeedbackSubmissionEditSaveAction followed by
// FEEDBACK_SUBMISSIONS_NOT_OPEN from FeedbackSubmissionEditPageAction
// - FEEDBACK_RESPONSES_SAVED from FeedbackSubmissionEditSaveAction followed by
// FEEDBACK_SUBMISSIONS_NOT_OPEN from FeedbackSubmissionEditPageAction
StatusMessage statusMessage = new StatusMessage(Const.StatusMessages.FEEDBACK_SUBMISSIONS_NOT_OPEN, StatusMessageColor.WARNING);
statusToUser.add(statusMessage);
}
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseAddAction method createCourse.
private void createCourse(String newCourseId, String newCourseName, String newCourseTimeZone) {
try {
logic.createCourseAndInstructor(data.account.googleId, newCourseId, newCourseName, newCourseTimeZone);
String statusMessage = Const.StatusMessages.COURSE_ADDED.replace("${courseEnrollLink}", data.getInstructorCourseEnrollLink(newCourseId)).replace("${courseEditLink}", data.getInstructorCourseEditLink(newCourseId));
statusToUser.add(new StatusMessage(statusMessage, StatusMessageColor.SUCCESS));
isError = false;
} catch (EntityAlreadyExistsException e) {
setStatusForException(e, Const.StatusMessages.COURSE_EXISTS);
} catch (InvalidParametersException e) {
setStatusForException(e);
}
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseAddAction method execute.
@Override
public ActionResult execute() {
String newCourseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, newCourseId);
String newCourseName = getRequestParamValue(Const.ParamsNames.COURSE_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_NAME, newCourseName);
String newCourseTimeZone = getRequestParamValue(Const.ParamsNames.COURSE_TIME_ZONE);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_TIME_ZONE, newCourseTimeZone);
/* Check if user has the right to execute the action */
gateKeeper.verifyInstructorPrivileges(account);
/* Create a new course in the database */
data = new InstructorCoursesPageData(account, sessionToken);
createCourse(newCourseId, newCourseName, newCourseTimeZone);
/* Prepare data for the refreshed page after executing the adding action */
Map<String, InstructorAttributes> instructorsForCourses = new HashMap<>();
List<CourseAttributes> activeCourses = new ArrayList<>();
List<CourseAttributes> archivedCourses = new ArrayList<>();
// Get list of InstructorAttributes that belong to the user.
List<InstructorAttributes> instructorList = logic.getInstructorsForGoogleId(data.account.googleId);
for (InstructorAttributes instructor : instructorList) {
instructorsForCourses.put(instructor.courseId, instructor);
}
// Get corresponding courses of the instructors.
List<CourseAttributes> allCourses = logic.getCoursesForInstructor(instructorList);
List<String> archivedCourseIds = logic.getArchivedCourseIds(allCourses, instructorsForCourses);
for (CourseAttributes course : allCourses) {
if (archivedCourseIds.contains(course.getId())) {
archivedCourses.add(course);
} else {
activeCourses.add(course);
}
}
// Sort CourseDetailsBundle lists by course id
CourseAttributes.sortById(activeCourses);
CourseAttributes.sortById(archivedCourses);
String courseIdToShowParam = "";
String courseNameToShowParam = "";
if (isError) {
// there is error in adding the course
courseIdToShowParam = SanitizationHelper.sanitizeForHtml(newCourseId);
courseNameToShowParam = SanitizationHelper.sanitizeForHtml(newCourseName);
List<String> statusMessageTexts = new ArrayList<>();
for (StatusMessage msg : statusToUser) {
statusMessageTexts.add(msg.getText());
}
statusToAdmin = StringHelper.toString(statusMessageTexts, "<br>");
} else {
statusToAdmin = "Course added : " + newCourseId;
statusToAdmin += "<br>Total courses: " + allCourses.size();
}
data.init(activeCourses, archivedCourses, instructorsForCourses, courseIdToShowParam, courseNameToShowParam);
return isError ? createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSES, data) : createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE);
}
Aggregations