Search in sources :

Example 76 with StatusMessage

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

the class InstructorStudentRecordsPageAction method execute.

@Override
public ActionResult execute() {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId));
    String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
    Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL, studentEmail);
    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> sessions = logic.getFeedbackSessionsListForInstructor(account.googleId, false);
    filterFeedbackSessions(courseId, sessions, instructor, student);
    sessions.sort(FeedbackSessionAttributes.DESCENDING_ORDER);
    StudentProfileAttributes studentProfile = null;
    boolean isInstructorAllowedToViewStudent = instructor.isAllowedForPrivilege(student.section, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
    boolean isStudentWithProfile = !student.googleId.isEmpty();
    if (isInstructorAllowedToViewStudent && isStudentWithProfile) {
        studentProfile = logic.getStudentProfile(student.googleId);
        Assumption.assertNotNull(studentProfile);
    } else {
        if (student.googleId.isEmpty()) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_JOINED_YET_FOR_RECORDS, StatusMessageColor.WARNING));
        } else if (!isInstructorAllowedToViewStudent) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_UNACCESSIBLE_TO_INSTRUCTOR, StatusMessageColor.WARNING));
        }
    }
    if (sessions.isEmpty()) {
        statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_NO_STUDENT_RECORDS, StatusMessageColor.WARNING));
    }
    List<String> sessionNames = new ArrayList<>();
    for (FeedbackSessionAttributes fsa : sessions) {
        sessionNames.add(fsa.getFeedbackSessionName());
    }
    InstructorStudentRecordsPageData data = new InstructorStudentRecordsPageData(account, student, sessionToken, courseId, studentProfile, sessionNames);
    statusToAdmin = "instructorStudentRecords Page Load<br>" + "Viewing <span class=\"bold\">" + studentEmail + "'s</span> records " + "for Course <span class=\"bold\">[" + courseId + "]</span><br>" + "Number of sessions: " + sessions.size() + "<br>" + "Student Profile: " + (studentProfile == null ? "No Profile" : SanitizationHelper.sanitizeForHtmlTag(studentProfile.toString()));
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) InstructorStudentRecordsPageData(teammates.ui.pagedata.InstructorStudentRecordsPageData) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 77 with StatusMessage

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

the class StudentCourseJoinAction method execute.

@Override
public ActionResult execute() {
    Assumption.assertPostParamNotNull(Const.ParamsNames.REGKEY, regkey);
    statusToAdmin = "Action Student Clicked Join Link" + (account.googleId == null ? "<br>Email: " + account.email : "<br>Google ID: " + account.googleId + "<br>Key: " + regkey);
    if (student == null) {
        statusToAdmin += "<br>Student course join failed as student does not exist.";
        String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
        Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
        isError = true;
        statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.NON_EXISTENT_STUDENT_ATTEMPTING_TO_JOIN_COURSE, courseId), StatusMessageColor.WARNING));
        return createRedirectResult(Const.ActionURIs.STUDENT_HOME_PAGE);
    }
    String nextUrl = getNextUrl();
    if (gateKeeper.getCurrentUser() == null) {
        return createRedirectToAuthenticatedJoinPage(nextUrl);
    }
    String confirmUrl = Const.ActionURIs.STUDENT_COURSE_JOIN_AUTHENTICATED + "?" + Const.ParamsNames.REGKEY + "=" + regkey + "&" + Const.ParamsNames.NEXT_URL + "=" + SanitizationHelper.sanitizeForNextUrl(nextUrl);
    String nextUrlType = getPageTypeOfUrl(nextUrl);
    // the student is redirected to join page because he/she is not registered in the course
    boolean isRedirectResult = !Const.SystemParams.PAGES_ACCESSIBLE_WITHOUT_REGISTRATION.contains(nextUrlType);
    boolean isNextUrlAccessibleWithoutLogin = Const.SystemParams.PAGES_ACCESSIBLE_WITHOUT_GOOGLE_LOGIN.contains(nextUrlType);
    String courseId = student.course;
    StudentCourseJoinConfirmationPageData data = new StudentCourseJoinConfirmationPageData(account, student, sessionToken, confirmUrl, gateKeeper.getLogoutUrl(SanitizationHelper.sanitizeForNextUrl(confirmUrl)), isRedirectResult, courseId, isNextUrlAccessibleWithoutLogin);
    excludeStudentDetailsFromResponseParams();
    return createShowPageResult(Const.ViewURIs.STUDENT_COURSE_JOIN_CONFIRMATION, data);
}
Also used : StudentCourseJoinConfirmationPageData(teammates.ui.pagedata.StudentCourseJoinConfirmationPageData) StatusMessage(teammates.common.util.StatusMessage)

Example 78 with StatusMessage

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

the class StudentHomePageAction method showEventualConsistencyMessage.

private void showEventualConsistencyMessage(String recentlyJoinedCourseId) {
    String errorMessage = String.format(Const.StatusMessages.EVENTUAL_CONSISTENCY_MESSAGE_STUDENT, recentlyJoinedCourseId);
    statusToUser.add(new StatusMessage(errorMessage, StatusMessageColor.DANGER));
}
Also used : StatusMessage(teammates.common.util.StatusMessage)

Example 79 with StatusMessage

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

the class StudentProfileEditSaveAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    try {
        account.studentProfile = extractProfileData();
        logic.updateStudentProfile(account.studentProfile);
        statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_EDITED, StatusMessageColor.SUCCESS));
        statusToAdmin = "Student Profile for <span class=\"bold\">(" + account.googleId + ")</span> edited.<br>" + SanitizationHelper.sanitizeForHtmlTag(account.studentProfile.toString());
    } catch (InvalidParametersException ipe) {
        setStatusForException(ipe);
    }
    return createRedirectResult(Const.ActionURIs.STUDENT_PROFILE_PAGE);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) StatusMessage(teammates.common.util.StatusMessage)

Example 80 with StatusMessage

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

the class StudentProfilePictureUploadAction method extractProfilePictureKey.

private BlobInfo extractProfilePictureKey() {
    try {
        Map<String, List<BlobInfo>> blobsMap = BlobstoreServiceFactory.getBlobstoreService().getBlobInfos(request);
        List<BlobInfo> blobs = blobsMap.get(Const.ParamsNames.STUDENT_PROFILE_PHOTO);
        if (blobs == null || blobs.isEmpty()) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_PROFILE_NO_PICTURE_GIVEN, StatusMessageColor.DANGER));
            isError = true;
            return null;
        }
        BlobInfo profilePic = blobs.get(0);
        return validateProfilePicture(profilePic);
    } catch (IllegalStateException e) {
        /*
             * This means the action was called directly (and not via BlobStore API callback).
             * Simply redirect to ProfilePage.
             */
        return null;
    }
}
Also used : List(java.util.List) BlobInfo(com.google.appengine.api.blobstore.BlobInfo) 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