use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorStudentListPageAction method execute.
@Override
public ActionResult execute() {
gateKeeper.verifyInstructorPrivileges(account);
String searchKey = getRequestParamValue(Const.ParamsNames.SEARCH_KEY);
Boolean displayArchive = getRequestParamAsBoolean(Const.ParamsNames.DISPLAY_ARCHIVE);
Map<String, InstructorAttributes> instructors = new HashMap<>();
List<CourseAttributes> courses = logic.getCoursesForInstructor(account.googleId);
// Sort by creation date
courses.sort(Comparator.comparing(course -> course.createdAt));
// Get instructor attributes
List<InstructorAttributes> instructorList = logic.getInstructorsForGoogleId(account.googleId);
for (InstructorAttributes instructor : instructorList) {
instructors.put(instructor.courseId, instructor);
}
if (courses.isEmpty()) {
statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_NO_COURSE_AND_STUDENTS, StatusMessageColor.WARNING));
}
statusToAdmin = "instructorStudentList Page Load<br>" + "Total Courses: " + courses.size();
List<InstructorStudentListPageCourseData> coursesToDisplay = new ArrayList<>();
for (CourseAttributes course : courses) {
InstructorAttributes instructor = instructors.get(course.getId());
boolean isInstructorAllowedToModify = instructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
boolean isCourseDisplayed = displayArchive || !instructor.isArchived;
if (isCourseDisplayed) {
coursesToDisplay.add(new InstructorStudentListPageCourseData(course, instructor.isArchived, isInstructorAllowedToModify));
}
}
InstructorStudentListPageData data = new InstructorStudentListPageData(account, sessionToken, searchKey, displayArchive, coursesToDisplay);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST, data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorStudentRecordsAjaxPageAction method execute.
@Override
public ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL, studentEmail);
String targetSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, targetSessionName);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
if (student == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_RECORDS, StatusMessageColor.DANGER));
isError = true;
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
}
List<FeedbackSessionAttributes> feedbacks = logic.getFeedbackSessionsListForInstructor(account.googleId, false);
filterFeedbackSessions(courseId, feedbacks, instructor, student);
List<SessionAttributes> sessions = new ArrayList<>();
sessions.addAll(feedbacks);
sessions.sort(SessionAttributes.DESCENDING_ORDER);
List<FeedbackSessionResultsBundle> results = new ArrayList<>();
for (SessionAttributes session : sessions) {
if (session instanceof FeedbackSessionAttributes) {
if (!targetSessionName.isEmpty() && targetSessionName.equals(session.getSessionName())) {
FeedbackSessionResultsBundle result = logic.getFeedbackSessionResultsForInstructor(session.getSessionName(), courseId, instructor.email);
results.add(result);
}
} else {
Assumption.fail("Unknown session type");
}
}
statusToAdmin = "instructorStudentRecords Ajax Page Load<br>" + "Viewing <span class=\"bold\">" + studentEmail + "'s</span> records " + "for session <span class=\"bold\">[" + targetSessionName + "]</span> " + "in course <span class=\"bold\">[" + courseId + "]</span>";
InstructorStudentRecordsAjaxPageData data = new InstructorStudentRecordsAjaxPageData(account, student, sessionToken, results);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS_AJAX, data);
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class AdminEmailComposeSendAction method checkAddressReceiverString.
private void checkAddressReceiverString(String addressReceiverString) throws InvalidParametersException {
FieldValidator validator = new FieldValidator();
String[] emails = addressReceiverString.split(",");
for (String email : emails) {
String error = validator.getInvalidityInfoForEmail(email);
if (!error.isEmpty()) {
isError = true;
statusToUser.add(new StatusMessage(error, StatusMessageColor.DANGER));
throw new InvalidParametersException("<strong>Email Format Error</strong>");
}
}
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class AdminEmailLogPageAction method searchEmailLogsWithTimeIncrement.
/**
* Searches enough email logs within MAX_SEARCH_PERIOD hours.
*/
private void searchEmailLogsWithTimeIncrement(AdminEmailLogPageData data) {
List<EmailLogEntry> emailLogs = new LinkedList<>();
List<String> versionToQuery = getVersionsForQuery(data.getVersions());
AdminLogQuery query = new AdminLogQuery(versionToQuery, null, data.getToDate());
int totalLogsSearched = 0;
GaeLogApi logApi = new GaeLogApi();
long startTime = query.getEndTime() - SEARCH_TIME_INCREMENT;
query.setTimePeriod(startTime, query.getEndTime());
for (int i = 0; i < MAX_SEARCH_TIMES; i++) {
if (emailLogs.size() >= LOGS_PER_PAGE) {
break;
}
List<AppLogLine> searchResult = logApi.fetchLogs(query);
List<EmailLogEntry> filteredLogs = filterLogsForEmailLogPage(searchResult, data);
emailLogs.addAll(filteredLogs);
totalLogsSearched += searchResult.size();
query.moveTimePeriodBackward(SEARCH_TIME_INCREMENT);
}
data.setLogs(emailLogs);
long nextEndTimeToSearch = query.getEndTime();
String status = " Total Logs gone through in last search: " + totalLogsSearched + "<br>" + "<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button>";
data.setStatusForAjax(status);
statusToUser.add(new StatusMessage(status, StatusMessageColor.INFO));
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class AdminEmailTrashDeleteAction method execute.
@Override
protected ActionResult execute() {
gateKeeper.verifyAdminPrivileges(account);
boolean shouldEmptyTrashBin = getRequestParamAsBoolean(Const.ParamsNames.ADMIN_EMAIL_EMPTY_TRASH_BIN);
if (shouldEmptyTrashBin) {
try {
logic.deleteAllEmailsInTrashBin();
statusToAdmin = "All emails in trash bin has been deleted";
statusToUser.add(new StatusMessage("All emails in trash bin has been deleted", StatusMessageColor.SUCCESS));
} catch (BlobstoreFailureException e) {
statusToAdmin = "Blobstore connection failure";
statusToUser.add(new StatusMessage("Blobstore connection failure", StatusMessageColor.DANGER));
}
}
return createRedirectResult(Const.ActionURIs.ADMIN_EMAIL_TRASH_PAGE);
}
Aggregations