use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class InstructorEditStudentFeedbackSaveActionTest method testClosedSession.
private void testClosedSession() {
______TS("Success case: modifying responses in closed session");
InstructorAttributes instructor = dataBundle.instructors.get("IESFPTCourseinstr");
gaeSimulation.loginAsInstructor(instructor.googleId);
String moderatedStudentEmail = "student1InIESFPTCourse@gmail.tmt";
FeedbackResponsesDb frDb = new FeedbackResponsesDb();
FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
FeedbackQuestionAttributes fq = fqDb.getFeedbackQuestion("Closed feedback session", "IESFPTCourse", 1);
FeedbackResponseAttributes fr = dataBundle.feedbackResponses.get("response1ForQ1InClosedSession");
// necessary to get the correct responseId
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
String[] submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "Edited" + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
InstructorEditStudentFeedbackSaveAction a = getAction(submissionParams);
RedirectResult r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_STUDENT_FEEDBACK_PAGE, false, "student1InIESFPTCourse%40gmail.tmt", "IESFPTCourseinstr", "IESFPTCourse", "Closed+feedback+session"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentAddActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
final FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
final FeedbackResponsesDb frDb = new FeedbackResponsesDb();
final FeedbackResponseCommentsDb frcDb = new FeedbackResponseCommentsDb();
int questionNumber = 1;
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackQuestionAttributes question = fqDb.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes response = frDb.getFeedbackResponse(question.getId(), giverEmail, receiverEmail);
FeedbackResponseCommentAttributes comment = FeedbackResponseCommentAttributes.builder(fs.getCourseId(), fs.getFeedbackSessionName(), giverEmail, new Text("")).withFeedbackQuestionId(question.getId()).withFeedbackResponseId(response.getId()).build();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, comment.courseId, Const.ParamsNames.FEEDBACK_SESSION_NAME, comment.feedbackSessionName, Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.FEEDBACK_QUESTION_ID, comment.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_ID, comment.feedbackResponseId, Const.ParamsNames.COMMENT_ID, "1-1-1-1" };
verifyUnaccessibleWithoutSubmitSessionInSectionsPrivilege(submissionParams);
verifyUnaccessibleWithoutLogin(submissionParams);
verifyUnaccessibleForUnregisteredUsers(submissionParams);
verifyUnaccessibleForStudents(submissionParams);
verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
// remove the comment
frcDb.deleteEntity(comment);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes 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.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentDeleteActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
final FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
final FeedbackResponsesDb frDb = new FeedbackResponsesDb();
final FeedbackResponseCommentsDb frcDb = new FeedbackResponseCommentsDb();
int questionNumber = 2;
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
FeedbackResponseCommentAttributes comment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q2S1C1");
FeedbackResponseAttributes response = typicalBundle.feedbackResponses.get("response1ForQ2S1C1");
FeedbackQuestionAttributes question = fqDb.getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), questionNumber);
response = frDb.getFeedbackResponse(question.getId(), response.giver, response.recipient);
comment = frcDb.getFeedbackResponseComment(response.getId(), comment.giverEmail, comment.createdAt);
comment.feedbackResponseId = response.getId();
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient", Const.ParamsNames.FEEDBACK_RESPONSE_ID, response.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, String.valueOf(comment.getId()) };
verifyUnaccessibleWithoutSubmitSessionInSectionsPrivilege(submissionParams);
verifyUnaccessibleWithoutLogin(submissionParams);
verifyUnaccessibleForUnregisteredUsers(submissionParams);
verifyUnaccessibleForStudents(submissionParams);
verifyAccessibleForInstructorsOfTheSameCourse(submissionParams);
verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentEditActionTest method testAccessControl.
@Override
@Test
protected void testAccessControl() throws Exception {
final FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
final FeedbackResponsesDb frDb = new FeedbackResponsesDb();
final FeedbackResponseCommentsDb frcDb = new FeedbackResponseCommentsDb();
FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
int questionNumber = 1;
FeedbackQuestionAttributes feedbackQuestion = fqDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", questionNumber);
String giverEmail = "student1InCourse1@gmail.tmt";
String receiverEmail = "student1InCourse1@gmail.tmt";
FeedbackResponseAttributes feedbackResponse = frDb.getFeedbackResponse(feedbackQuestion.getId(), giverEmail, receiverEmail);
FeedbackResponseCommentAttributes feedbackResponseComment = typicalBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1");
feedbackResponseComment = frcDb.getFeedbackResponseComment(feedbackResponse.getId(), feedbackResponseComment.giverEmail, feedbackResponseComment.createdAt);
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_RESPONSE_ID, feedbackResponse.getId(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_ID, feedbackResponseComment.getId().toString(), Const.ParamsNames.FEEDBACK_RESPONSE_COMMENT_TEXT, "comment", Const.ParamsNames.FEEDBACK_RESULTS_SORTTYPE, "recipient" };
// this person is not the giver. so not accessible
verifyUnaccessibleWithoutModifySessionCommentInSectionsPrivilege(submissionParams);
verifyOnlyInstructorsCanAccess(submissionParams);
}
Aggregations