Search in sources :

Example 1 with FeedbackQuestionAttributes

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

the class InstructorFeedbackEditPageUiTest method testEditQuestionNumberAction.

private void testEditQuestionNumberAction() throws MaximumRetriesExceededException {
    ______TS("edit question number success");
    feedbackEditPage.clickEditQuestionButton(2);
    feedbackEditPage.selectQuestionNumber(2, 1);
    feedbackEditPage.clickSaveExistingQuestionButton(2);
    feedbackEditPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED);
    ______TS("questions still editable even if questions numbers became inconsistent");
    FeedbackQuestionAttributes firstQuestion = getFeedbackQuestionWithRetry(courseId, feedbackSessionName, 1);
    assertEquals(1, firstQuestion.questionNumber);
    FeedbackQuestionAttributes secondQuestion = getFeedbackQuestionWithRetry(courseId, feedbackSessionName, 2);
    assertEquals(2, secondQuestion.questionNumber);
    int originalSecondQuestionNumber = secondQuestion.questionNumber;
    // edit so that both questions have the same question number
    secondQuestion.questionNumber = firstQuestion.questionNumber;
    BackDoor.editFeedbackQuestion(secondQuestion);
    // verify both can be edited
    feedbackEditPage = getFeedbackEditPage();
    feedbackEditPage.clickEditQuestionButton(1);
    assertTrue(feedbackEditPage.isQuestionEnabled(1));
    feedbackEditPage.clickEditQuestionButton(2);
    assertTrue(feedbackEditPage.isQuestionEnabled(2));
    // fix inconsistent state
    secondQuestion.questionNumber = originalSecondQuestionNumber;
    BackDoor.editFeedbackQuestion(secondQuestion);
    feedbackEditPage = getFeedbackEditPage();
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)

Example 2 with FeedbackQuestionAttributes

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

the class InstructorFeedbackResultsPageUiTest method testExceptionalCases.

@Test
public void testExceptionalCases() throws Exception {
    ______TS("Case where more than 1 question with same question number");
    // results page should be able to load incorrect data and still display it gracefully
    FeedbackQuestionAttributes firstQuestion = testData.feedbackQuestions.get("qn1InSession4");
    assertEquals(1, firstQuestion.questionNumber);
    FeedbackQuestionAttributes firstQuestionFromDatastore = BackDoor.getFeedbackQuestion(firstQuestion.courseId, firstQuestion.feedbackSessionName, firstQuestion.questionNumber);
    FeedbackQuestionAttributes secondQuestion = testData.feedbackQuestions.get("qn2InSession4");
    assertEquals(2, secondQuestion.questionNumber);
    // need to retrieve question from datastore to get its questionId
    FeedbackQuestionAttributes secondQuestionFromDatastore = BackDoor.getFeedbackQuestion(secondQuestion.courseId, secondQuestion.feedbackSessionName, secondQuestion.questionNumber);
    assertEquals(secondQuestion, secondQuestionFromDatastore);
    // make both questions have the same question number
    secondQuestionFromDatastore.questionNumber = 1;
    BackDoor.editFeedbackQuestion(secondQuestionFromDatastore);
    resultsPage = loginToInstructorFeedbackResultsPage("CFResultsUiT.instr", "Session with errors");
    resultsPage.loadResultQuestionPanel(1);
    resultsPage.loadResultQuestionPanel(2);
    // compare html for each question panel
    // to verify that the right responses are showing for each question
    By firstQuestionPanelResponses = By.xpath("//div[contains(@class,'panel')][.//input[@name='questionid'][@value='" + firstQuestionFromDatastore.getId() + "']]" + "//div[contains(@class, 'table-responsive')]");
    resultsPage.verifyHtmlPart(firstQuestionPanelResponses, "/instructorFeedbackResultsDuplicateQuestionNumberPanel1.html");
    By secondQuestionPanelResponses = By.xpath("//div[contains(@class,'panel')][.//input[@name='questionid'][@value='" + secondQuestionFromDatastore.getId() + "']]" + "//div[contains(@class, 'table-responsive')]");
    resultsPage.verifyHtmlPart(secondQuestionPanelResponses, "/instructorFeedbackResultsDuplicateQuestionNumberPanel2.html");
    ______TS("Results with sanitized data");
    resultsPage = loginToInstructorFeedbackResultsPage("CFResultsUiT.SanitizedTeam.instr", "Session with sanitized data");
    resultsPage.loadResultQuestionPanel(1);
    resultsPage.verifyHtmlMainContent("/instructorFeedbackResultsPageWithSanitizedData.html");
    ______TS("Results with sanitized data with comments : giver > recipient > question");
    resultsPage.displayByGiverRecipientQuestion();
    resultsPage.loadResultSectionPanel(1, 2);
    resultsPage.verifyHtmlMainContent("/instructorFeedbackResultsPageGQRWithSanitizedData.html");
}
Also used : By(org.openqa.selenium.By) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Test(org.testng.annotations.Test)

Example 3 with FeedbackQuestionAttributes

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

the class FeedbackQuestionAttributesTest method testGetQuestionDetails.

@Test
public void testGetQuestionDetails() {
    ______TS("Text question: new Json format");
    FeedbackQuestionAttributes fq = typicalBundle.feedbackQuestions.get("qn5InSession1InCourse1");
    FeedbackTextQuestionDetails questionDetails = new FeedbackTextQuestionDetails("New format text question");
    fq.setQuestionDetails(questionDetails);
    assertTrue(fq.isValid());
    assertEquals(fq.getQuestionDetails().getQuestionText(), "New format text question");
    ______TS("Text question: old string format");
    fq = typicalBundle.feedbackQuestions.get("qn2InSession1InCourse1");
    assertEquals(fq.getQuestionDetails().getQuestionText(), "Rate 1 other student's product");
}
Also used : FeedbackTextQuestionDetails(teammates.common.datatransfer.questions.FeedbackTextQuestionDetails) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Test(org.testng.annotations.Test)

Example 4 with FeedbackQuestionAttributes

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

the class FeedbackQuestionAttributesTest method testValidate.

@Test
public void testValidate() throws Exception {
    FeedbackQuestionAttributes fq = new FeedbackQuestionAttributes();
    fq.feedbackSessionName = "";
    fq.courseId = "";
    fq.creatorEmail = "";
    fq.questionType = FeedbackQuestionType.TEXT;
    fq.giverType = FeedbackParticipantType.NONE;
    fq.recipientType = FeedbackParticipantType.RECEIVER;
    fq.showGiverNameTo = new ArrayList<>();
    fq.showGiverNameTo.add(FeedbackParticipantType.SELF);
    fq.showGiverNameTo.add(FeedbackParticipantType.STUDENTS);
    fq.showRecipientNameTo = new ArrayList<>();
    fq.showRecipientNameTo.add(FeedbackParticipantType.SELF);
    fq.showRecipientNameTo.add(FeedbackParticipantType.STUDENTS);
    fq.showResponsesTo = new ArrayList<>();
    fq.showResponsesTo.add(FeedbackParticipantType.NONE);
    fq.showResponsesTo.add(FeedbackParticipantType.SELF);
    assertFalse(fq.isValid());
    String errorMessage = getPopulatedEmptyStringErrorMessage(FieldValidator.SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE_EMPTY_STRING, FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME, FieldValidator.FEEDBACK_SESSION_NAME_MAX_LENGTH) + System.lineSeparator() + getPopulatedEmptyStringErrorMessage(FieldValidator.COURSE_ID_ERROR_MESSAGE_EMPTY_STRING, FieldValidator.COURSE_ID_FIELD_NAME, FieldValidator.COURSE_ID_MAX_LENGTH) + System.lineSeparator() + "Invalid creator's email: " + getPopulatedEmptyStringErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE_EMPTY_STRING, FieldValidator.EMAIL_FIELD_NAME, FieldValidator.EMAIL_MAX_LENGTH) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.giverType.toString(), FieldValidator.GIVER_TYPE_NAME) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.recipientType.toString(), FieldValidator.RECIPIENT_TYPE_NAME) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showGiverNameTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + "Trying to show giver name to STUDENTS without showing response first." + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showRecipientNameTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + "Trying to show recipient name to STUDENTS without showing response first." + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showResponsesTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showResponsesTo.get(1).toString(), FieldValidator.VIEWER_TYPE_NAME);
    assertEquals(errorMessage, StringHelper.toString(fq.getInvalidityInfo()));
    fq.feedbackSessionName = "First Feedback Session";
    fq.courseId = "CS1101";
    fq.creatorEmail = "instructor1@course1.com";
    fq.giverType = FeedbackParticipantType.TEAMS;
    fq.recipientType = FeedbackParticipantType.OWN_TEAM;
    assertFalse(fq.isValid());
    errorMessage = String.format(FieldValidator.PARTICIPANT_TYPE_TEAM_ERROR_MESSAGE, fq.recipientType.toDisplayRecipientName(), fq.giverType.toDisplayGiverName()) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showGiverNameTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + "Trying to show giver name to STUDENTS without showing response first." + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showRecipientNameTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + "Trying to show recipient name to STUDENTS without showing response first." + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showResponsesTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showResponsesTo.get(1).toString(), FieldValidator.VIEWER_TYPE_NAME);
    assertEquals(errorMessage, StringHelper.toString(fq.getInvalidityInfo()));
    fq.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS;
    assertFalse(fq.isValid());
    errorMessage = String.format(FieldValidator.PARTICIPANT_TYPE_TEAM_ERROR_MESSAGE, fq.recipientType.toDisplayRecipientName(), fq.giverType.toDisplayGiverName()) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showGiverNameTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + "Trying to show giver name to STUDENTS without showing response first." + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showRecipientNameTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + "Trying to show recipient name to STUDENTS without showing response first." + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showResponsesTo.get(0).toString(), FieldValidator.VIEWER_TYPE_NAME) + System.lineSeparator() + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, fq.showResponsesTo.get(1).toString(), FieldValidator.VIEWER_TYPE_NAME);
    assertEquals(errorMessage, StringHelper.toString(fq.getInvalidityInfo()));
    fq.recipientType = FeedbackParticipantType.TEAMS;
    fq.showGiverNameTo = new ArrayList<>();
    fq.showGiverNameTo.add(FeedbackParticipantType.RECEIVER);
    fq.showRecipientNameTo = new ArrayList<>();
    fq.showRecipientNameTo.add(FeedbackParticipantType.RECEIVER);
    fq.showResponsesTo = new ArrayList<>();
    fq.showResponsesTo.add(FeedbackParticipantType.RECEIVER);
    assertTrue(fq.isValid());
}
Also used : FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) Test(org.testng.annotations.Test)

Example 5 with FeedbackQuestionAttributes

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

the class StudentFeedbackSubmitPageUiTest method testSubmitAction.

private void testSubmitAction() throws Exception {
    ______TS("create new responses");
    submitPage = loginToStudentFeedbackSubmitPage("Alice", "Open Session");
    submitPage.waitForPageToLoad();
    String responseText = "Test Self Feedback";
    submitPage.fillResponseRichTextEditor(1, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(1, 0));
    responseText = "Response to Benny.";
    submitPage.selectRecipient(2, 0, "Benny Charles");
    submitPage.fillResponseRichTextEditor(2, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 0));
    responseText = "Response to student who is going to drop out.";
    submitPage.selectRecipient(2, 1, "Drop out");
    submitPage.fillResponseRichTextEditor(2, 1, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 1));
    responseText = "Response to extra guy.";
    submitPage.selectRecipient(2, 2, "Extra guy");
    submitPage.fillResponseRichTextEditor(2, 2, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 2));
    submitPage.fillResponseTextBox(14, 0, "1");
    // Test partial response for question
    responseText = "Feedback to team 3";
    submitPage.fillResponseRichTextEditor(4, 1, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(4, 1));
    submitPage.verifyOtherOptionTextUnclickable(6, 0);
    submitPage.chooseMcqOption(6, 0, "");
    submitPage.waitForOtherOptionTextToBeClickable(6, 0);
    submitPage.fillMcqOtherOptionTextBox(6, 0, "Features");
    submitPage.chooseMcqOption(7, 0, "Algo");
    submitPage.verifyOtherOptionTextUnclickable(8, 0);
    submitPage.toggleMsqOption(8, 0, "");
    submitPage.waitForOtherOptionTextToBeClickable(8, 0);
    submitPage.fillMsqOtherOptionTextBox(8, 0, "Features");
    submitPage.toggleMsqOption(9, 0, "UI");
    submitPage.toggleMsqOption(9, 0, "Design");
    submitPage.fillResponseTextBox(18, 0, 0, "90");
    submitPage.fillResponseTextBox(18, 0, 1, "10");
    // total sums up to expected value, verify empty entries are filled with 0
    submitPage.fillResponseTextBox(19, 1, 0, "200");
    assertEquals(submitPage.getResponseTextBoxValue(19, 0, 0), "0");
    // delete an auto-filled 0, verify it's auto-filled again
    submitPage.clearResponseTextBoxValue(19, 0, 0);
    assertEquals(submitPage.getResponseTextBoxValue(19, 0, 0), "0");
    // modify a non-zero value and remove a 0
    submitPage.fillResponseTextBox(19, 1, 0, "100");
    submitPage.clearResponseTextBoxValue(19, 0, 0);
    // verify no longer auto-filled with 0
    assertTrue(submitPage.isTextBoxValueEmpty(19, 0, 0));
    // clear both input box for successful form submission.
    submitPage.clearResponseTextBoxValue(19, 1, 0);
    submitPage.chooseContribOption(20, 0, "Equal share");
    // Just check that some of the responses persisted.
    FeedbackQuestionAttributes fq = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 2);
    FeedbackQuestionAttributes fqPartial = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 4);
    FeedbackQuestionAttributes fqMcq = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 8);
    FeedbackQuestionAttributes fqMsq = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 10);
    FeedbackQuestionAttributes fqNumscale = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 15);
    FeedbackQuestionAttributes fqConstSum = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 19);
    FeedbackQuestionAttributes fqConstSum2 = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 20);
    FeedbackQuestionAttributes fqContrib = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 21);
    assertNull(BackDoor.getFeedbackResponse(fq.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt"));
    String aliceTeam = testData.students.get("Alice").team;
    assertNull(BackDoor.getFeedbackResponse(fqPartial.getId(), aliceTeam, "Team 3"));
    assertNull(BackDoor.getFeedbackResponse(fqMcq.getId(), aliceTeam, "Team 2"));
    assertNull(BackDoor.getFeedbackResponse(fqMsq.getId(), aliceTeam, "Team 2"));
    assertNull(BackDoor.getFeedbackResponse(fqNumscale.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqContrib.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqContrib.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt"));
    submitPage.submitWithoutConfirmationEmail();
    submitPage.verifyAndCloseSuccessfulSubmissionModal();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    assertNotNull(BackDoor.getFeedbackResponse(fq.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqPartial.getId(), aliceTeam, "Team 3"));
    assertNotNull(BackDoor.getFeedbackResponse(fqMcq.getId(), aliceTeam, "Team 2"));
    assertNotNull(BackDoor.getFeedbackResponse(fqMsq.getId(), aliceTeam, "Team 2"));
    assertNotNull(BackDoor.getFeedbackResponse(fqNumscale.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqConstSum.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqContrib.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqContrib.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt"));
    submitPage = loginToStudentFeedbackSubmitPage("Alice", "Open Session");
    submitPage.verifyHtmlMainContent("/studentFeedbackSubmitPagePartiallyFilled.html");
    ______TS("test toggle radio button");
    submitPage.chooseMcqOption(7, 1, "UI");
    submitPage.chooseMcqOption(7, 1, "Algo");
    // toggle 'Algo' radio option
    submitPage.chooseMcqOption(7, 1, "Algo");
    submitPage.submitWithoutConfirmationEmail();
    submitPage.verifyAndCloseSuccessfulSubmissionModal();
    assertNull(BackDoor.getFeedbackResponse(fqMcq.getId(), aliceTeam, "Team 3"));
    submitPage = loginToStudentFeedbackSubmitPage("Alice", "Open Session");
    submitPage.verifyHtmlMainContent("/studentFeedbackSubmitPagePartiallyFilled.html");
    ______TS("edit existing response");
    // Test editing an existing response
    // + fill up rest of responses at the same time
    String editedResponse = "Edited response to Benny.";
    submitPage.fillResponseRichTextEditor(2, 0, editedResponse);
    assertEquals(editedResponse.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 0));
    responseText = "Feedback to instructors";
    submitPage.fillResponseRichTextEditor(3, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(3, 0));
    responseText = "Feedback to team 2.";
    submitPage.fillResponseRichTextEditor(4, 1, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(4, 1));
    responseText = "Feedback to teammate.";
    submitPage.fillResponseRichTextEditor(5, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(5, 0));
    submitPage.chooseMcqOption(6, 0, "UI");
    // Changed from "Algo" to "UI"
    submitPage.chooseMcqOption(7, 0, "UI");
    submitPage.chooseMcqOption(7, 1, "UI");
    submitPage.toggleMsqOption(8, 0, "UI");
    submitPage.toggleMsqOption(8, 0, "Algo");
    submitPage.toggleMsqOption(8, 0, "Design");
    submitPage.toggleMsqOption(9, 0, "UI");
    submitPage.toggleMsqOption(9, 0, "Algo");
    submitPage.toggleMsqOption(9, 0, "Design");
    submitPage.toggleMsqOption(9, 1, "Design");
    submitPage.chooseMcqOption(10, 0, "Drop out (Team 2)");
    submitPage.toggleMsqOption(11, 0, "Alice Betsy</option></td></div>'\" (Team >'\"< 1</td></div>'\")");
    submitPage.toggleMsqOption(11, 0, "Benny Charles (Team >'\"< 1</td></div>'\")");
    submitPage.toggleMsqOption(11, 0, "Charlie Davis (Team 2)");
    submitPage.toggleMsqOption(11, 0, "Extra guy (Team 2)");
    submitPage.chooseMcqOption(12, 0, "Team 2");
    submitPage.toggleMsqOption(13, 0, "Team >'\"< 1</td></div>'\"");
    submitPage.toggleMsqOption(13, 0, "Team 3");
    submitPage.fillResponseTextBox(14, 0, "5");
    submitPage.fillResponseTextBox(15, 0, "1.5");
    submitPage.fillResponseTextBox(15, 1, "2.5");
    submitPage.chooseMcqOption(16, 0, "Teammates Test2");
    submitPage.toggleMsqOption(17, 0, "Teammates Test");
    submitPage.toggleMsqOption(17, 0, "Teammates Test3");
    submitPage.fillResponseTextBox(18, 0, 0, "70");
    submitPage.fillResponseTextBox(18, 0, 1, "30");
    submitPage.fillResponseTextBox(19, 0, 0, "90");
    submitPage.fillResponseTextBox(19, 1, 0, "110");
    submitPage.chooseContribOption(20, 1, "0%");
    // Just check the edited responses, and two new response.
    assertNull(BackDoor.getFeedbackResponse(fqPartial.getId(), aliceTeam, "Team 2"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum2.getId(), aliceTeam, "Team 2"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum2.getId(), aliceTeam, "Team 3"));
    submitPage.submitWithoutConfirmationEmail();
    // check new response
    fqPartial = BackDoor.getFeedbackQuestion("SFSubmitUiT.CS2104", "First Session", 4);
    assertNotNull(BackDoor.getFeedbackResponse(fqPartial.getId(), aliceTeam, "Team 2"));
    // check edited
    submitPage.verifyAndCloseSuccessfulSubmissionModal();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    assertEquals("<p>" + editedResponse + "</p>", BackDoor.getFeedbackResponse(fq.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt").responseMetaData.getValue());
    assertEquals("UI", BackDoor.getFeedbackResponse(fqMcq.getId(), aliceTeam, "Team 2").getResponseDetails().getAnswerString());
    FeedbackMsqResponseDetails frMsq = (FeedbackMsqResponseDetails) BackDoor.getFeedbackResponse(fqMsq.getId(), aliceTeam, "Team 2").getResponseDetails();
    assertFalse(frMsq.contains("UI"));
    assertTrue(frMsq.contains("Algo"));
    assertFalse(frMsq.contains("Design"));
    FeedbackNumericalScaleResponseDetails frNumscale = (FeedbackNumericalScaleResponseDetails) BackDoor.getFeedbackResponse(fqNumscale.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt").getResponseDetails();
    assertEquals("5", frNumscale.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt").getResponseDetails();
    assertEquals("70, 30", frConstSum.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum1 = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum2.getId(), aliceTeam, "Team 2").getResponseDetails();
    assertEquals("90", frConstSum1.getAnswerString());
    FeedbackConstantSumResponseDetails frConstSum2 = (FeedbackConstantSumResponseDetails) BackDoor.getFeedbackResponse(fqConstSum2.getId(), aliceTeam, "Team 3").getResponseDetails();
    assertEquals("110", frConstSum2.getAnswerString());
    FeedbackContributionResponseDetails frContrib = (FeedbackContributionResponseDetails) BackDoor.getFeedbackResponse(fqContrib.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.alice.b@gmail.tmt").getResponseDetails();
    assertEquals("100", frContrib.getAnswerString());
    FeedbackContributionResponseDetails frContrib1 = (FeedbackContributionResponseDetails) BackDoor.getFeedbackResponse(fqContrib.getId(), "SFSubmitUiT.alice.b@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt").getResponseDetails();
    assertEquals("0", frContrib1.getAnswerString());
    submitPage = loginToStudentFeedbackSubmitPage("Alice", "Open Session");
    submitPage.verifyHtmlMainContent("/studentFeedbackSubmitPageFullyFilled.html");
    ______TS("MSQ: min/max selectable choices test");
    int qnNumber = 22;
    // Submit response with 1 option checked
    submitPage.toggleMsqOption(qnNumber, 0, "Charlie Davis (Team 2)");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(String.format(Const.StatusMessages.FEEDBACK_RESPONSES_MSQ_MIN_CHECK, qnNumber, 2));
    // Submit response with 2 options checked
    submitPage.toggleMsqOption(qnNumber, 0, "Drop out (Team 2)");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    submitPage.waitForConfirmationModalAndClickOk();
    // Submit response with 3 options checked
    submitPage.toggleMsqOption(qnNumber, 0, "Emily (Team 3)");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    submitPage.waitForConfirmationModalAndClickOk();
    // Submit response with 4 options checked
    submitPage.toggleMsqOption(qnNumber, 0, "Extra guy (Team 2)");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(String.format(Const.StatusMessages.FEEDBACK_RESPONSES_MSQ_MAX_CHECK, qnNumber, 3));
    // Uncheck an option so that response is valid
    submitPage.toggleMsqOption(qnNumber, 0, "Extra guy (Team 2)");
    qnNumber = 23;
    // Submit response for 1st recipient with 2 options checked
    submitPage.toggleMsqOption(qnNumber, 0, "B");
    submitPage.toggleMsqOption(qnNumber, 0, "C");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(String.format(Const.StatusMessages.FEEDBACK_RESPONSES_MSQ_MIN_CHECK, qnNumber, 3));
    // Submit response for 1st recipient with 3 options checked
    submitPage.toggleMsqOption(qnNumber, 0, "E");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    submitPage.waitForConfirmationModalAndClickOk();
    // Submit response for 1st recipient with 4 options checked
    submitPage.toggleMsqOption(qnNumber, 0, "A");
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(String.format(Const.StatusMessages.FEEDBACK_RESPONSES_MSQ_MAX_CHECK, qnNumber, 3));
    ______TS("create new response for unreg student");
    submitPage.logout();
    submitPage = loginToStudentFeedbackSubmitPage(testData.students.get("DropOut"), "Open Session");
    responseText = "Test Self Feedback";
    submitPage.fillResponseRichTextEditor(1, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(1, 0));
    responseText = "Response to Benny.";
    submitPage.selectRecipient(2, 0, "Benny Charles");
    submitPage.fillResponseRichTextEditor(2, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 0));
    responseText = "Response to student who is number 1.";
    submitPage.selectRecipient(2, 1, "Alice Betsy</option></td></div>'\"");
    submitPage.fillResponseRichTextEditor(2, 1, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 1));
    responseText = "Response to extra guy.";
    submitPage.selectRecipient(2, 2, "Extra guy");
    submitPage.fillResponseRichTextEditor(2, 2, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(2, 2));
    submitPage.fillResponseTextBox(14, 0, "1");
    // Test partial response for question
    responseText = "Feedback to team 3";
    submitPage.fillResponseRichTextEditor(4, 0, responseText);
    assertEquals(responseText.trim().split(" +").length, submitPage.getResponseTextBoxLengthLabelValue(4, 0));
    submitPage.chooseMcqOption(7, 1, "Algo");
    submitPage.toggleMsqOption(9, 1, "UI");
    submitPage.toggleMsqOption(9, 1, "Design");
    submitPage.fillResponseTextBox(18, 0, 0, "90");
    submitPage.fillResponseTextBox(18, 0, 1, "10");
    submitPage.chooseContribOption(20, 0, "Equal share");
    assertNull(BackDoor.getFeedbackResponse(fq.getId(), "drop.out@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqPartial.getId(), "Team 2", "Team 3"));
    assertNull(BackDoor.getFeedbackResponse(fqMcq.getId(), "Team 2", testData.students.get("Alice").team));
    assertNull(BackDoor.getFeedbackResponse(fqMsq.getId(), "Team 2", testData.students.get("Alice").team));
    assertNull(BackDoor.getFeedbackResponse(fqNumscale.getId(), "drop.out@gmail.tmt", "drop.out@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqConstSum.getId(), "drop.out@gmail.tmt", "drop.out@gmail.tmt"));
    assertNull(BackDoor.getFeedbackResponse(fqContrib.getId(), "drop.out@gmail.tmt", "SFSubmitUiT.charlie.d@gmail.tmt"));
    submitPage.submitWithoutConfirmationEmail();
    submitPage.verifyAndCloseSuccessfulSubmissionModal();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    submitPage.verifyHtmlMainContent("/unregisteredStudentFeedbackSubmitPagePartiallyFilled.html");
    assertNotNull(BackDoor.getFeedbackResponse(fq.getId(), "drop.out@gmail.tmt", "SFSubmitUiT.benny.c@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqPartial.getId(), "Team 2", "Team 3"));
    assertNotNull(BackDoor.getFeedbackResponse(fqMcq.getId(), "Team 2", testData.students.get("Alice").team));
    assertNotNull(BackDoor.getFeedbackResponse(fqMsq.getId(), "Team 2", testData.students.get("Alice").team));
    assertNotNull(BackDoor.getFeedbackResponse(fqNumscale.getId(), "drop.out@gmail.tmt", "drop.out@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqConstSum.getId(), "drop.out@gmail.tmt", "drop.out@gmail.tmt"));
    assertNotNull(BackDoor.getFeedbackResponse(fqContrib.getId(), "drop.out@gmail.tmt", "SFSubmitUiT.charlie.d@gmail.tmt"));
}
Also used : FeedbackMsqResponseDetails(teammates.common.datatransfer.questions.FeedbackMsqResponseDetails) FeedbackNumericalScaleResponseDetails(teammates.common.datatransfer.questions.FeedbackNumericalScaleResponseDetails) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) FeedbackContributionResponseDetails(teammates.common.datatransfer.questions.FeedbackContributionResponseDetails) FeedbackConstantSumResponseDetails(teammates.common.datatransfer.questions.FeedbackConstantSumResponseDetails)

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