use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentAddAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
String feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_ID, feedbackQuestionId);
String feedbackResponseId = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseId);
String commentId = getRequestParamValue(Const.ParamsNames.COMMENT_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COMMENT_ID, commentId);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
FeedbackResponseAttributes response = logic.getFeedbackResponse(feedbackResponseId);
Assumption.assertNotNull(response);
boolean isCreatorOnly = true;
gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly, response.giverSection, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
gateKeeper.verifyAccessible(instructor, session, !isCreatorOnly, response.recipientSection, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
InstructorFeedbackResponseCommentAjaxPageData data = new InstructorFeedbackResponseCommentAjaxPageData(account, sessionToken);
String giverEmail = response.giver;
String recipientEmail = response.recipient;
FeedbackSessionResultsBundle bundle = logic.getFeedbackSessionResultsForInstructor(feedbackSessionName, courseId, instructor.email);
String giverName = bundle.getGiverNameForResponse(response);
String giverTeamName = bundle.getTeamNameForEmail(giverEmail);
data.giverName = bundle.appendTeamNameToName(giverName, giverTeamName);
String recipientName = bundle.getRecipientNameForResponse(response);
String recipientTeamName = bundle.getTeamNameForEmail(recipientEmail);
data.recipientName = bundle.appendTeamNameToName(recipientName, recipientTeamName);
// Set up comment text
String commentText = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, commentText);
if (commentText.trim().isEmpty()) {
data.errorMessage = Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY;
data.isError = true;
return createAjaxResult(data);
}
FeedbackResponseCommentAttributes feedbackResponseComment = FeedbackResponseCommentAttributes.builder(courseId, feedbackSessionName, instructor.email, new Text(commentText)).withFeedbackQuestionId(feedbackQuestionId).withFeedbackResponseId(feedbackResponseId).withCreatedAt(Instant.now()).withGiverSection(response.giverSection).withReceiverSection(response.recipientSection).build();
// Set up visibility settings
String showCommentTo = getRequestParamValue(Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO);
String showGiverNameTo = getRequestParamValue(Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO);
feedbackResponseComment.showCommentTo = new ArrayList<>();
if (showCommentTo != null && !showCommentTo.isEmpty()) {
String[] showCommentToArray = showCommentTo.split(",");
for (String viewer : showCommentToArray) {
feedbackResponseComment.showCommentTo.add(FeedbackParticipantType.valueOf(viewer.trim()));
}
}
feedbackResponseComment.showGiverNameTo = new ArrayList<>();
if (showGiverNameTo != null && !showGiverNameTo.isEmpty()) {
String[] showGiverNameToArray = showGiverNameTo.split(",");
for (String viewer : showGiverNameToArray) {
feedbackResponseComment.showGiverNameTo.add(FeedbackParticipantType.valueOf(viewer.trim()));
}
}
FeedbackResponseCommentAttributes createdComment = null;
try {
createdComment = logic.createFeedbackResponseComment(feedbackResponseComment);
logic.putDocument(createdComment);
} catch (InvalidParametersException e) {
setStatusForException(e);
data.errorMessage = e.getMessage();
data.isError = true;
}
if (!data.isError) {
statusToAdmin += "InstructorFeedbackResponseCommentAddAction:<br>" + "Adding comment to response: " + feedbackResponseComment.feedbackResponseId + "<br>" + "in course/feedback session: " + feedbackResponseComment.courseId + "/" + feedbackResponseComment.feedbackSessionName + "<br>" + "by: " + feedbackResponseComment.giverEmail + " at " + feedbackResponseComment.createdAt + "<br>" + "comment text: " + feedbackResponseComment.commentText.getValue();
}
if (createdComment == null) {
data.showCommentToString = "";
data.showGiverNameToString = "";
} else {
data.showCommentToString = StringHelper.toString(createdComment.showCommentTo, ",");
data.showGiverNameToString = StringHelper.toString(createdComment.showGiverNameTo, ",");
}
data.comment = createdComment;
data.commentId = commentId;
data.instructorEmailNameTable = bundle.instructorEmailNameTable;
data.question = logic.getFeedbackQuestion(feedbackQuestionId);
data.sessionTimeZone = session.getTimeZone();
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESPONSE_COMMENTS_ADD, data);
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentEditAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
String feedbackResponseId = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseId);
String feedbackResponseCommentId = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseCommentId);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
FeedbackResponseAttributes response = logic.getFeedbackResponse(feedbackResponseId);
Assumption.assertNotNull(response);
FeedbackResponseCommentAttributes frc = logic.getFeedbackResponseComment(Long.parseLong(feedbackResponseCommentId));
Assumption.assertNotNull("FeedbackResponseComment should not be null", frc);
verifyAccessibleForInstructorToFeedbackResponseComment(feedbackResponseCommentId, instructor, session, response);
InstructorFeedbackResponseCommentAjaxPageData data = new InstructorFeedbackResponseCommentAjaxPageData(account, sessionToken);
// Edit comment text
String commentText = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, commentText);
if (commentText.trim().isEmpty()) {
data.errorMessage = Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY;
data.isError = true;
return createAjaxResult(data);
}
FeedbackResponseCommentAttributes feedbackResponseComment = FeedbackResponseCommentAttributes.builder(courseId, feedbackSessionName, instructor.email, new Text(commentText)).withCreatedAt(Instant.now()).withGiverSection(response.giverSection).withReceiverSection(response.recipientSection).build();
feedbackResponseComment.setId(Long.parseLong(feedbackResponseCommentId));
// Edit visibility settings
String showCommentTo = getRequestParamValue(Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO);
String showGiverNameTo = getRequestParamValue(Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO);
feedbackResponseComment.showCommentTo = new ArrayList<>();
if (showCommentTo != null && !showCommentTo.isEmpty()) {
String[] showCommentToArray = showCommentTo.split(",");
for (String viewer : showCommentToArray) {
feedbackResponseComment.showCommentTo.add(FeedbackParticipantType.valueOf(viewer.trim()));
}
}
feedbackResponseComment.showGiverNameTo = new ArrayList<>();
if (showGiverNameTo != null && !showGiverNameTo.isEmpty()) {
String[] showGiverNameToArray = showGiverNameTo.split(",");
for (String viewer : showGiverNameToArray) {
feedbackResponseComment.showGiverNameTo.add(FeedbackParticipantType.valueOf(viewer.trim()));
}
}
FeedbackResponseCommentAttributes updatedComment = null;
try {
updatedComment = logic.updateFeedbackResponseComment(feedbackResponseComment);
// TODO: move putDocument to task queue
logic.putDocument(updatedComment);
} catch (InvalidParametersException e) {
setStatusForException(e);
data.errorMessage = e.getMessage();
data.isError = true;
}
if (!data.isError) {
statusToAdmin += "InstructorFeedbackResponseCommentEditAction:<br>" + "Editing feedback response comment: " + feedbackResponseComment.getId() + "<br>" + "in course/feedback session: " + feedbackResponseComment.courseId + "/" + feedbackResponseComment.feedbackSessionName + "<br>" + "by: " + feedbackResponseComment.giverEmail + "<br>" + "comment text: " + feedbackResponseComment.commentText.getValue();
String commentGiverName = logic.getInstructorForEmail(courseId, frc.giverEmail).name;
String commentEditorName = instructor.name;
// createdAt and lastEditedAt fields in updatedComment as well as sessionTimeZone
// are required to generate timestamps in editedCommentDetails
data.comment = updatedComment;
data.sessionTimeZone = session.getTimeZone();
data.editedCommentDetails = data.createEditedCommentDetails(commentGiverName, commentEditorName);
}
return createAjaxResult(data);
}
use of teammates.common.exception.InvalidParametersException 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;
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class InstructorCourseEnrollSaveAction method enrollAndProcessResultForDisplay.
private List<StudentAttributes>[] enrollAndProcessResultForDisplay(String studentsInfo, String courseId) throws EnrollException, EntityDoesNotExistException, InvalidParametersException, EntityAlreadyExistsException {
CourseEnrollmentResult enrollResult = logic.enrollStudents(studentsInfo, courseId);
List<StudentAttributes> students = enrollResult.studentList;
// Adjust submissions for all feedback responses within the course
List<FeedbackSessionAttributes> feedbackSessions = logic.getFeedbackSessionsForCourse(courseId);
for (FeedbackSessionAttributes session : feedbackSessions) {
// Schedule adjustment of submissions for feedback session in course
taskQueuer.scheduleFeedbackResponseAdjustmentForCourse(courseId, session.getFeedbackSessionName(), enrollResult.enrollmentList);
}
students.sort(Comparator.comparing(obj -> obj.updateStatus.numericRepresentation));
return separateStudents(students);
}
use of teammates.common.exception.InvalidParametersException in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method deleteFeedbackResponsesForQuestionAndCascade.
public void deleteFeedbackResponsesForQuestionAndCascade(String feedbackQuestionId, boolean hasResponseRateUpdate) {
List<FeedbackResponseAttributes> responsesForQuestion = getFeedbackResponsesForQuestion(feedbackQuestionId);
Set<String> emails = new HashSet<>();
for (FeedbackResponseAttributes response : responsesForQuestion) {
this.deleteFeedbackResponseAndCascade(response);
emails.add(response.giver);
}
if (!hasResponseRateUpdate) {
return;
}
try {
FeedbackQuestionAttributes question = fqLogic.getFeedbackQuestion(feedbackQuestionId);
boolean isInstructor = question.giverType == FeedbackParticipantType.SELF || question.giverType == FeedbackParticipantType.INSTRUCTORS;
for (String email : emails) {
boolean hasResponses = hasGiverRespondedForSession(email, question.feedbackSessionName, question.courseId);
if (!hasResponses) {
if (isInstructor) {
fsLogic.deleteInstructorRespondent(email, question.feedbackSessionName, question.courseId);
} else {
fsLogic.deleteStudentFromRespondentList(email, question.feedbackSessionName, question.courseId);
}
}
}
} catch (InvalidParametersException | EntityDoesNotExistException e) {
Assumption.fail("Fail to delete respondent");
}
}
Aggregations