@Override
  public void testInputValidation() {

    ______TS("empty question text");

    feedbackEditPage.clickAddQuestionButton();
    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_QUESTION_TEXTINVALID);

    ______TS("empty weight test");

    feedbackEditPage.fillNewQuestionBox("empty weight test");
    feedbackEditPage.fillNewQuestionDescription("more details");
    feedbackEditPage.clickAssignWeightsCheckbox(-1);
    feedbackEditPage.fillRubricWeightBox("", -1, 3);
    feedbackEditPage.clickAddQuestionButton();

    feedbackEditPage.verifyStatus(Const.FeedbackQuestion.RUBRIC_ERROR_INVALID_WEIGHT);
  }
  @Override
  public void testAddQuestionAction() throws Exception {
    ______TS("NUMSCALE: add question action success");

    assertNull(BackDoor.getFeedbackQuestion(courseId, feedbackSessionName, 1));
    feedbackEditPage.enableOtherFeedbackPathOptionsForNewQuestion();
    feedbackEditPage.selectRecipientsToBeStudents();
    feedbackEditPage.clickAddQuestionButton();
    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_QUESTION_ADDED);
    assertNotNull(BackDoor.getFeedbackQuestion(courseId, feedbackSessionName, 1));
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackNumScaleQuestionAddSuccess.html");
  }
  @Override
  public void testAddQuestionAction() throws Exception {
    ______TS("RUBRIC: add question action success");

    feedbackEditPage.clickNewQuestionButton();
    feedbackEditPage.selectNewQuestionType("RUBRIC");
    feedbackEditPage.fillNewQuestionBox("RUBRIC qn");
    feedbackEditPage.fillNewQuestionDescription("more details");
    assertNull(BackDoor.getFeedbackQuestion(courseId, feedbackSessionName, 1));
    feedbackEditPage.clickAddQuestionButton();
    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_QUESTION_ADDED);
    assertNotNull(BackDoor.getFeedbackQuestion(courseId, feedbackSessionName, 1));
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackRubricQuestionAddSuccess.html");
  }
  @Override
  public void testDeleteQuestionAction() {
    ______TS("NUMSCALE: qn delete then cancel");

    feedbackEditPage.clickDeleteQuestionLink(1);
    feedbackEditPage.waitForConfirmationModalAndClickCancel();
    assertNotNull(BackDoor.getFeedbackQuestion(courseId, feedbackSessionName, 1));

    ______TS("NUMSCALE: qn delete then accept");

    feedbackEditPage.clickDeleteQuestionLink(1);
    feedbackEditPage.waitForConfirmationModalAndClickOk();
    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_QUESTION_DELETED);
    assertNull(BackDoor.getFeedbackQuestion(courseId, feedbackSessionName, 1));
  }
  @Override
  public void testEditQuestionAction() throws Exception {
    ______TS("NUMSCALE: edit question success");

    feedbackEditPage.clickEditQuestionButton(1);
    feedbackEditPage.fillEditQuestionBox("edited numscale qn text", 1);
    feedbackEditPage.fillEditQuestionDescription("more details", 1);
    feedbackEditPage.fillMinNumScaleBox(3, 1);
    feedbackEditPage.fillMaxNumScaleBox(4, 1);
    feedbackEditPage.fillStepNumScaleBox(0.002, 1);
    assertEquals(
        "[Based on the above settings, acceptable responses are: 3, 3.002, 3.004, ..., 3.996, 3.998, 4]",
        feedbackEditPage.getNumScalePossibleValuesString(1));
    feedbackEditPage.clickSaveExistingQuestionButton(1);
    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_QUESTION_EDITED);

    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackNumScaleQuestionEditSuccess.html");
  }
  private void testInputJsValidationForRubricQuestion() {
    // this tests whether the JS validation disallows empty rubric options

    ______TS("JS validation test");

    // add a new question
    feedbackEditPage.clickNewQuestionButton();
    feedbackEditPage.selectNewQuestionType("RUBRIC");

    // start editing it
    feedbackEditPage.fillNewQuestionBox("RUBRIC qn JS validation test");
    feedbackEditPage.fillNewQuestionDescription("more details");
    feedbackEditPage.clickAddQuestionButton();

    feedbackEditPage.clickEditQuestionButton(1);

    // try to remove everything
    feedbackEditPage.clickRemoveRubricRowLinkAndConfirm(1, 1);
    feedbackEditPage.clickRemoveRubricRowLinkAndConfirm(1, 0);
    feedbackEditPage.clickRemoveRubricColLinkAndConfirm(1, 3);
    feedbackEditPage.clickRemoveRubricColLinkAndConfirm(1, 2);
    feedbackEditPage.clickRemoveRubricColLinkAndConfirm(1, 1);
    feedbackEditPage.clickRemoveRubricColLinkAndConfirm(1, 0);

    // TODO check if the rubric column and link is indeed empty

    // add something so that we know that the elements are still there
    // and so that we don't get empty sub question error
    feedbackEditPage.fillRubricSubQuestionBox("New sub-question text", 1, 0);
    feedbackEditPage.fillRubricDescriptionBox("New(0) description", 1, 0, 0);

    feedbackEditPage.clickSaveExistingQuestionButton(1);

    feedbackEditPage.verifyStatus(
        "Too little choices for Rubric question. Minimum number of options is: 2");
  }
  @Override
  public void testInputValidation() {

    ______TS("empty options");

    feedbackEditPage.fillNewQuestionBox("NumScale qn");
    feedbackEditPage.fillNewQuestionDescription("more details");
    feedbackEditPage.fillMinNumScaleBox("", -1);
    feedbackEditPage.fillStepNumScaleBox("", -1);
    feedbackEditPage.fillMaxNumScaleBox("", -1);

    assertEquals(
        "[Please enter valid numbers for all the options.]",
        feedbackEditPage.getNumScalePossibleValuesString(-1));

    feedbackEditPage.clickAddQuestionButton();

    feedbackEditPage.verifyStatus("Please enter valid options. The min/max/step cannot be empty.");

    ______TS("invalid options");

    feedbackEditPage.fillNewQuestionBox("NumScale qn");
    feedbackEditPage.fillNewQuestionDescription("more details");
    feedbackEditPage.fillMinNumScaleBox("1", -1);
    feedbackEditPage.fillStepNumScaleBox("0.3", -1);
    feedbackEditPage.fillMaxNumScaleBox("5", -1);

    assertEquals(
        "[The interval 1 - 5 is not divisible by the specified increment.]",
        feedbackEditPage.getNumScalePossibleValuesString(-1));

    feedbackEditPage.clickAddQuestionButton();

    feedbackEditPage.verifyStatus(
        "Please enter valid options. "
            + "The interval is not divisible by the specified increment.");

    ______TS("possible floating point error");

    feedbackEditPage.fillNewQuestionBox("NumScale qn");
    feedbackEditPage.fillNewQuestionDescription("more details");
    feedbackEditPage.fillMinNumScaleBox("1", -1);
    feedbackEditPage.fillStepNumScaleBox("0.001", -1);
    feedbackEditPage.fillMaxNumScaleBox("5555", -1);

    assertEquals(
        "[Based on the above settings, acceptable responses are: 1, 1.001, 1.002, ..., "
            + "5554.998, 5554.999, 5555]",
        feedbackEditPage.getNumScalePossibleValuesString(-1));

    ______TS("more than three dp step rounding test");

    feedbackEditPage.fillMaxNumScaleBox("1002", -1);
    feedbackEditPage.fillStepNumScaleBox("1.00123456789", -1);

    assertEquals(
        "[Based on the above settings, acceptable responses are: 1, 2.001, 3.002, ..., "
            + "999.998, 1000.999, 1002]",
        feedbackEditPage.getNumScalePossibleValuesString(-1));

    ______TS("NUMSCALE: min >= max test");
    // Tests javascript that automatically makes max = min+1 when max is <= min.
    feedbackEditPage.fillMinNumScaleBox(1, -1);
    feedbackEditPage.fillStepNumScaleBox(1, -1);
    feedbackEditPage.fillMaxNumScaleBox(5, -1);
    assertEquals(
        "[Based on the above settings, acceptable responses are: 1, 2, 3, 4, 5]",
        feedbackEditPage.getNumScalePossibleValuesString(-1));

    fillNumScaleBoxWithRecheck(true, 6, -1, "7");
    fillNumScaleBoxWithRecheck(false, 6, -1, "7");

    // Reset values
    feedbackEditPage.fillMinNumScaleBox(1, -1);
    feedbackEditPage.fillMaxNumScaleBox(5, -1);
  }
  @Override
  public void testEditQuestionAction() throws Exception {
    ______TS("RUBRIC: edit question success");

    // Click edit button
    feedbackEditPage.clickEditQuestionButton(1);

    // Check that fields are editable
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackRubricQuestionEdit.html");

    feedbackEditPage.fillEditQuestionBox("edited RUBRIC qn text", 1);
    feedbackEditPage.fillEditQuestionDescription("more details", 1);
    feedbackEditPage.clickSaveExistingQuestionButton(1);
    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_QUESTION_EDITED);

    // Check question text is updated
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackRubricQuestionEditSuccess.html");

    ______TS("RUBRIC: edit sub-questions success");
    feedbackEditPage.clickEditQuestionButton(1);

    // Edit sub-question for row 1
    feedbackEditPage.fillRubricSubQuestionBox("New(0) sub-question text", 1, 0);

    // Add new sub-question
    feedbackEditPage.clickAddRubricRowLink(1);
    feedbackEditPage.fillRubricSubQuestionBox("New(1) sub-question text", 1, 2);

    // Remove existing sub-questions
    feedbackEditPage.clickRemoveRubricRowLinkAndConfirm(1, 0);
    feedbackEditPage.clickRemoveRubricRowLinkAndConfirm(1, 1);

    // Add new sub-question
    feedbackEditPage.clickAddRubricRowLink(1);
    feedbackEditPage.fillRubricSubQuestionBox("New(2) sub-question text", 1, 3);

    // Remove new sub-question
    feedbackEditPage.clickRemoveRubricRowLinkAndConfirm(1, 2);

    // Should end up with 1 question

    feedbackEditPage.clickSaveExistingQuestionButton(1);
    feedbackEditPage.verifyHtmlMainContent(
        "/instructorFeedbackRubricQuestionEditSubQuestionSuccess.html");

    ______TS("RUBRIC: edit choices success");
    feedbackEditPage.clickEditQuestionButton(1);

    // Edit choice for col 1
    feedbackEditPage.fillRubricChoiceBox("New(0) choice", 1, 0);

    // Add new choice
    feedbackEditPage.clickAddRubricColLink(1);
    feedbackEditPage.fillRubricChoiceBox("New(1) choice", 1, 4);

    // Remove existing choice
    feedbackEditPage.clickRemoveRubricColLinkAndConfirm(1, 0);

    // Add new choice
    feedbackEditPage.clickAddRubricColLink(1);
    feedbackEditPage.fillRubricChoiceBox("New(2) choice", 1, 5);

    // Remove new choice
    feedbackEditPage.clickRemoveRubricColLinkAndConfirm(1, 4);

    // Should end up with 4 choices, including (1) and (2)

    feedbackEditPage.clickSaveExistingQuestionButton(1);
    feedbackEditPage.verifyHtmlMainContent(
        "/instructorFeedbackRubricQuestionEditChoiceSuccess.html");

    ______TS("RUBRIC: edit weight success");
    feedbackEditPage.clickEditQuestionButton(1);

    // Edit the weight of the first choice
    feedbackEditPage.clickAssignWeightsCheckbox(1);
    feedbackEditPage.fillRubricWeightBox("2.25", 1, 0);

    feedbackEditPage.clickSaveExistingQuestionButton(1);
    feedbackEditPage.verifyHtmlMainContent(
        "/instructorFeedbackRubricQuestionEditWeightSuccess.html");

    ______TS("RUBRIC: edit descriptions success");
    feedbackEditPage.clickEditQuestionButton(1);

    // Edit description for 0-0
    feedbackEditPage.fillRubricDescriptionBox("New(0) description", 1, 0, 0);

    // Edit description for a new row, to test if the js generated html works.
    feedbackEditPage.clickAddRubricRowLink(1);
    feedbackEditPage.fillRubricSubQuestionBox("New sub-question text", 1, 1);

    feedbackEditPage.fillRubricDescriptionBox("New(1) description", 1, 1, 0);

    // Should end up with 2 rubric descriptions, (0) and (1)

    feedbackEditPage.clickSaveExistingQuestionButton(1);

    feedbackEditPage.verifyHtmlMainContent(
        "/instructorFeedbackRubricQuestionEditDescriptionSuccess.html");
  }
  @Test
  public void allTests() throws Exception {
    feedbackEditPage = getFeedbackEditPage();

    ______TS("Submit empty course list");
    feedbackEditPage.clickFsCopyButton();
    feedbackEditPage.getFsCopyToModal().waitForModalToLoad();

    // Full HTML verification already done in InstructorFeedbackEditPageUiTest
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackEditCopyPage.html");

    feedbackEditPage.getFsCopyToModal().clickSubmitButton();
    feedbackEditPage.getFsCopyToModal().waitForFormSubmissionErrorMessagePresence();
    assertTrue(feedbackEditPage.getFsCopyToModal().isFormSubmissionStatusMessageVisible());
    feedbackEditPage
        .getFsCopyToModal()
        .verifyStatusMessage(Const.StatusMessages.FEEDBACK_SESSION_COPY_NONESELECTED);

    feedbackEditPage.getFsCopyToModal().clickCloseButton();

    ______TS("Copying fails due to fs with same name in course selected");
    feedbackEditPage.clickFsCopyButton();
    feedbackEditPage.getFsCopyToModal().waitForModalToLoad();
    feedbackEditPage.getFsCopyToModal().fillFormWithAllCoursesSelected(feedbackSessionName);

    feedbackEditPage.getFsCopyToModal().clickSubmitButton();
    feedbackEditPage.getFsCopyToModal().waitForFormSubmissionErrorMessagePresence();
    assertTrue(feedbackEditPage.getFsCopyToModal().isFormSubmissionStatusMessageVisible());

    feedbackEditPage
        .getFsCopyToModal()
        .verifyStatusMessage(
            String.format(
                Const.StatusMessages.FEEDBACK_SESSION_COPY_ALREADYEXISTS,
                feedbackSessionName,
                testData.courses.get("course").getId()));

    // Full HTML verification already done in InstructorFeedbackEditPageUiTest
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackEditCopyFail.html");

    feedbackEditPage.getFsCopyToModal().clickCloseButton();

    ______TS("Copying fails due to fs with invalid name");
    feedbackEditPage.clickFsCopyButton();
    feedbackEditPage.getFsCopyToModal().waitForModalToLoad();
    feedbackEditPage
        .getFsCopyToModal()
        .fillFormWithAllCoursesSelected("Invalid name | for feedback session");

    feedbackEditPage.getFsCopyToModal().clickSubmitButton();

    feedbackEditPage.getFsCopyToModal().waitForFormSubmissionErrorMessagePresence();
    assertTrue(feedbackEditPage.getFsCopyToModal().isFormSubmissionStatusMessageVisible());
    feedbackEditPage
        .getFsCopyToModal()
        .verifyStatusMessage(
            "\"Invalid name | for feedback session\" is not acceptable to TEAMMATES as "
                + "feedback session name because it contains invalid characters. "
                + "All feedback session name must start with an alphanumeric character, "
                + "and cannot contain any vertical bar (|) or percent sign (%).");

    feedbackEditPage.getFsCopyToModal().clickCloseButton();

    ______TS("Successful case");
    feedbackEditPage.clickFsCopyButton();
    feedbackEditPage.getFsCopyToModal().waitForModalToLoad();
    feedbackEditPage.getFsCopyToModal().fillFormWithAllCoursesSelected("New name!");

    feedbackEditPage.getFsCopyToModal().clickSubmitButton();
    feedbackEditPage.waitForPageToLoad();

    feedbackEditPage.verifyStatus(Const.StatusMessages.FEEDBACK_SESSION_COPIED);
    feedbackEditPage.waitForElementPresence(By.id("table-sessions"));

    // Full HTML verification already done in InstructorFeedbackEditPageUiTest
    feedbackEditPage.verifyHtmlMainContent("/instructorFeedbackEditCopySuccess.html");
  }