Search in sources :

Example 71 with StatusMessage

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

Example 72 with StatusMessage

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);
}
Also used : CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) InstructorCourseDetailsPageData(teammates.ui.pagedata.InstructorCourseDetailsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 73 with StatusMessage

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

Example 74 with StatusMessage

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);
}
Also used : CourseSummaryBundle(teammates.common.datatransfer.CourseSummaryBundle) InstructorHomePageData(teammates.ui.pagedata.InstructorHomePageData) ArrayList(java.util.ArrayList) StatusMessage(teammates.common.util.StatusMessage)

Example 75 with StatusMessage

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);
}
Also used : StudentSearchResultBundle(teammates.common.datatransfer.StudentSearchResultBundle) InstructorSearchPageData(teammates.ui.pagedata.InstructorSearchPageData) FeedbackResponseCommentSearchResultBundle(teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle) StatusMessage(teammates.common.util.StatusMessage) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) HashSet(java.util.HashSet)

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