use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseArchiveAction method execute.
@Override
protected ActionResult execute() {
String idOfCourseToArchive = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, idOfCourseToArchive);
String archiveStatus = getRequestParamValue(Const.ParamsNames.COURSE_ARCHIVE_STATUS);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ARCHIVE_STATUS, archiveStatus);
boolean isArchive = Boolean.parseBoolean(archiveStatus);
gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(idOfCourseToArchive, account.googleId), logic.getCourse(idOfCourseToArchive));
try {
// Set the archive status and status shown to user and admin
logic.setArchiveStatusOfInstructor(account.googleId, idOfCourseToArchive, isArchive);
if (isArchive) {
if (isRedirectedToHomePage()) {
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_ARCHIVED_FROM_HOMEPAGE, idOfCourseToArchive), StatusMessageColor.SUCCESS));
} else {
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_ARCHIVED, idOfCourseToArchive), StatusMessageColor.SUCCESS));
}
statusToAdmin = "Course archived: " + idOfCourseToArchive;
} else {
statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.COURSE_UNARCHIVED, idOfCourseToArchive), StatusMessageColor.SUCCESS));
statusToAdmin = "Course unarchived: " + idOfCourseToArchive;
}
} catch (Exception e) {
setStatusForException(e);
}
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 InstructorCourseDetailsPageAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
// this is for ajax loading of the htm table in the modal
boolean isHtmlTableNeeded = getRequestParamAsBoolean(Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
/* Setup page data for the "Course Details" page */
InstructorCourseDetailsPageData data = new InstructorCourseDetailsPageData(account, sessionToken);
if (isHtmlTableNeeded) {
String courseStudentListAsCsv = logic.getCourseStudentListAsCsv(courseId, account.googleId);
data.setStudentListHtmlTableAsString(StringHelper.csvToHtmlTable(courseStudentListAsCsv));
statusToAdmin = "instructorCourseDetails Page Ajax Html table Load<br>" + "Viewing Student List Table for Course <span class=\"bold\">[" + courseId + "]</span>";
return createAjaxResult(data);
}
CourseDetailsBundle courseDetails = logic.getCourseDetails(courseId);
List<InstructorAttributes> instructors = logic.getInstructorsForCourse(courseId);
data.init(instructor, courseDetails, instructors);
if (courseDetails.getStats().getStudentsTotal() == 0) {
String message = String.format(Const.StatusMessages.INSTRUCTOR_COURSE_EMPTY, data.getInstructorCourseEnrollLink(courseId));
statusToUser.add(new StatusMessage(message, StatusMessageColor.WARNING));
}
statusToAdmin = "instructorCourseDetails Page Load<br>" + "Viewing Course Details for Course <span class=\"bold\">[" + courseId + "]</span>";
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_DETAILS, data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseEditSaveAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String courseName = getRequestParamValue(Const.ParamsNames.COURSE_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_NAME, courseName);
String courseTimeZone = getRequestParamValue(Const.ParamsNames.COURSE_TIME_ZONE);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_TIME_ZONE, courseTimeZone);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE);
try {
logic.updateCourse(courseId, courseName, courseTimeZone);
statusToUser.add(new StatusMessage(Const.StatusMessages.COURSE_EDITED, StatusMessageColor.SUCCESS));
statusToAdmin = "Updated Course <span class=\"bold\">[" + courseId + "]</span> details:<br>" + "Name: " + courseName + "<br>" + "Time zone: " + courseTimeZone;
} catch (InvalidParametersException e) {
setStatusForException(e);
}
RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE);
result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return result;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorHomePageAction method loadPage.
private ActionResult loadPage() {
boolean shouldOmitArchived = true;
Map<String, CourseSummaryBundle> courses = logic.getCourseSummariesWithoutStatsForInstructor(account.googleId, shouldOmitArchived);
ArrayList<CourseSummaryBundle> courseList = new ArrayList<>(courses.values());
String sortCriteria = getSortCriteria();
sortCourse(courseList, sortCriteria);
InstructorHomePageData data = new InstructorHomePageData(account, sessionToken);
data.init(courseList, sortCriteria);
if (logic.isNewInstructor(account.googleId)) {
statusToUser.add(new StatusMessage(StatusMessages.HINT_FOR_NEW_INSTRUCTOR, StatusMessageColor.INFO));
}
statusToAdmin = "instructorHome Page Load<br>" + "Total Courses: " + courseList.size();
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_HOME, data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorSearchPageAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyInstructorPrivileges(account);
String searchKey = getRequestParamValue(Const.ParamsNames.SEARCH_KEY);
if (searchKey == null) {
searchKey = "";
}
int numberOfSearchOptions = 0;
boolean isSearchForStudents = getRequestParamAsBoolean(Const.ParamsNames.SEARCH_STUDENTS);
if (isSearchForStudents) {
numberOfSearchOptions++;
}
boolean isSearchFeedbackSessionData = getRequestParamAsBoolean(Const.ParamsNames.SEARCH_FEEDBACK_SESSION_DATA);
if (isSearchFeedbackSessionData) {
numberOfSearchOptions++;
}
FeedbackResponseCommentSearchResultBundle frCommentSearchResults = new FeedbackResponseCommentSearchResultBundle();
StudentSearchResultBundle studentSearchResults = new StudentSearchResultBundle();
int totalResultsSize = 0;
if (searchKey.isEmpty() || numberOfSearchOptions == 0) {
// display search tips and tutorials
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_SEARCH_TIPS, StatusMessageColor.INFO));
} else {
// Start searching
List<InstructorAttributes> instructors = logic.getInstructorsForGoogleId(account.googleId);
if (isSearchFeedbackSessionData) {
frCommentSearchResults = logic.searchFeedbackResponseComments(searchKey, instructors);
}
if (isSearchForStudents) {
studentSearchResults = logic.searchStudents(searchKey, instructors);
}
totalResultsSize = frCommentSearchResults.numberOfResults + studentSearchResults.numberOfResults;
Set<String> instructorEmails = new HashSet<>();
for (InstructorAttributes instructor : instructors) {
instructorEmails.add(instructor.email);
}
if (totalResultsSize == 0) {
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_SEARCH_NO_RESULTS, StatusMessageColor.WARNING));
}
}
InstructorSearchPageData data = new InstructorSearchPageData(account, sessionToken);
data.init(frCommentSearchResults, studentSearchResults, searchKey, isSearchFeedbackSessionData, isSearchForStudents);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_SEARCH, data);
}
Aggregations