Search in sources :

Example 31 with InstructorAttributes

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

the class InstructorFeedbackQuestionAddActionTest method testExecuteAndPostProcessConstSumOption.

@Test
public void testExecuteAndPostProcessConstSumOption() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    ______TS("Typical case");
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.SELF.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "CONSTSUM", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Split points among the options.", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTS, "30", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSFOREACHOPTION, "100", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSFOREACHRECIPIENT, "50", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMPOINTSPEROPTION, "true", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "3", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-1", "Option 1", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-2", "Option 2", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION + "-3", "Option 3", Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMTORECIPIENTS, "false", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "1", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit" };
    InstructorFeedbackQuestionAddAction action = getAction(params);
    RedirectResult result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Distribute points (among options) " + "question:</span> Split points among the options." + "|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackQuestionAddAction(teammates.ui.controller.InstructorFeedbackQuestionAddAction) Test(org.testng.annotations.Test)

Example 32 with InstructorAttributes

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

the class InstructorFeedbackQuestionAddActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    ______TS("Not enough parameters");
    verifyAssumptionFailure();
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] params = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName() };
    verifyAssumptionFailure(params);
    ______TS("Empty questionText");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "");
    verifyAssumptionFailure(params);
    ______TS("Invalid questionNumber");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    // change questionNumber to invalid number
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "0");
    verifyAssumptionFailure(params);
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    // change questionNumber to invalid number
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "-1");
    verifyAssumptionFailure(params);
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    // change questionNumber to invalid "number"
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "ABC");
    try {
        InstructorFeedbackQuestionAddAction c = getAction(params);
        c.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (NumberFormatException e) {
        ignoreExpectedException();
    }
    ______TS("Non-existent Enumeration");
    params = createParamsForTypicalFeedbackQuestion(instructor1ofCourse1.courseId, fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, "NON_EXISTENT_ENUMERATION");
    try {
        InstructorFeedbackQuestionAddAction c = getAction(params);
        c.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (IllegalArgumentException e) {
        ignoreExpectedException();
    }
    params = createParamsForTypicalFeedbackQuestion(instructor1ofCourse1.courseId, fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, "NON_EXISTENT_ENUMERATION");
    try {
        InstructorFeedbackQuestionAddAction c = getAction(params);
        c.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (IllegalArgumentException e) {
        ignoreExpectedException();
    }
    params = createParamsForTypicalFeedbackQuestion(instructor1ofCourse1.courseId, fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "NON_EXISTENT_ENUMERATION");
    try {
        InstructorFeedbackQuestionAddAction c = getAction(params);
        c.executeAndPostProcess();
        signalFailureToDetectException();
    } catch (IllegalArgumentException e) {
        ignoreExpectedException();
    }
    ______TS("Typical case");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    // change number of feedback to give to unlimited
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max");
    InstructorFeedbackQuestionAddAction action = getAction(params);
    RedirectResult result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "question|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Custom number of students to give feedback to");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "question|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Custom number of teams to give feedback to");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, "TEAMS");
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "question|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Remnant custom number of entities when recipient is changed to non-student and non-team");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, "INSTRUCTORS");
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "question|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Question text requires sanitization");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "attempted html injection '\"/>");
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "attempted html injection &#39;&quot;&#x2f;&gt;|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Failure: Empty or null participant lists");
    params = createParamsForTypicalFeedbackQuestion(fs.getCourseId(), fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, "");
    // Purposely not using modifyParamVale because we're removing showRecipientTo
    params[22] = Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE;
    params[23] = "edit";
    params = Arrays.copyOf(params, 24);
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "question|||/page/instructorFeedbackQuestionAdd";
    ______TS("Failure: Invalid Parameter");
    params = createParamsForTypicalFeedbackQuestion(instructor1ofCourse1.courseId, fs.getFeedbackSessionName());
    modifyParamValue(params, Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, "NONE");
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, true), result.getDestinationWithParams());
    assertEquals("NONE is not a valid feedback giver.", result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + String.format(FieldValidator.PARTICIPANT_TYPE_ERROR_MESSAGE, "NONE", FieldValidator.GIVER_TYPE_NAME) + "|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Masquerade mode");
    String adminUserId = "admin.user";
    gaeSimulation.loginAsAdmin(adminUserId);
    params = createParamsForTypicalFeedbackQuestion(instructor1ofCourse1.courseId, fs.getFeedbackSessionName());
    params = addUserIdToParams(instructor1ofCourse1.googleId, params);
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor(M)|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Essay question:</span> " + "question|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, action.getLogMessage(), adminUserId);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackQuestionAddAction(teammates.ui.controller.InstructorFeedbackQuestionAddAction) Test(org.testng.annotations.Test)

Example 33 with InstructorAttributes

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

the class InstructorFeedbackQuestionAddActionTest method testExecuteAndPostProcessNumScale.

@Test
public void testExecuteAndPostProcessNumScale() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    ______TS("Typical case");
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "NUMSCALE", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Rate the class?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN, "1", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX, "5", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP, "0.5", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit" };
    InstructorFeedbackQuestionAddAction action = getAction(params);
    RedirectResult result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Numerical-scale question:</span> " + "Rate the class?|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackQuestionAddAction(teammates.ui.controller.InstructorFeedbackQuestionAddAction) Test(org.testng.annotations.Test)

Example 34 with InstructorAttributes

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

the class InstructorFeedbackQuestionAddActionTest method testExecuteAndPostProcessMsq.

@Test
public void testExecuteAndPostProcessMsq() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    ______TS("Typical case");
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MSQ", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "What do you like best about the class?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "5", Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-0", "The Content", // empty option
    Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-2", // empty option
    "", // empty option with extra whitespace
    Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-3", "          ", Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-4", "The Atmosphere", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_MSQ_GENERATED_OPTIONS, FeedbackParticipantType.NONE.toString() };
    InstructorFeedbackQuestionAddAction action = getAction(params);
    RedirectResult result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd" + "|||instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> " + "for Course <span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Multiple-choice (multiple answers) " + "question:</span> What do you like best about the class?" + "|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Generated options");
    params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MSQ", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Who do you like in the class?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "2", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_MSQ_GENERATED_OPTIONS, FeedbackParticipantType.STUDENTS.toString() };
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Multiple-choice (multiple answers) question:</span> " + "Who do you like in the class?|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Enable other option");
    params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "3", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MSQ", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Choose all the food you like", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "3", Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-0", "Pizza", Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-1", "Pasta", Const.ParamsNames.FEEDBACK_QUESTION_MSQCHOICE + "-2", "Chicken rice", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_MSQ_GENERATED_OPTIONS, FeedbackParticipantType.NONE.toString(), Const.ParamsNames.FEEDBACK_QUESTION_MSQOTHEROPTIONFLAG, "on" };
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Multiple-choice (multiple answers) question:</span> " + "Choose all the food you like|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackQuestionAddAction(teammates.ui.controller.InstructorFeedbackQuestionAddAction) Test(org.testng.annotations.Test)

Example 35 with InstructorAttributes

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

the class InstructorFeedbackQuestionAddActionTest method testExecuteAndPostProcessMcq.

@Test
public void testExecuteAndPostProcessMcq() {
    InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
    ______TS("Typical case");
    FeedbackSessionAttributes fs = typicalBundle.feedbackSessions.get("session1InCourse1");
    String[] params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "1", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MCQ", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "What do you like best about the class?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "5", Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-0", "The Content", // empty option
    Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-2", // empty option
    "", // empty option with extra whitespace
    Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-3", "          ", Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-4", "The Atmosphere", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_MCQ_GENERATED_OPTIONS, FeedbackParticipantType.NONE.toString() };
    InstructorFeedbackQuestionAddAction action = getAction(params);
    RedirectResult result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    String expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Multiple-choice (single answer) " + "question:</span> What do you like best about the class?" + "|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Generated options");
    params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "2", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MCQ", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "Who do you like best in the class?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", // this field defaults to 2
    Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, // this field defaults to 2
    "2", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_MCQ_GENERATED_OPTIONS, FeedbackParticipantType.STUDENTS.toString() };
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Multiple-choice (single answer) question:</span> " + "Who do you like best in the class?|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
    ______TS("Enable other option");
    params = new String[] { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, FeedbackParticipantType.STUDENTS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, "3", Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "MCQ", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, "What can be improved for this class?", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFCHOICECREATED, "4", Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-0", "The content", Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-1", "Teaching style", Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-2", "Tutorial questions", Const.ParamsNames.FEEDBACK_QUESTION_MCQCHOICE + "-3", "Assignments", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "custom", Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES, "2", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.RECEIVER.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_MCQ_GENERATED_OPTIONS, FeedbackParticipantType.NONE.toString(), Const.ParamsNames.FEEDBACK_QUESTION_MCQOTHEROPTIONFLAG, "on" };
    action = getAction(params);
    result = getRedirectResult(action);
    assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, instructor1ofCourse1.courseId, "First+feedback+session", instructor1ofCourse1.googleId, false), result.getDestinationWithParams());
    assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_ADDED, result.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||instructorFeedbackQuestionAdd|||" + "instructorFeedbackQuestionAdd|||true|||" + "Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||" + "Created Feedback Question for Feedback Session:<span class=\"bold\">" + "(First feedback session)</span> for Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span>" + " created.<br><span class=\"bold\">Multiple-choice (single answer) question:</span> " + "What can be improved for this class?|||/page/instructorFeedbackQuestionAdd";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, action.getLogMessage());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorFeedbackQuestionAddAction(teammates.ui.controller.InstructorFeedbackQuestionAddAction) Test(org.testng.annotations.Test)

Aggregations

InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)325 Test (org.testng.annotations.Test)127 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)84 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)77 ArrayList (java.util.ArrayList)58 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)46 RedirectResult (teammates.ui.controller.RedirectResult)46 StatusMessage (teammates.common.util.StatusMessage)34 ShowPageResult (teammates.ui.controller.ShowPageResult)31 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)29 HashMap (java.util.HashMap)25 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)24 InvalidParametersException (teammates.common.exception.InvalidParametersException)24 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)20 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)18 EmailWrapper (teammates.common.util.EmailWrapper)15 InstructorPrivileges (teammates.common.datatransfer.InstructorPrivileges)14 DataBundle (teammates.common.datatransfer.DataBundle)13