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);
}
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);
}
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));
}
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);
}
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;
}
}
Aggregations