use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionCopyAction method execute.
@Override
protected ActionResult execute() {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
InstructorAttributes instructorDetailForCourse = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructorDetailForCourse, logic.getFeedbackSession(feedbackSessionName, courseId), false, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
String instructorEmail = instructorDetailForCourse.email;
try {
int index = 0;
String feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + index);
statusToAdmin = "";
while (feedbackQuestionId != null) {
FeedbackQuestionAttributes feedbackQuestion = logic.copyFeedbackQuestion(feedbackQuestionId, feedbackSessionName, courseId, instructorEmail);
index++;
feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + index);
statusToAdmin += "Created Feedback Question for Feedback Session:<span class=\"bold\">(" + feedbackQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + feedbackQuestion.courseId + "]</span> created.<br>" + "<span class=\"bold\">" + feedbackQuestion.getQuestionDetails().getQuestionTypeDisplayName() + ":</span> " + SanitizationHelper.sanitizeForHtml(feedbackQuestion.getQuestionDetails().getQuestionText());
}
if (index > 0) {
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, StatusMessageColor.SUCCESS));
} else {
statusToUser.add(new StatusMessage("No questions are indicated to be copied", StatusMessageColor.DANGER));
isError = true;
}
} catch (InvalidParametersException e) {
// This part is not tested because GateKeeper handles if this happens, would be
// extremely difficult to replicate a situation whereby it gets past GateKeeper
statusToUser.add(new StatusMessage(e.getMessage(), StatusMessageColor.DANGER));
statusToAdmin = e.getMessage();
isError = true;
}
return createRedirectResult(new PageData(account, sessionToken).getInstructorFeedbackEditLink(courseId, feedbackSessionName));
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionEditAction method editQuestion.
private void editQuestion(FeedbackQuestionAttributes updatedQuestion) throws InvalidParametersException, EntityDoesNotExistException {
String err = validateQuestionGiverRecipientVisibility(updatedQuestion);
if (!err.isEmpty()) {
statusToUser.add(new StatusMessage(err, StatusMessageColor.DANGER));
isError = true;
}
FeedbackQuestionDetails updatedQuestionDetails = updatedQuestion.getQuestionDetails();
List<String> questionDetailsErrors = updatedQuestionDetails.validateQuestionDetails();
List<StatusMessage> questionDetailsErrorsMessages = new ArrayList<>();
for (String error : questionDetailsErrors) {
questionDetailsErrorsMessages.add(new StatusMessage(error, StatusMessageColor.DANGER));
}
if (questionDetailsErrors.isEmpty()) {
logic.updateFeedbackQuestionNumber(updatedQuestion);
statusToUser.add(new StatusMessage(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, StatusMessageColor.SUCCESS));
statusToAdmin = "Feedback Question " + updatedQuestion.questionNumber + " for session:<span class=\"bold\">(" + updatedQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + updatedQuestion.courseId + "]</span> edited.<br>" + "<span class=\"bold\">" + updatedQuestionDetails.getQuestionTypeDisplayName() + ":</span> " + SanitizationHelper.sanitizeForHtml(updatedQuestionDetails.getQuestionText());
} else {
statusToUser.addAll(questionDetailsErrorsMessages);
isError = true;
}
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class AdminSessionsPageAction method createShowPageResultIfParametersInvalid.
private ActionResult createShowPageResultIfParametersInvalid() {
String startDate = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_STARTDATE);
String endDate = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENDDATE);
String startHour = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_STARTHOUR);
String endHour = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENDHOUR);
String startMin = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_STARTMINUTE);
String endMin = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_ENDMINUTE);
String timeZone = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_TIMEZONE);
Date start;
Date end;
double zone = 0.0;
Calendar calStart = TimeHelper.now(zone);
Calendar calEnd = TimeHelper.now(zone);
calStart.add(Calendar.DAY_OF_YEAR, -3);
calEnd.add(Calendar.DAY_OF_YEAR, 4);
if (checkAllParameters("null")) {
start = calStart.getTime();
end = calEnd.getTime();
} else if (checkAllParameters("notNull")) {
SanitizationHelper.sanitizeForHtml(startDate);
SanitizationHelper.sanitizeForHtml(endDate);
SanitizationHelper.sanitizeForHtml(startHour);
SanitizationHelper.sanitizeForHtml(endHour);
SanitizationHelper.sanitizeForHtml(startMin);
SanitizationHelper.sanitizeForHtml(endMin);
SanitizationHelper.sanitizeForHtml(timeZone);
zone = Double.parseDouble(timeZone);
start = TimeHelper.convertLocalDateTimeToDate(TimeHelper.parseLocalDateTimeForSessionsForm(startDate, startHour, startMin));
end = TimeHelper.convertLocalDateTimeToDate(TimeHelper.parseLocalDateTimeForSessionsForm(endDate, endHour, endMin));
if (start.after(end)) {
isError = true;
statusToUser.add(new StatusMessage("The filter range is not valid." + " End time should be after start time.", StatusMessageColor.DANGER));
statusToAdmin = "Admin Sessions Page Load<br>" + "<span class=\"bold\"> Error: invalid filter range</span>";
prepareDefaultPageData(calStart, calEnd);
data.init(this.map, this.sessionToInstructorIdMap, this.totalOngoingSessions, this.totalOpenStatusSessions, this.totalClosedStatusSessions, this.totalWaitToOpenStatusSessions, this.totalInstitutes, this.rangeStart, this.rangeEnd, this.zone, this.isShowAll);
return createShowPageResult(Const.ViewURIs.ADMIN_SESSIONS, data);
}
} else {
isError = true;
statusToUser.add(new StatusMessage("Error: Missing Parameters", StatusMessageColor.DANGER));
statusToAdmin = "Admin Sessions Page Load<br>" + "<span class=\"bold\"> Error: Missing Parameters</span>";
prepareDefaultPageData(calStart, calEnd);
data.init(this.map, this.sessionToInstructorIdMap, this.totalOngoingSessions, this.totalOpenStatusSessions, this.totalClosedStatusSessions, this.totalWaitToOpenStatusSessions, this.totalInstitutes, this.rangeStart, this.rangeEnd, this.zone, this.isShowAll);
return createShowPageResult(Const.ViewURIs.ADMIN_SESSIONS, data);
}
this.rangeStart = start;
this.rangeEnd = end;
this.zone = zone;
return null;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseStudentDeleteAction method execute.
@Override
public ActionResult execute() {
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);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
logic.deleteStudent(courseId, studentEmail);
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_DELETED, StatusMessageColor.SUCCESS));
statusToAdmin = "Student <span class=\"bold\">" + studentEmail + "</span> in Course <span class=\"bold\">[" + courseId + "]</span> deleted.";
RedirectResult result = createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE);
result.addResponseParam(Const.ParamsNames.COURSE_ID, courseId);
return result;
}
use of teammates.common.util.StatusMessage in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditPageAction 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);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
gateKeeper.verifyAccessible(instructor, logic.getCourse(courseId), Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
if (student == null) {
statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT, StatusMessageColor.DANGER));
isError = true;
return createRedirectResult(Const.ActionURIs.INSTRUCTOR_HOME_PAGE);
}
boolean hasSection = logic.hasIndicatedSections(courseId);
boolean isOpenOrPublishedEmailSentForTheCourse = logic.isOpenOrPublishedEmailSentForTheCourse(courseId);
InstructorCourseStudentDetailsEditPageData data = new InstructorCourseStudentDetailsEditPageData(account, sessionToken, student, student.email, hasSection, isOpenOrPublishedEmailSentForTheCourse);
statusToAdmin = "instructorCourseStudentEdit Page Load<br>" + "Editing Student <span class=\"bold\">" + studentEmail + "'s</span> details " + "in Course <span class=\"bold\">[" + courseId + "]</span>";
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT, data);
}
Aggregations