Search in sources :

Example 31 with StatusMessage

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);
}
Also used : List(java.util.List) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Const(teammates.common.util.Const) Map(java.util.Map) InstructorStudentListPageCourseData(teammates.ui.datatransfer.InstructorStudentListPageCourseData) StatusMessage(teammates.common.util.StatusMessage) HashMap(java.util.HashMap) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) StatusMessageColor(teammates.common.util.StatusMessageColor) Comparator(java.util.Comparator) InstructorStudentListPageData(teammates.ui.pagedata.InstructorStudentListPageData) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) InstructorStudentListPageCourseData(teammates.ui.datatransfer.InstructorStudentListPageCourseData) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorStudentListPageData(teammates.ui.pagedata.InstructorStudentListPageData)

Example 32 with StatusMessage

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) InstructorStudentRecordsAjaxPageData(teammates.ui.pagedata.InstructorStudentRecordsAjaxPageData) SessionAttributes(teammates.common.datatransfer.attributes.SessionAttributes) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage) FeedbackSessionResultsBundle(teammates.common.datatransfer.FeedbackSessionResultsBundle)

Example 33 with StatusMessage

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>");
        }
    }
}
Also used : FieldValidator(teammates.common.util.FieldValidator) InvalidParametersException(teammates.common.exception.InvalidParametersException) StatusMessage(teammates.common.util.StatusMessage)

Example 34 with StatusMessage

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 = "&nbsp;&nbsp;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));
}
Also used : EmailLogEntry(teammates.common.util.EmailLogEntry) AppLogLine(com.google.appengine.api.log.AppLogLine) LinkedList(java.util.LinkedList) AdminLogQuery(teammates.common.util.AdminLogQuery) GaeLogApi(teammates.common.util.GaeLogApi) StatusMessage(teammates.common.util.StatusMessage)

Example 35 with StatusMessage

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);
}
Also used : BlobstoreFailureException(com.google.appengine.api.blobstore.BlobstoreFailureException) StatusMessage(teammates.common.util.StatusMessage)

Aggregations

StatusMessage (teammates.common.util.StatusMessage)81 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)34 InvalidParametersException (teammates.common.exception.InvalidParametersException)20 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)18 ArrayList (java.util.ArrayList)14 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)9 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)9 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)7 List (java.util.List)6 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)6 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)6 HashMap (java.util.HashMap)4 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)4 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)3 PageData (teammates.ui.pagedata.PageData)3 BlobInfo (com.google.appengine.api.blobstore.BlobInfo)2 BlobKey (com.google.appengine.api.blobstore.BlobKey)2 BlobstoreFailureException (com.google.appengine.api.blobstore.BlobstoreFailureException)2 Text (com.google.appengine.api.datastore.Text)2 AppLogLine (com.google.appengine.api.log.AppLogLine)2