use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseDeleteAction method execute.
@Override
public ActionResult execute() {
String idOfCourseToDelete = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, idOfCourseToDelete);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(idOfCourseToDelete, account.googleId), logic.getCourse(idOfCourseToDelete), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE);
/* Delete the course and setup status to be shown to user and admin */
logic.deleteCourse(idOfCourseToDelete);
String statusMessage = String.format(Const.StatusMessages.COURSE_DELETED, idOfCourseToDelete);
statusToUser.add(new StatusMessage(statusMessage, StatusMessageColor.SUCCESS));
statusToAdmin = "Course deleted: " + idOfCourseToDelete;
if (isRedirectedToHomePage()) {
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
}
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseEnrollSaveAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String studentsInfo = getRequestParamValue(Const.ParamsNames.STUDENTS_ENROLLMENT_INFO);
String sanitizedStudentsInfo = SanitizationHelper.sanitizeForHtml(studentsInfo);
Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENTS_ENROLLMENT_INFO, studentsInfo);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
/* Process enrollment list and setup data for page result */
try {
List<StudentAttributes>[] students = enrollAndProcessResultForDisplay(studentsInfo, courseId);
boolean hasSection = hasSections(students);
InstructorCourseEnrollResultPageData pageData = new InstructorCourseEnrollResultPageData(account, sessionToken, courseId, students, hasSection, studentsInfo);
statusToAdmin = "Students Enrolled in Course <span class=\"bold\">[" + courseId + "]:</span><br>" + sanitizedStudentsInfo.replace("\n", "<br>");
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL_RESULT, pageData);
} catch (EnrollException | InvalidParametersException e) {
setStatusForException(e);
statusToAdmin += "<br>Enrollment string entered by user:<br>" + sanitizedStudentsInfo.replace("\n", "<br>");
InstructorCourseEnrollPageData pageData = new InstructorCourseEnrollPageData(account, sessionToken, courseId, studentsInfo);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, pageData);
} catch (EntityAlreadyExistsException e) {
setStatusForException(e);
statusToUser.add(new StatusMessage("The enrollment failed, possibly because some students were re-enrolled before " + "the previous enrollment action was still being processed by TEAMMATES database " + "servers. Please try again after about 10 minutes. If the problem persists, " + "please contact TEAMMATES support", StatusMessageColor.DANGER));
InstructorCourseEnrollPageData pageData = new InstructorCourseEnrollPageData(account, sessionToken, courseId, studentsInfo);
log.severe("Entity already exists exception occurred when updating student: " + e.getMessage());
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_ENROLL, pageData);
}
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseInstructorAddAction method execute.
@Override
protected ActionResult execute() {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String instructorName = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_NAME, instructorName);
String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
InstructorAttributes instructorToAdd = extractCompleteInstructor(courseId, instructorName, instructorEmail);
/* Process adding the instructor and setup status to be shown to user and admin */
try {
logic.createInstructor(instructorToAdd);
taskQueuer.scheduleCourseRegistrationInviteToInstructor(loggedInUser.googleId, instructorEmail, courseId);
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_ADDED, instructorName, instructorEmail), StatusMessageColor.SUCCESS));
statusToAdmin = "New instructor (<span class=\"bold\"> " + instructorEmail + "</span>)" + " for Course <span class=\"bold\">[" + courseId + "]</span> created.<br>";
} catch (EntityAlreadyExistsException e) {
setStatusForException(e, Const.StatusMessages.COURSE_INSTRUCTOR_EXISTS);
} catch (InvalidParametersException e) {
setStatusForException(e);
}
RedirectResult redirectResult = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE);
redirectResult.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return redirectResult;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseInstructorDeleteAction method execute.
@Override
protected ActionResult execute() {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String instructorEmail = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR);
/* Process deleting an instructor and setup status to be shown to user and admin */
if (hasAlternativeInstructor(courseId, instructorEmail)) {
logic.deleteInstructor(courseId, instructorEmail);
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_INSTRUCTOR_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor <span class=\"bold\"> " + instructorEmail + "</span>" + " in Course <span class=\"bold\">[" + courseId + "]</span> deleted.<br>";
} else {
isError = true;
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_INSTRUCTOR_DELETE_NOT_ALLOWED, StatusMessageColor.DANGER));
statusToAdmin = "Instructor <span class=\"bold\"> " + instructorEmail + "</span>" + " in Course <span class=\"bold\">[" + courseId + "]</span> could not be deleted " + "as there is only one instructor left to be able to modify instructors.<br>";
}
/* Create redirection. It will redirect back to 'Courses' page if the instructor deletes himself */
RedirectResult result = null;
if (logic.isInstructorOfCourse(account.googleId, courseId)) {
result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE);
result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
} else {
result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE);
}
return result;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class StudentCourseJoinAuthenticatedAction method addStatusMessageToUser.
private void addStatusMessageToUser() throws EntityDoesNotExistException {
CourseAttributes course = logic.getCourse(getStudent().course);
String courseDisplayText = "[" + course.getId() + "] " + SanitizationHelper.sanitizeForHtml(course.getName());
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, courseDisplayText), StatusMessageColor.SUCCESS));
List<FeedbackSessionAttributes> fsa = logic.getFeedbackSessionsForUserInCourse(getStudent().course, getStudent().email);
if (fsa.isEmpty()) {
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, courseDisplayText), StatusMessageColor.INFO));
StudentProfileAttributes spa = logic.getStudentProfile(account.googleId);
String updateProfileMessage = spa.generateUpdateMessageForStudent();
if (!updateProfileMessage.isEmpty()) {
statusToUser.add(new StatusMessage(updateProfileMessage, StatusMessageColor.INFO));
}
}
}
Aggregations