use of teammates.ui.controller.AjaxResult in project teammates by TEAMMATES.
the class StudentProfileCreateFormUrlActionTest method testGenerateUploadUrlSuccessTypical.
private void testGenerateUploadUrlSuccessTypical(AccountAttributes student) {
______TS("Typical case");
String[] submissionParams = new String[] {};
gaeSimulation.loginAsStudent(student.googleId);
StudentProfileCreateFormUrlAction action = getAction(submissionParams);
AjaxResult result = getAjaxResult(action);
assertFalse(result.isError);
assertEquals("", result.getStatusMessage());
verifyLogMessage(student, action, result, false);
}
use of teammates.ui.controller.AjaxResult in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionVisibilityMessageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
String instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1").googleId;
gaeSimulation.loginAsInstructor(instructor1OfCourse1);
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackQuestionAttributes fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
______TS("Typical Case - max -> constructed params");
String[] typicalParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "0", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "TEXT", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
InstructorFeedbackQuestionVisibilityMessageAction a = getAction(typicalParams);
AjaxResult r = getAjaxResult(a);
assertFalse(r.isError);
______TS("Custom Case Students - constructed params");
String[] customParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "TEXT", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
a = getAction(customParams);
r = getAjaxResult(a);
assertFalse(r.isError);
______TS("Custom Case Teams - data bundle params");
fs = typicalBundle.feedbackSessions.get("session2InCourse1");
fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
customParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.TEAMS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.TEAMS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "TEXT", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
a = getAction(customParams);
r = getAjaxResult(a);
assertFalse(r.isError);
______TS("Custom Case Instructor - data bundle params");
fs = typicalBundle.feedbackSessions.get("gracePeriodSession");
fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
customParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "2", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "TEXT", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "1", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
a = getAction(customParams);
r = getAjaxResult(a);
assertFalse(r.isError);
______TS("Private case, empty participant list - data bundle params");
String instructor1OfCourse2 = typicalBundle.instructors.get("instructor1OfCourse2").googleId;
// log out of instructor 1
gaeSimulation.logoutUser();
gaeSimulation.loginAsInstructor(instructor1OfCourse2);
fs = typicalBundle.feedbackSessions.get("session1InCourse2");
fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
String[] privateParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "TEXT", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "10", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, "", Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, "", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, "", Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
a = getAction(privateParams);
r = getAjaxResult(a);
assertFalse(r.isError);
______TS("Private case, null participant list - constructed params");
privateParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "TEXT", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "10", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, null, Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, null, Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, null, Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
a = getAction(privateParams);
r = getAjaxResult(a);
assertFalse(r.isError);
}
use of teammates.ui.controller.AjaxResult 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.controller.AjaxResult 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.controller.AjaxResult in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
gaeSimulation.loginAsInstructor(typicalBundle.instructors.get("instructor1OfCourse1").googleId);
FeedbackSessionAttributes session = typicalBundle.feedbackSessions.get("session2InCourse1");
String[] paramsWithoutSortType = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName() };
String[] paramsWithSortTypeQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "question" };
String[] paramsWithSortTypeGiverRecipientQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "giver-recipient-question" };
String[] paramsWithSortTypeRecipientGiverQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question" };
String[] paramsWithSortTypeGiverQuestionRecipient = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "giver-question-recipient" };
String[] paramsWithSortTypeRecipientQuestionGiver = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-question-giver" };
String[] paramsWithSortTypeUndefined = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "undefined" };
String[] paramsNeedAjax = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "undefined", Const.ParamsNames.FEEDBACK_RESULTS_NEED_AJAX, "true" };
String[] paramsWithStartIndex = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "undefined", Const.ParamsNames.FEEDBACK_RESULTS_MAIN_INDEX, "1" };
String[] paramsQuestionNumberOne = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "question", Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1" };
String[] paramsSectionOneByQuestion = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "question", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
String[] paramsSectionOneByGrq = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "giver-recipient-question", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
String[] paramsSectionOneByRgq = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
String[] paramsNeedHtmlTableAllSections = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question", Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED, "true" };
String[] paramsNeedHtmlTableSectionOne = { Const.ParamsNames.COURSE_ID, session.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient-giver-question", Const.ParamsNames.CSV_TO_HTML_TABLE_NEEDED, "true", Const.ParamsNames.FEEDBACK_RESULTS_GROUPBYSECTION, "Section+1" };
______TS("Failure case: no params");
this.verifyAssumptionFailure();
this.verifyAssumptionFailure(new String[] { Const.ParamsNames.COURSE_ID, session.getCourseId() });
______TS("Typical case: no sortType param");
InstructorFeedbackResultsPageAction action = getAction(paramsWithoutSortType);
ShowPageResult result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: sortType question");
action = getAction(paramsWithSortTypeQuestion);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: sortType giver-recipient-question");
action = getAction(paramsWithSortTypeGiverRecipientQuestion);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: sortType recipient-giver-question");
action = getAction(paramsWithSortTypeRecipientGiverQuestion);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: sortType giver-question-recipient");
action = getAction(paramsWithSortTypeGiverQuestionRecipient);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_QUESTION_RECIPIENT, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: sortType recipient-question-giver");
action = getAction(paramsWithSortTypeRecipientQuestionGiver);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_QUESTION_GIVER, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: sortType undefined");
action = getAction(paramsWithSortTypeUndefined);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: feedback result with start index");
action = getAction(paramsWithStartIndex);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: feedback result needing ajax");
action = getAction(paramsNeedAjax);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: specific question number");
action = getAction(paramsQuestionNumberOne);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: view section 1 sortType question");
action = getAction(paramsSectionOneByQuestion);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: view section 1 sortType GRQ");
action = getAction(paramsSectionOneByGrq);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_GIVER_RECIPIENT_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: view section 1 sortType RGQ");
action = getAction(paramsSectionOneByRgq);
result = getShowPageResult(action);
assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_FEEDBACK_RESULTS_BY_RECIPIENT_GIVER_QUESTION, false, "idOfInstructor1OfCourse1"), result.getDestinationWithParams());
assertEquals("", result.getStatusMessage());
assertFalse(result.isError);
______TS("Typical case: view HTML table all sections");
action = getAction(paramsNeedHtmlTableAllSections);
AjaxResult ajaxResult = getAjaxResult(action);
assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), ajaxResult.getDestinationWithParams());
assertEquals("", ajaxResult.getStatusMessage());
assertFalse(ajaxResult.isError);
______TS("Typical case: view HTML table section 1");
action = getAction(paramsNeedHtmlTableSectionOne);
ajaxResult = getAjaxResult(action);
assertEquals(getPageResultDestination("", false, "idOfInstructor1OfCourse1"), ajaxResult.getDestinationWithParams());
assertEquals("", ajaxResult.getStatusMessage());
assertFalse(ajaxResult.isError);
______TS("Typical case: filtering of feedbackResponses for access control");
// accessControl--filtering of the result is tested in FeedbackSessionsLogicTest,
// so the test here about filtering is not rigorous
gaeSimulation.loginAsInstructor(typicalBundle.accounts.get("helperOfCourse1").googleId);
action = getAction(paramsWithSortTypeQuestion);
result = getShowPageResult(action);
InstructorFeedbackResultsPageData pageData = (InstructorFeedbackResultsPageData) result.data;
assertTrue(pageData.getBundle().responses.isEmpty());
}
Aggregations