use of teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentDeleteActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
removeAndRestoreTypicalDataBundle();
FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
FeedbackResponseCommentsDb feedbackResponseCommentsDb = new FeedbackResponseCommentsDb();
int questionNumber = 1;
FeedbackQuestionAttributes feedbackQuestion = feedbackQuestionsDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes feedbackResponse = feedbackResponsesDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
FeedbackResponseCommentAttributes feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
feedbackResponseComment = feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
assertNotNull("response comment not found", feedbackResponseComment);
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("Unsuccessful case: not enough parameters");
verifyAssumptionFailure();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.USER_ID, instructor.googleId };
verifyAssumptionFailure(submissionParams);
______TS("Typical successful case");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
InstructorFeedbackResponseCommentDeleteAction action = getAction(submissionParams);
AjaxResult result = getAjaxResult(action);
InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertNull(feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponseComment.feedbackResponseId, feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt));
assertEquals("", result.getStatusMessage());
______TS("Non-existent feedback response comment");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, // non-existent feedback response comment id
Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, "123123123123123", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertNull(feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponseComment.feedbackResponseId, feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt));
assertEquals("", result.getStatusMessage());
______TS("Instructor is not feedback response comment giver");
gaeSimulation.loginAsInstructor("idOfInstructor2OfCourse1");
questionNumber = 2;
feedbackQuestion = feedbackQuestionsDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
giverEmail = "student2InCourse1@gmail.tmt";
feedbackResponse = feedbackResponsesDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q2S1C1");
feedbackResponseComment = feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
assertNotNull("response comment not found", feedbackResponseComment);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertNull(feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponseComment.feedbackResponseId, feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt));
assertEquals("", result.getStatusMessage());
}
use of teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentEditActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
FeedbackResponseCommentsDb feedbackResponseCommentsDb = new FeedbackResponseCommentsDb();
int questionNumber = 1;
FeedbackQuestionAttributes feedbackQuestion = feedbackQuestionsDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes feedbackResponse = feedbackResponsesDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
FeedbackResponseCommentAttributes feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
feedbackResponseComment = feedbackResponseCommentsDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
assertNotNull("response comment not found", feedbackResponseComment);
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("Unsuccessful csae: not enough parameters");
verifyAssumptionFailure();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.USER_ID, instructor.googleId };
verifyAssumptionFailure(submissionParams);
______TS("Typical successful case for unpublished session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS" };
InstructorFeedbackResponseCommentEditAction action = getAction(submissionParams);
AjaxResult result = getAjaxResult(action);
InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Null show comments and show giver permissions");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Empty show comments and show giver permissions");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Typical successful case for unpublished session public to various recipients");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "OWN_TEAM_MEMBERS" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER_TEAM_MEMBERS" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "STUDENTS" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Non-existent feedback response comment id");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, "123123123123123", Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS" };
try {
action = getAction(submissionParams);
result = getAjaxResult(action);
} catch (AssertionError e) {
assertEquals("FeedbackResponseComment should not be null", e.getMessage());
}
______TS("Instructor is not feedback response comment giver");
gaeSimulation.loginAsInstructor("idOfInstructor2OfCourse1");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Typical successful case for published session");
gaeSimulation.loginAsInstructor(instructor.googleId);
FeedbackSessionAttributes fs = FeedbackSessionsLogic.inst().getFeedbackSession(feedbackResponseComment.feedbackSessionName, feedbackResponseComment.courseId);
FeedbackSessionsLogic.inst().publishFeedbackSession(fs);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, feedbackResponseComment.commentText + " (Edited for published session)", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS" };
action = getAction(submissionParams);
result = getAjaxResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Unsuccessful case: empty comment text");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, feedbackResponseComment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackResponseComment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponseComment.feedbackResponseId, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
action = getAction(submissionParams);
result = getAjaxResult(action);
assertEquals("", result.getStatusMessage());
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertTrue(data.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY, data.errorMessage);
}
use of teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentAddActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
FeedbackQuestionsDb feedbackQuestionsDb = new FeedbackQuestionsDb();
FeedbackResponsesDb feedbackResponsesDb = new FeedbackResponsesDb();
FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session1InCourse1");
int questionNumber = 1;
FeedbackQuestionAttributes question = feedbackQuestionsDb.getFeedbackQuestion(session.getFeedbackSessionName(), session.getCourseId(), questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes response = feedbackResponsesDb.getFeedbackResponse(question.getId(), giverEmail, receiverEmail);
InstructorAttributes instructor = typicalBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor.googleId);
______TS("Unsuccessful case: not enough parameters");
verifyAssumptionFailure();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response" };
verifyAssumptionFailure(submissionParams);
______TS("typical successful case for unpublished session");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
InstructorFeedbackResponseCommentAddAction action = getAction(submissionParams);
ShowPageResult result = getShowPageResult(action);
InstructorFeedbackResponseCommentAjaxPageData data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("typical successful case for unpublished session empty giver permissions");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty giver permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("typical successful case for unpublished session shown to various recipients");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Null comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Empty comment permissions", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to giver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to own team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "OWN_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to receiver team members", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "RECEIVER_TEAM_MEMBERS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment shown to students", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "STUDENTS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("typical successful case for published session");
FeedbackSessionsLogic.inst().publishFeedbackSession(session);
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "Comment to first response, published session", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.RESPONSE_COMMENTS_SHOWCOMMENTSTO, "GIVER,INSTRUCTORS", Const.ParamsNames.RESPONSE_COMMENTS_SHOWGIVERTO, "GIVER,INSTRUCTORS", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
result = getShowPageResult(action);
data = (InstructorFeedbackResponseCommentAjaxPageData) result.data;
assertFalse(data.isError);
assertEquals("", result.getStatusMessage());
______TS("Unsuccessful case: empty comment text");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_QUESTION_ID, question.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
action = getAction(submissionParams);
AjaxResult ajaxResult = getAjaxResult(action);
assertEquals("", ajaxResult.getStatusMessage());
data = (InstructorFeedbackResponseCommentAjaxPageData) ajaxResult.data;
assertTrue(data.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSE_COMMENT_EMPTY, data.errorMessage);
}
use of teammates.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData 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.ui.pagedata.InstructorFeedbackResponseCommentAjaxPageData in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentDeleteAction method execute.
@Override
protected ActionResult execute() {
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);
verifyAccessibleForInstructorToFeedbackResponseComment(feedbackResponseCommentId, instructor, session, response);
Long commentId = Long.parseLong(feedbackResponseCommentId);
logic.deleteDocumentByCommentId(commentId);
logic.deleteFeedbackResponseCommentById(commentId);
statusToAdmin += "InstructorFeedbackResponseCommentDeleteAction:<br>" + "Deleting feedback response comment: " + commentId + "<br>" + "in course/feedback session: " + courseId + "/" + feedbackSessionName + "<br>";
InstructorFeedbackResponseCommentAjaxPageData data = new InstructorFeedbackResponseCommentAjaxPageData(account, sessionToken);
return createAjaxResult(data);
}
Aggregations