Search in sources :

Example 96 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class DataMigrationForFeedbackResponseCommentSearchDocumentParticipantName method isMigrationNeeded.

/**
 * {@inheritDoc}
 */
@Override
protected boolean isMigrationNeeded(FeedbackResponseCommentAttributes comment) {
    FeedbackQuestionAttributes question = FeedbackQuestionsLogic.inst().getFeedbackQuestion(comment.feedbackQuestionId);
    if (question == null) {
        return false;
    }
    Document document = index.get(comment.getId().toString());
    if (isFixRequiredForGiverName(document, question) || isFixRequiredForReceiverName(document, question)) {
        println("Fix of response participant name required in document: " + document.getId());
        return true;
    }
    return false;
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Document(com.google.appengine.api.search.Document)

Example 97 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class InstructorFeedbackSubmitPageUiTest method testSubmitAction.

private void testSubmitAction() throws Exception {
    ______TS("create new responses");
    submitPage = loginToInstructorFeedbackSubmitPage("IFSubmitUiT.instr", "Open Session");
    submitPage.fillResponseRichTextEditor(1, 0, "Test Self Feedback");
    submitPage.selectRecipient(2, 0, "Alice Betsy</option></td></div>'\"");
    submitPage.fillResponseRichTextEditor(2, 0, "Response to Alice.");
    submitPage.selectRecipient(2, 1, "Drop out");
    submitPage.fillResponseRichTextEditor(2, 1, "Response to student who is going to drop out.");
    submitPage.selectRecipient(2, 2, "Extra guy");
    submitPage.fillResponseRichTextEditor(2, 2, "Response to extra guy.");
    submitPage.fillResponseTextBox(13, 0, "1");
    // Test partial response for question
    submitPage.fillResponseRichTextEditor(4, 1, "Feedback to Instructor 3");
    submitPage.selectRecipient(6, 0, "Teammates Test2");
    submitPage.chooseMcqOption(6, 0, "Algo");
    submitPage.selectRecipient(8, 0, "Teammates Test2");
    submitPage.toggleMsqOption(8, 0, "UI");
    submitPage.toggleMsqOption(8, 0, "Design");
    submitPage.fillResponseTextBox(17, 0, 0, "90");
    submitPage.fillResponseTextBox(17, 0, 1, "10");
    // Just check that some of the responses persisted.
    FeedbackQuestionAttributes fq = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 2);
    FeedbackQuestionAttributes fqPartial = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 6);
    FeedbackQuestionAttributes fqMcq = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 8);
    FeedbackQuestionAttributes fqMsq = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 10);
    FeedbackQuestionAttributes fqNumscale = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 15);
    FeedbackQuestionAttributes fqConstSum = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 19);
    FeedbackQuestionAttributes fqConstSum2 = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 20);
    assertNull(BackDoor.getFeedbackResponse(fq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.alice.b@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqPartial.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqMcq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqMsq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqNumscale.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt"));
    submitPage.submitWithoutConfirmationEmail();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    assertNotNull(BackDoor.getFeedbackResponse(fq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.alice.b@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqPartial.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr3@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqMcq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqMsq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqNumscale.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqConstSum.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt"));
    submitPage = loginToInstructorFeedbackSubmitPage("IFSubmitUiT.instr", "Open Session");
    submitPage.verifyHtmlMainContent("/instructorFeedbackSubmitPagePartiallyFilled.html");
    ______TS("edit existing response");
    // Test editing an existing response + fill up rest of responses at the same time
    String editedResponse = "Edited response to Alice.";
    submitPage.fillResponseRichTextEditor(2, 0, editedResponse);
    submitPage.fillResponseRichTextEditor(3, 0, "Feedback to instructors");
    submitPage.fillResponseRichTextEditor(4, 1, "Feedback to instructor 2.");
    submitPage.fillResponseRichTextEditor(4, 2, "Feedback to instructor 4.");
    submitPage.fillResponseRichTextEditor(4, 3, "Feedback to instructor 5.");
    submitPage.chooseMcqOption(5, 0, "UI");
    // Changed from "Algo" to "UI"
    submitPage.chooseMcqOption(6, 0, "UI");
    submitPage.selectRecipient(6, 1, "Teammates Test3");
    submitPage.chooseMcqOption(6, 1, "UI");
    submitPage.selectRecipient(6, 2, "Teammates Test4");
    submitPage.chooseMcqOption(6, 2, "UI");
    // Click on "None of the above", the option will be deselected when another option is clicked
    submitPage.toggleMsqOption(7, 0, "");
    submitPage.toggleMsqOption(7, 0, "UI");
    submitPage.toggleMsqOption(7, 0, "Algo");
    submitPage.toggleMsqOption(7, 0, "Design");
    submitPage.toggleMsqOption(8, 0, "UI");
    submitPage.toggleMsqOption(8, 0, "Algo");
    submitPage.toggleMsqOption(8, 0, "Design");
    submitPage.selectRecipient(8, 1, "Teammates Test3");
    submitPage.toggleMsqOption(8, 1, "Design");
    submitPage.selectRecipient(8, 2, "Teammates Test4");
    submitPage.toggleMsqOption(8, 2, "UI");
    submitPage.chooseMcqOption(9, 0, "Drop out (Team 2)");
    submitPage.toggleMsqOption(10, 0, "Alice Betsy</option></td></div>'\" (Team 1</td></div>'\")");
    submitPage.toggleMsqOption(10, 0, "Benny Charles (Team 1</td></div>'\")");
    submitPage.toggleMsqOption(10, 0, "Charlie Davis (Team 2)");
    submitPage.toggleMsqOption(10, 0, "Extra guy (Team 2)");
    submitPage.chooseMcqOption(11, 0, "Team 2");
    submitPage.toggleMsqOption(12, 0, "Team 1</td></div>'\"");
    submitPage.toggleMsqOption(12, 0, "Team 3");
    submitPage.fillResponseTextBox(13, 0, "5");
    submitPage.selectRecipient(14, 0, "Teammates Test2");
    submitPage.fillResponseTextBox(14, 0, "1.5");
    submitPage.selectRecipient(14, 1, "Teammates Test3");
    submitPage.fillResponseTextBox(14, 1, "2");
    submitPage.selectRecipient(14, 2, "Teammates Test4");
    submitPage.fillResponseTextBox(14, 2, "3.5");
    submitPage.chooseMcqOption(15, 0, "Teammates Test2");
    submitPage.toggleMsqOption(16, 0, "Teammates Test");
    submitPage.toggleMsqOption(16, 0, "Teammates Test3");
    submitPage.fillResponseTextBox(17, 0, 0, "70");
    submitPage.fillResponseTextBox(17, 0, 1, "30");
    submitPage.fillResponseTextBox(18, 0, 0, "90");
    submitPage.fillResponseTextBox(18, 1, 0, "110");
    submitPage.fillResponseTextBox(18, 2, 0, "100");
    submitPage.fillResponseTextBox(19, 0, 0, "85");
    submitPage.fillResponseTextBox(19, 1, 0, "110");
    submitPage.fillResponseTextBox(19, 2, 0, "105");
    submitPage.fillResponseTextBox(20, 0, 0, "35");
    submitPage.fillResponseTextBox(20, 0, 1, "40");
    submitPage.fillResponseTextBox(20, 0, 2, "25");
    submitPage.fillResponseTextBox(20, 1, 0, "10");
    submitPage.fillResponseTextBox(20, 1, 1, "50");
    submitPage.fillResponseTextBox(20, 1, 2, "40");
    submitPage.fillResponseTextBox(20, 2, 0, "15");
    submitPage.fillResponseTextBox(20, 2, 1, "35");
    submitPage.fillResponseTextBox(20, 2, 2, "50");
    // Just check the edited responses, and two new response.
    assertNull(BackDoor.getFeedbackResponse(fq.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 2"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum2.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 1</td></div>'\""));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum2.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 2"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum2.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 3"));
    // checks that "" can be submitted and other choices reset when "" is clicked
    submitPage.toggleMsqOption(21, 0, "Team 3");
    submitPage.toggleMsqOption(21, 0, "");
    submitPage.submitWithoutConfirmationEmail();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    assertEquals("<p>" + editedResponse + "</p>", BackDoor.getFeedbackResponse(fq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.alice.b@gmail.tmt").getResponseDetails().getAnswerString());
    fq = BackDoor.getFeedbackQuestion("IFSubmitUiT.CS2104", "First Session", 7);
    assertNotNull(BackDoor.getFeedbackResponse(fq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt"));
    assertEquals("UI", BackDoor.getFeedbackResponse(fqMcq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt").getResponseDetails().getAnswerString());
    FeedbackMsqResponseDetails frMsq = (FeedbackMsqResponseDetails) BackDoor.getFeedbackResponse(fqMsq.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr2@gmail.tmt").getResponseDetails();
    assertFalse(frMsq.contains("UI"));
    assertTrue(frMsq.contains("Algo"));
    assertFalse(frMsq.contains("Design"));
    FeedbackNumericalScaleResponseDetails frNumscale = (FeedbackNumericalScaleResponseDetails) BackDoor.getFeedbackResponse(fqNumscale.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt").getResponseDetails();
    assertEquals("5", frNumscale.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum.getId(), "IFSubmitUiT.instr@gmail.tmt", "IFSubmitUiT.instr@gmail.tmt").getResponseDetails();
    assertEquals("70, 30", frConstSum.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum0 = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum2.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 1</td></div>'\"").getResponseDetails();
    assertEquals("90", frConstSum0.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum1 = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum2.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 2").getResponseDetails();
    assertEquals("110", frConstSum1.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum2 = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum2.getId(), "IFSubmitUiT.instr@gmail.tmt", "Team 3").getResponseDetails();
    assertEquals("100", frConstSum2.getAnswerString());
    submitPage = loginToInstructorFeedbackSubmitPage("IFSubmitUiT.instr", "Open Session");
    submitPage.verifyHtmlMainContent("/instructorFeedbackSubmitPageFullyFilled.html");
}
Also used : FeedbackMsqResponseDetails(teammates.common.datatransfer.questions.FeedbackMsqResponseDetails) FeedbackNumericalScaleResponseDetails(teammates.common.datatransfer.questions.FeedbackNumericalScaleResponseDetails) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackConstantSumResponseDetails(teammates.common.datatransfer.questions.FeedbackConstantSumResponseDetails)

Example 98 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class InstructorSubmissionAdjustmentUiTest method getAllTeamResponsesForStudent.

private List<FeedbackResponseAttributes> getAllTeamResponsesForStudent(StudentAttributes student) {
    List<FeedbackResponseAttributes> returnList = new ArrayList<>();
    List<FeedbackResponseAttributes> studentReceiverResponses = BackDoor.getFeedbackResponsesForReceiverForCourse(student.course, student.email);
    for (FeedbackResponseAttributes response : studentReceiverResponses) {
        FeedbackQuestionAttributes question = BackDoor.getFeedbackQuestion(response.feedbackQuestionId);
        if (question.recipientType == FeedbackParticipantType.OWN_TEAM_MEMBERS) {
            returnList.add(response);
        }
    }
    List<FeedbackResponseAttributes> studentGiverResponses = BackDoor.getFeedbackResponsesFromGiverForCourse(student.course, student.email);
    for (FeedbackResponseAttributes response : studentGiverResponses) {
        FeedbackQuestionAttributes question = BackDoor.getFeedbackQuestion(response.feedbackQuestionId);
        if (question.giverType == FeedbackParticipantType.TEAMS || question.recipientType == FeedbackParticipantType.OWN_TEAM_MEMBERS) {
            returnList.add(response);
        }
    }
    return returnList;
}
Also used : FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 99 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class StudentFeedbackSubmissionEditSaveActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    ______TS("edit existing answer");
    FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
    FeedbackQuestionAttributes fq = fqDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    FeedbackResponsesDb frDb = new FeedbackResponsesDb();
    FeedbackResponseAttributes fr = typicalBundle.feedbackResponses.get("response1ForQ1S1C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    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() };
    StudentFeedbackSubmissionEditSaveAction a = getAction(submissionParams);
    RedirectResult r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("deleted response");
    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", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // delete respondent task scheduled
    verifySpecifiedTasksAdded(a, Const.TaskQueue.FEEDBACK_SESSION_UPDATE_RESPONDENT_QUEUE_NAME, 1);
    ______TS("skipped question");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", 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", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // submission confirmation email not sent if parameter does not exist
    verifyNoEmailsSent(a);
    ______TS("new response");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", 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", "New " + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.SEND_SUBMISSION_EMAIL, "on" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // submission confirmation email sent
    verifyNumberOfEmailsSent(a, 1);
    EmailWrapper email = getEmailsSent(a).get(0);
    String courseName = coursesLogic.getCourse(fr.courseId).getName();
    assertEquals(String.format(EmailType.FEEDBACK_SUBMISSION_CONFIRMATION.getSubject(), courseName, fr.feedbackSessionName), email.getSubject());
    assertEquals(student1InCourse1.email, email.getRecipient());
    // append respondent task scheduled
    verifySpecifiedTasksAdded(a, Const.TaskQueue.FEEDBACK_SESSION_UPDATE_RESPONDENT_QUEUE_NAME, 1);
    ______TS("edit response, did not specify recipient");
    fq = fqDb.getFeedbackQuestion("First feedback session", "idOfTypicalCourse1", 2);
    assertNotNull("Feedback question not found in database", fq);
    fr = typicalBundle.feedbackResponses.get("response2ForQ2S1C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-2", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-2-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-2", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-2-0", "", Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-2", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-2-0", "Edited" + fr.getResponseDetails().getAnswerString(), Const.ParamsNames.SEND_SUBMISSION_EMAIL, "on" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertTrue(r.isError);
    assertEquals("You did not specify a recipient for your response in question 2.", r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    // submission confirmation email not sent if the action is an error, even with submission parameter "on"
    verifyNoEmailsSent(a);
    ______TS("edit response, empty answer");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-2", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-2-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-2", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-2-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-2", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-2-0", "", Const.ParamsNames.SEND_SUBMISSION_EMAIL, "off" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    // submission confirmation email not sent if parameter is not "on"
    verifyNoEmailsSent(a);
    ______TS("new response, did not specify recipient");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-2", "1", Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-2", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-2-0", "", Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-2", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-2-0", "Edited" + fr.getResponseDetails().getAnswerString() };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertTrue(r.isError);
    assertEquals("You did not specify a recipient for your response in question 2.", r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "student1InCourse1", "idOfTypicalCourse1", "First+feedback+session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("mcq");
    DataBundle dataBundle = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
    removeAndRestoreDataBundle(dataBundle);
    fq = fqDb.getFeedbackQuestion("MCQ Session", "FSQTT.idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    fr = dataBundle.feedbackResponses.get("response1ForQ1S1C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    student1InCourse1 = dataBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    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", "It's perfect" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MCQ+Session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("mcq, question skipped");
    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() };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MCQ+Session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("mcq with other option enabled");
    fq = fqDb.getFeedbackQuestion("MCQ Session", "FSQTT.idOfTypicalCourse1", 3);
    assertNotNull("Feedback question not found in database", fq);
    fr = dataBundle.feedbackResponses.get("response1ForQ3S1C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-2", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-2-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-2", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-2-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-2", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-2-0", "Tutorial", Const.ParamsNames.FEEDBACK_QUESTION_MCQ_ISOTHEROPTIONANSWER + "-2-0", "1" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MCQ+Session"), r.getDestinationWithParams());
    FeedbackResponseAttributes finalFr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull(finalFr);
    assertEquals("Tutorial", finalFr.getResponseDetails().getAnswerString());
    ______TS("msq");
    fq = fqDb.getFeedbackQuestion("MSQ Session", "FSQTT.idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    fr = dataBundle.feedbackResponses.get("response1ForQ1S2C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    student1InCourse1 = dataBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    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", "It's perfect" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MSQ+Session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("msq, question skipped");
    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() };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MSQ+Session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("msq with other option enabled, student selects predefined options and other option");
    fq = fqDb.getFeedbackQuestion("MSQ Session", "FSQTT.idOfTypicalCourse1", 3);
    assertNotNull("Feedback question not found in database", fq);
    fr = dataBundle.feedbackResponses.get("response1ForQ3S2C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-3", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-3-0", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-3", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-3-0", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-3", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-3-0", "Pizza, Pasta, Chicken rice, Hotdog", Const.ParamsNames.FEEDBACK_QUESTION_MSQ_ISOTHEROPTIONANSWER + "-3-0", "1" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MSQ+Session"), r.getDestinationWithParams());
    finalFr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull(finalFr);
    assertEquals("Pizza, Pasta, Chicken rice, Hotdog", finalFr.getResponseDetails().getAnswerString());
    ______TS("msq with other option enabled, student selects predefined options only, not other option");
    fr = dataBundle.feedbackResponses.get("response2ForQ3S2C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-3", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-3-1", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-3", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-3-1", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-3", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-3-1", "Pasta", Const.ParamsNames.FEEDBACK_QUESTION_MSQ_ISOTHEROPTIONANSWER + "-3-1", "0" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MSQ+Session"), r.getDestinationWithParams());
    finalFr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull(finalFr);
    assertEquals("Pasta", finalFr.getResponseDetails().getAnswerString());
    ______TS("msq with other option enabled, student selects other option only, not any predefined option");
    fr = dataBundle.feedbackResponses.get("response3ForQ3S2C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-3", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-3-2", fr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-3", fr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-3-2", fr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-3", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-3-2", "Hotdog", Const.ParamsNames.FEEDBACK_QUESTION_MSQ_ISOTHEROPTIONANSWER + "-3-2", "1" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MSQ+Session"), r.getDestinationWithParams());
    finalFr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull(finalFr);
    assertEquals("Hotdog", finalFr.getResponseDetails().getAnswerString());
    ______TS("numscale");
    fq = fqDb.getFeedbackQuestion("NUMSCALE Session", "FSQTT.idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    FeedbackNumericalScaleQuestionDetails fqd = (FeedbackNumericalScaleQuestionDetails) fq.getQuestionDetails();
    fr = dataBundle.feedbackResponses.get("response1ForQ1S3C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    student1InCourse1 = dataBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    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", "1", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN + "-1-0", Integer.toString(fqd.getMinScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX + "-1-0", Integer.toString(fqd.getMaxScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP + "-1-0", StringHelper.toDecimalFormatString(fqd.getStep()) };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertFalse(r.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "NUMSCALE+Session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("numscale, question skipped");
    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", "", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN + "-1-0", Integer.toString(fqd.getMinScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX + "-1-0", Integer.toString(fqd.getMaxScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP + "-1-0", StringHelper.toDecimalFormatString(fqd.getStep()) };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "NUMSCALE+Session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("Successful case: const sum: typical case");
    fq = fqDb.getFeedbackQuestion("CONSTSUM Session", "FSQTT.idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    fr = dataBundle.feedbackResponses.get("response1ForQ1S4C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    FeedbackResponseAttributes fr2 = dataBundle.feedbackResponses.get("response2ForQ1S4C1");
    // necessary to get the correct responseId
    fr2 = frDb.getFeedbackResponse(fq.getId(), fr2.giver, fr2.recipient);
    assertNotNull("Feedback response not found in database", fr2);
    student1InCourse1 = dataBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    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", "50", Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "50" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertFalse(r.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "CONSTSUM+Session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("Successful case: const sum: question skipped");
    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", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "CONSTSUM+Session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("Successful case: contrib qn: typical case");
    fq = fqDb.getFeedbackQuestion("CONTRIB Session", "FSQTT.idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    fr = dataBundle.feedbackResponses.get("response1ForQ1S5C1");
    // necessary to get the correct responseId
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    student1InCourse1 = dataBundle.students.get("student1InCourse1");
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    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", "150" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertFalse(r.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "CONTRIB+Session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("Successful case: contrib qn: question skipped");
    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", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertFalse(r.isError);
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, r.isError, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "CONTRIB+Session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("Unsuccessful case: test empty feedback session name parameter");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, dataBundle.feedbackResponses.get("response1ForQ1S1C1").courseId };
    try {
        a = getAction(submissionParams);
        r = getRedirectResult(a);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.FEEDBACK_SESSION_NAME), e.getMessage());
    }
    ______TS("Unsuccessful case: test empty course id parameter");
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_SESSION_NAME, dataBundle.feedbackResponses.get("response1ForQ1S1C1").feedbackSessionName };
    try {
        a = getAction(submissionParams);
        r = getRedirectResult(a);
        signalFailureToDetectException("Did not detect that parameters are null.");
    } catch (NullPostParameterException e) {
        assertEquals(String.format(Const.StatusCodes.NULL_POST_PARAMETER, Const.ParamsNames.COURSE_ID), e.getMessage());
    }
    ______TS("Unsuccessful case: modified recipient list to invalid recipient");
    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", "invalid recipient", Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertTrue(r.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, true, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "CONTRIB+Session"), r.getDestinationWithParams());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, "invalid recipient"));
    ______TS("Unsuccessful case: modified question type to another type");
    // Response is supposed to be CONTRIB, but submit as RUBRIC
    assertEquals(fq.questionType, FeedbackQuestionType.CONTRIB);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", 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", "RUBRIC", Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertTrue(r.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, true, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "CONTRIB+Session"), r.getDestinationWithParams());
    assertEquals(String.format(Const.StatusMessages.FEEDBACK_RESPONSES_WRONG_QUESTION_TYPE, "1"), r.getStatusMessage());
    assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
    ______TS("Unsuccessful case: try to delete response not belonging to the student");
    fq = fqDb.getFeedbackQuestion("MCQ Session", "FSQTT.idOfTypicalCourse1", 1);
    assertNotNull("Feedback question not found in database", fq);
    FeedbackResponseAttributes otherFr = dataBundle.feedbackResponses.get("response2ForQ1S1C1");
    List<FeedbackResponseAttributes> responsesToAdd = new ArrayList<>();
    responsesToAdd.add(fr);
    frDb.createFeedbackResponses(responsesToAdd);
    // necessary to get the correct responseId
    otherFr = frDb.getFeedbackResponse(fq.getId(), otherFr.giver, otherFr.recipient);
    assertNotNull("Feedback response not found in database", fr);
    submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "1", Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-0", otherFr.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, otherFr.feedbackSessionName, Const.ParamsNames.COURSE_ID, otherFr.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", otherFr.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-0", otherFr.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", otherFr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", "" };
    a = getAction(submissionParams);
    r = getRedirectResult(a);
    assertTrue(r.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, true, "FSQTT.student1InCourse1", "FSQTT.idOfTypicalCourse1", "MCQ+Session"), r.getDestinationWithParams());
    assertNotNull(frDb.getFeedbackResponse(fq.getId(), otherFr.giver, otherFr.recipient));
    gaeSimulation.logoutUser();
    ______TS("Unregistered student with valid submission of response remains at submission page");
    StudentAttributes unregisteredStudent = dataBundle.students.get("unregisteredStudentInCourse1");
    fq = fqDb.getFeedbackQuestion("Unregistered Student Session", "FSQTT.idOfTypicalCourse2", 1);
    assertNotNull("Feedback question not found in database", fq);
    fqd = (FeedbackNumericalScaleQuestionDetails) fq.getQuestionDetails();
    fr = dataBundle.feedbackResponses.get("response1ForQ1S1C2");
    fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
    // ensure correct response id is retrieved
    assertNotNull("Feedback response not found in database", fr);
    FeedbackSessionsDb fsDb = new FeedbackSessionsDb();
    FeedbackSessionAttributes fsa = dataBundle.feedbackSessions.get("unregisteredStudentSession");
    fsa = fsDb.getFeedbackSession(unregisteredStudent.course, fsa.getFeedbackSessionName());
    assertNotNull("Feedback session not found in database", fsa);
    String studentKey = StudentsLogic.inst().getEncryptedKeyForStudent(unregisteredStudent.course, unregisteredStudent.email);
    // Valid response from unregistered student
    String[] validSubmissionParams = 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", fr.getResponseDetails().getAnswerString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN + "-1-0", Integer.toString(fqd.getMinScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX + "-1-0", Integer.toString(fqd.getMaxScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP + "-1-0", StringHelper.toDecimalFormatString(fqd.getStep()), Const.ParamsNames.SEND_SUBMISSION_EMAIL, "on", Const.ParamsNames.REGKEY, studentKey, Const.ParamsNames.STUDENT_EMAIL, unregisteredStudent.email };
    StudentFeedbackSubmissionEditSaveAction submissionAction = getAction(validSubmissionParams);
    RedirectResult redirectResult = getRedirectResult(submissionAction);
    assertFalse(redirectResult.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, "unregisteredStudentInCourse2%40gmail.tmt", redirectResult.isError, unregisteredStudent.course, "Unregistered+Student+Session", studentKey), redirectResult.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, redirectResult.getStatusMessage());
    gaeSimulation.logoutUser();
    // submission confirmation email sent also for unregistered student
    verifyNumberOfEmailsSent(submissionAction, 1);
    email = getEmailsSent(submissionAction).get(0);
    courseName = coursesLogic.getCourse(fr.courseId).getName();
    assertEquals(String.format(EmailType.FEEDBACK_SUBMISSION_CONFIRMATION.getSubject(), courseName, fr.feedbackSessionName), email.getSubject());
    assertEquals(unregisteredStudent.email, email.getRecipient());
    ______TS("Unregistered student with invalid submission of response remains at submission page");
    studentKey = StudentsLogic.inst().getEncryptedKeyForStudent(unregisteredStudent.course, unregisteredStudent.email);
    // Invalid response from unregistered student
    String[] invalidSubmissionParams = 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", "100", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN + "-1-0", Integer.toString(fqd.getMinScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX + "-1-0", Integer.toString(fqd.getMaxScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP + "-1-0", StringHelper.toDecimalFormatString(fqd.getStep()), Const.ParamsNames.REGKEY, studentKey, Const.ParamsNames.STUDENT_EMAIL, unregisteredStudent.email };
    submissionAction = getAction(invalidSubmissionParams);
    redirectResult = getRedirectResult(submissionAction);
    assertTrue(redirectResult.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE, "unregisteredStudentInCourse2%40gmail.tmt", redirectResult.isError, unregisteredStudent.course, "Unregistered+Student+Session", studentKey), redirectResult.getDestinationWithParams());
    assertEquals("100 is out of the range for Numerical-scale question.(min=1, max=5)", redirectResult.getStatusMessage());
    gaeSimulation.logoutUser();
}
Also used : FeedbackSessionsDb(teammates.storage.api.FeedbackSessionsDb) RedirectResult(teammates.ui.controller.RedirectResult) StudentFeedbackSubmissionEditSaveAction(teammates.ui.controller.StudentFeedbackSubmissionEditSaveAction) ArrayList(java.util.ArrayList) FeedbackResponsesDb(teammates.storage.api.FeedbackResponsesDb) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EmailWrapper(teammates.common.util.EmailWrapper) FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) NullPostParameterException(teammates.common.exception.NullPostParameterException) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) DataBundle(teammates.common.datatransfer.DataBundle) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackQuestionsDb(teammates.storage.api.FeedbackQuestionsDb) FeedbackNumericalScaleQuestionDetails(teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails) Test(org.testng.annotations.Test)

Example 100 with FeedbackQuestionAttributes

use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.

the class FeedbackQuestionAttributesTest method testRemoveIrrelevantVisibilityOptions.

@Test
public void testRemoveIrrelevantVisibilityOptions() {
    ______TS("test teams->none");
    FeedbackQuestionAttributes question = new FeedbackQuestionAttributes();
    List<FeedbackParticipantType> participants = new ArrayList<>();
    question.feedbackSessionName = "test session";
    question.courseId = "some course";
    question.creatorEmail = "test@case.com";
    question.questionMetaData = new Text("test qn from teams->none.");
    question.questionNumber = 1;
    question.questionType = FeedbackQuestionType.TEXT;
    question.giverType = FeedbackParticipantType.TEAMS;
    question.recipientType = FeedbackParticipantType.NONE;
    question.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertTrue(question.showGiverNameTo.isEmpty());
    assertTrue(question.showRecipientNameTo.isEmpty());
    // check that other types are not removed
    assertTrue(question.showResponsesTo.contains(FeedbackParticipantType.STUDENTS));
    assertEquals(question.showResponsesTo.size(), 1);
    ______TS("test students->teams");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.TEAMS;
    participants.clear();
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    question.showGiverNameTo = new ArrayList<>(participants);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 2);
    assertEquals(question.showRecipientNameTo.size(), 3);
    assertEquals(question.showResponsesTo.size(), 3);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    ______TS("test students->team members including giver");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF;
    participants.clear();
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    question.showGiverNameTo = new ArrayList<>(participants);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 3);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.OWN_TEAM_MEMBERS_INCLUDING_SELF));
    ______TS("test students->instructors");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.INSTRUCTORS;
    participants.clear();
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 4);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    ______TS("test students->own team");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.OWN_TEAM;
    participants.clear();
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 4);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    ______TS("test students->own team members");
    question.giverType = FeedbackParticipantType.STUDENTS;
    question.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS;
    participants.clear();
    participants.add(FeedbackParticipantType.RECEIVER);
    participants.add(FeedbackParticipantType.INSTRUCTORS);
    participants.add(FeedbackParticipantType.OWN_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS);
    participants.add(FeedbackParticipantType.STUDENTS);
    question.showGiverNameTo = new ArrayList<>(participants);
    question.showRecipientNameTo = new ArrayList<>(participants);
    question.showResponsesTo = new ArrayList<>(participants);
    question.removeIrrelevantVisibilityOptions();
    assertEquals(question.showGiverNameTo.size(), 4);
    assertEquals(question.showRecipientNameTo.size(), 4);
    assertEquals(question.showResponsesTo.size(), 4);
    assertFalse(question.showGiverNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showRecipientNameTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
    assertFalse(question.showResponsesTo.contains(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS));
}
Also used : ArrayList(java.util.ArrayList) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Text(com.google.appengine.api.datastore.Text) FeedbackParticipantType(teammates.common.datatransfer.FeedbackParticipantType) Test(org.testng.annotations.Test)

Aggregations

FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)154 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)64 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 ArrayList (java.util.ArrayList)47 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)38 Test (org.testng.annotations.Test)35 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)25 List (java.util.List)23 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)23 FeedbackQuestionsDb (teammates.storage.api.FeedbackQuestionsDb)19 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)18 HashMap (java.util.HashMap)17 RedirectResult (teammates.ui.controller.RedirectResult)17 HashSet (java.util.HashSet)12 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)12 Text (com.google.appengine.api.datastore.Text)11 Map (java.util.Map)10 FeedbackQuestionDetails (teammates.common.datatransfer.questions.FeedbackQuestionDetails)10 LinkedHashMap (java.util.LinkedHashMap)9 DataBundle (teammates.common.datatransfer.DataBundle)9