Search in sources :

Example 6 with StatusMessage

use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.

the class ErrorUserReportLogAction method execute.

@Override
protected ActionResult execute() {
    emailContent = getRequestParamValue(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_CONTENT);
    Assumption.assertPostParamNotNull(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_CONTENT, emailContent);
    emailSubject = getRequestParamValue(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_SUBJECT);
    Assumption.assertPostParamNotNull(Const.ParamsNames.ERROR_FEEDBACK_EMAIL_SUBJECT, emailSubject);
    requestedUrl = getRequestParamValue(Const.ParamsNames.ERROR_FEEDBACK_URL_REQUESTED);
    log.severe(getUserErrorReportLogMessage());
    PageData data = new PageData(account, sessionToken);
    statusToUser.add(new StatusMessage(Const.StatusMessages.ERROR_FEEDBACK_SUBMIT_SUCCESS, StatusMessageColor.SUCCESS));
    return createAjaxResult(data);
}
Also used : PageData(teammates.ui.pagedata.PageData) StatusMessage(teammates.common.util.StatusMessage)

Example 7 with StatusMessage

use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.

the class FeedbackSubmissionEditPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    if (!isSpecificUserJoinedCourse()) {
        return createPleaseJoinCourseResponse(courseId);
    }
    FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(feedbackSessionName, courseId);
    if (feedbackSession == null) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_SESSION_DELETED_NO_ACCESS, StatusMessageColor.WARNING));
        return createSpecificRedirectResult();
    }
    verifyAccessibleForSpecificUser(feedbackSession);
    String regKey = getRequestParamValue(Const.ParamsNames.REGKEY);
    String email = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
    String userEmailForCourse = getUserEmailForCourse();
    data = new FeedbackSubmissionEditPageData(account, student, sessionToken);
    data.bundle = getDataBundle(userEmailForCourse);
    data.setSessionOpenForSubmission(isSessionOpenForSpecificUser(data.bundle.feedbackSession));
    data.init(regKey, email, courseId);
    setStatusToAdmin();
    // TODO: implement this in another way so there is no dependence on status messages from another page
    addFeedbackSubmissionStatusMessageIfNotRedirected();
    return createSpecificShowPageResult();
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSubmissionEditPageData(teammates.ui.pagedata.FeedbackSubmissionEditPageData) StatusMessage(teammates.common.util.StatusMessage)

Example 8 with StatusMessage

use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.

the class FeedbackSubmissionEditPageAction method addFeedbackSubmissionStatusMessageIfNotRedirected.

private void addFeedbackSubmissionStatusMessageIfNotRedirected() {
    // Add status messages only if accessing the page directly, otherwise use only status messages from original page
    if (isRedirectedFromFeedbackSubmissionEditSave()) {
        return;
    }
    if (data.isSessionOpenForSubmission()) {
        // Side effect of only adding status message when accessing the page directly means that the status message
        // following is only shown the first time and not when submitting
        StatusMessage statusMessage = new StatusMessage(Const.StatusMessages.FEEDBACK_SUBMISSIONS_CAN_SUBMIT_PARTIAL_ANSWER, StatusMessageColor.INFO);
        statusToUser.add(statusMessage);
    } else {
        // Side effect of only adding status message when accessing the page directly means that the status message
        // following will not show double submission statuses, such as the following (non-exhaustive):
        // - FEEDBACK_SUBMISSIONS_NOT_OPEN from FeedbackSubmissionEditSaveAction followed by
        // FEEDBACK_SUBMISSIONS_NOT_OPEN from FeedbackSubmissionEditPageAction
        // - FEEDBACK_RESPONSES_SAVED from FeedbackSubmissionEditSaveAction followed by
        // FEEDBACK_SUBMISSIONS_NOT_OPEN from FeedbackSubmissionEditPageAction
        StatusMessage statusMessage = new StatusMessage(Const.StatusMessages.FEEDBACK_SUBMISSIONS_NOT_OPEN, StatusMessageColor.WARNING);
        statusToUser.add(statusMessage);
    }
}
Also used : StatusMessage(teammates.common.util.StatusMessage)

Example 9 with StatusMessage

use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.

the class InstructorCourseAddAction method createCourse.

private void createCourse(String newCourseId, String newCourseName, String newCourseTimeZone) {
    try {
        logic.createCourseAndInstructor(data.account.googleId, newCourseId, newCourseName, newCourseTimeZone);
        String statusMessage = Const.StatusMessages.COURSE_ADDED.replace("${courseEnrollLink}", data.getInstructorCourseEnrollLink(newCourseId)).replace("${courseEditLink}", data.getInstructorCourseEditLink(newCourseId));
        statusToUser.add(new StatusMessage(statusMessage, StatusMessageColor.SUCCESS));
        isError = false;
    } catch (EntityAlreadyExistsException e) {
        setStatusForException(e, Const.StatusMessages.COURSE_EXISTS);
    } catch (InvalidParametersException e) {
        setStatusForException(e);
    }
}
Also used : EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) InvalidParametersException(teammates.common.exception.InvalidParametersException) StatusMessage(teammates.common.util.StatusMessage)

Example 10 with StatusMessage

use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.

the class InstructorCourseAddAction method execute.

@Override
public ActionResult execute() {
    String newCourseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, newCourseId);
    String newCourseName = getRequestParamValue(Const.ParamsNames.COURSE_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_NAME, newCourseName);
    String newCourseTimeZone = getRequestParamValue(Const.ParamsNames.COURSE_TIME_ZONE);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_TIME_ZONE, newCourseTimeZone);
    /* Check if user has the right to execute the action */
    gateKeeper.verifyInstructorPrivileges(account);
    /* Create a new course in the database */
    data = new InstructorCoursesPageData(account, sessionToken);
    createCourse(newCourseId, newCourseName, newCourseTimeZone);
    /* Prepare data for the refreshed page after executing the adding action */
    Map<String, InstructorAttributes> instructorsForCourses = new HashMap<>();
    List<CourseAttributes> activeCourses = new ArrayList<>();
    List<CourseAttributes> archivedCourses = new ArrayList<>();
    // Get list of InstructorAttributes that belong to the user.
    List<InstructorAttributes> instructorList = logic.getInstructorsForGoogleId(data.account.googleId);
    for (InstructorAttributes instructor : instructorList) {
        instructorsForCourses.put(instructor.courseId, instructor);
    }
    // Get corresponding courses of the instructors.
    List<CourseAttributes> allCourses = logic.getCoursesForInstructor(instructorList);
    List<String> archivedCourseIds = logic.getArchivedCourseIds(allCourses, instructorsForCourses);
    for (CourseAttributes course : allCourses) {
        if (archivedCourseIds.contains(course.getId())) {
            archivedCourses.add(course);
        } else {
            activeCourses.add(course);
        }
    }
    // Sort CourseDetailsBundle lists by course id
    CourseAttributes.sortById(activeCourses);
    CourseAttributes.sortById(archivedCourses);
    String courseIdToShowParam = "";
    String courseNameToShowParam = "";
    if (isError) {
        // there is error in adding the course
        courseIdToShowParam = SanitizationHelper.sanitizeForHtml(newCourseId);
        courseNameToShowParam = SanitizationHelper.sanitizeForHtml(newCourseName);
        List<String> statusMessageTexts = new ArrayList<>();
        for (StatusMessage msg : statusToUser) {
            statusMessageTexts.add(msg.getText());
        }
        statusToAdmin = StringHelper.toString(statusMessageTexts, "<br>");
    } else {
        statusToAdmin = "Course added : " + newCourseId;
        statusToAdmin += "<br>Total courses: " + allCourses.size();
    }
    data.init(activeCourses, archivedCourses, instructorsForCourses, courseIdToShowParam, courseNameToShowParam);
    return isError ? createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSES, data) : createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE);
}
Also used : InstructorCoursesPageData(teammates.ui.pagedata.InstructorCoursesPageData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) 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