use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class Action method createPleaseJoinCourseResponse.
protected ActionResult createPleaseJoinCourseResponse(String courseId) {
String errorMessage = "You are not registered in the course " + SanitizationHelper.sanitizeForHtml(courseId);
statusToUser.add(new StatusMessage(errorMessage, StatusMessageColor.DANGER));
isError = true;
statusToAdmin = Const.ACTION_RESULT_FAILURE + " : " + errorMessage;
return createRedirectResult(Const.ActionURIs.STUDENT_HOME_PAGE);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class Action method setStatusForException.
/**
* Status messages to be shown to the admin will be set based
* on the error message in the exception {@code e}.<br>
* Status message to be shown to the user will be set as {@code statusMessageToUser}.<br>
* {@code isError} is also set to true.
*/
protected void setStatusForException(Exception e, String statusMessageToUser) {
isError = true;
String statusMessageForHtml = statusMessageToUser.replace(System.lineSeparator(), Const.HTML_BR_TAG);
statusToUser.add(new StatusMessage(statusMessageForHtml, StatusMessageColor.DANGER));
String exceptionMessageForHtml = e.getMessage().replace(System.lineSeparator(), Const.HTML_BR_TAG);
statusToAdmin = Const.ACTION_RESULT_FAILURE + " : " + exceptionMessageForHtml;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class Action method setStatusForException.
/**
* Status messages to be shown to the user and the admin will be set based
* on the error message in the exception {@code e}.<br>
* {@code isError} is also set to true.
*/
protected void setStatusForException(Exception e) {
isError = true;
String exceptionMessageForHtml = e.getMessage().replace(System.lineSeparator(), Const.HTML_BR_TAG);
statusToUser.add(new StatusMessage(exceptionMessageForHtml, StatusMessageColor.DANGER));
statusToAdmin = Const.ACTION_RESULT_FAILURE + " : " + exceptionMessageForHtml;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class AdminAccountDeleteAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyAdminPrivileges(account);
String instructorId = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID);
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String account = getRequestParamValue("account");
// TODO: We should extract these into separate actions e.g., AdminInstructorDowngradeAction
if (courseId == null && account == null) {
// delete instructor status
logic.downgradeInstructorToStudentCascade(instructorId);
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_STATUS_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor Status for <span class=\"bold\">" + instructorId + "</span> has been deleted.";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_MANAGEMENT_PAGE);
}
if (courseId == null && account != null) {
// delete entire account
logic.deleteAccount(instructorId);
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_ACCOUNT_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor Account for <span class=\"bold\">" + instructorId + "</span> has been deleted.";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_MANAGEMENT_PAGE);
}
String studentId = getRequestParamValue(Const.ParamsNames.STUDENT_ID);
if (courseId != null && studentId != null) {
// remove student from course
StudentAttributes student = logic.getStudentForGoogleId(courseId, studentId);
logic.deleteStudent(courseId, student.email);
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor <span class=\"bold\">" + instructorId + "</span>'s student status in Course" + "<span class=\"bold\">[" + courseId + "]</span> has been deleted";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_DETAILS_PAGE + "?instructorid=" + studentId);
}
// remove instructor from course
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, instructorId);
logic.deleteInstructor(courseId, instructor.email);
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_REMOVED_FROM_COURSE, StatusMessageColor.SUCCESS));
statusToAdmin = "Instructor <span class=\"bold\">" + instructorId + "</span> has been deleted from Course<span class=\"bold\">[" + courseId + "]</span>";
return createRedirectResult(Const.ActionURIs.ADMIN_ACCOUNT_DETAILS_PAGE + "?instructorid=" + instructorId);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class AdminActivityLogPageAction method generateStatusMessage.
private void generateStatusMessage(List<String> versionToQuery, AdminActivityLogPageData data, List<ActivityLogEntry> logs, String courseId) {
StringBuilder status = new StringBuilder(500);
status.append("Total Logs gone through in last search: " + totalLogsSearched + "<br>Total Relevant Logs found in last search: " + String.format("%s<br>", logs.size()));
long earliestSearchTime = data.getFromDate();
ActivityLogEntry earliestLogChecked = null;
if (!logs.isEmpty()) {
earliestLogChecked = logs.get(logs.size() - 1);
}
// if the search space is limited to a certain log
if (logs.size() >= RELEVANT_LOGS_PER_PAGE && earliestLogChecked != null) {
earliestSearchTime = earliestLogChecked.getLogTime();
}
ZoneId targetTimeZone = null;
if (data.isPersonSpecified()) {
String targetUserGoogleId = data.getPersonSpecified();
targetTimeZone = getLocalTimeZoneForRequest(targetUserGoogleId, "");
if (targetTimeZone == null && courseId != null && !courseId.isEmpty()) {
// if the user is unregistered, try finding the timezone by course id passed from Search page
targetTimeZone = getLocalTimeZoneForUnregisteredUserRequest(courseId);
}
} else {
targetTimeZone = Const.SystemParams.ADMIN_TIME_ZONE_ID;
}
String timeInAdminTimeZone = TimeHelper.formatActivityLogTime(Instant.ofEpochMilli(earliestSearchTime), Const.SystemParams.ADMIN_TIME_ZONE_ID);
String timeInUserTimeZone = TimeHelper.formatActivityLogTime(Instant.ofEpochMilli(earliestSearchTime), targetTimeZone);
status.append("The earliest log entry checked on <b>" + timeInAdminTimeZone + "</b> in Admin Time Zone (" + Const.SystemParams.ADMIN_TIME_ZONE_ID.getId() + ") and ");
if (targetTimeZone == null) {
status.append(timeInUserTimeZone).append(".<br>");
} else {
status.append("on <b>" + timeInUserTimeZone + "</b> in Local Time Zone (" + targetTimeZone + ").<br>");
}
status.append("Logs are from following version(s): ");
for (int i = 0; i < versionToQuery.size(); i++) {
String version = versionToQuery.get(i).replace('-', '.');
if (i < versionToQuery.size() - 1) {
status.append(version).append(", ");
} else {
status.append(version).append("<br>");
}
}
status.append("All available version(s): ");
GaeVersionApi versionApi = new GaeVersionApi();
List<Version> versionList = versionApi.getAvailableVersions();
for (int i = 0; i < versionList.size(); i++) {
String version = versionList.get(i).toString();
if (i < versionList.size() - 1) {
status.append(version).append(", ");
} else {
status.append(version).append("<br>");
}
}
// the "Search More" button to continue searching from the previous fromDate
status.append("<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button><input id=\"ifShowAll\" type=\"hidden\" value=\"" + data.getShouldShowAllLogs() + "\"/><input id=\"ifShowTestData\" type=\"hidden\" value=\"" + data.getShouldShowTestData() + "\"/>");
String statusString = status.toString();
data.setStatusForAjax(statusString);
statusToUser.add(new StatusMessage(statusString, StatusMessageColor.INFO));
}
Aggregations