use of teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails in project teammates by TEAMMATES.
the class InstructorFeedbackQuestionEditActionTest method testExecuteAndPostProcessNumScale.
@Test
public void testExecuteAndPostProcessNumScale() {
DataBundle dataBundle = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
removeAndRestoreDataBundle(dataBundle);
InstructorAttributes instructor1ofCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1ofCourse1.googleId);
FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("numscaleSession");
FeedbackQuestionAttributes fq = FeedbackQuestionsLogic.inst().getFeedbackQuestion(fs.getFeedbackSessionName(), fs.getCourseId(), 1);
FeedbackNumericalScaleQuestionDetails numscaleDetails = (FeedbackNumericalScaleQuestionDetails) fq.getQuestionDetails();
FeedbackResponsesDb frDb = new FeedbackResponsesDb();
______TS("Edit text");
// There are already responses for this question
assertFalse(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
String[] editTextParams = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.giverType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, fq.recipientType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "NUMSCALE", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, numscaleDetails.getQuestionText() + " (edited)", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN, Integer.toString(numscaleDetails.getMinScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX, Integer.toString(numscaleDetails.getMaxScale()), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP, StringHelper.toDecimalFormatString(numscaleDetails.getStep()), Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
InstructorFeedbackQuestionEditAction a = getAction(editTextParams);
RedirectResult r = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, "FSQTT.idOfTypicalCourse1", "NUMSCALE+Session", "FSQTT.idOfInstructor1OfCourse1", false), r.getDestinationWithParams());
assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, r.getStatusMessage());
assertFalse(r.isError);
// All existing response should remain
assertFalse(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
______TS("Edit scales");
String[] editScalesParams = { Const.ParamsNames.COURSE_ID, fs.getCourseId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fs.getFeedbackSessionName(), Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE, fq.giverType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE, fq.recipientType.toString(), Const.ParamsNames.FEEDBACK_QUESTION_NUMBER, Integer.toString(fq.questionNumber), Const.ParamsNames.FEEDBACK_QUESTION_TYPE, "NUMSCALE", Const.ParamsNames.FEEDBACK_QUESTION_TEXT, numscaleDetails.getQuestionText() + " (edited)", Const.ParamsNames.FEEDBACK_QUESTION_DESCRIPTION, "more details", Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MIN, Integer.toString(1), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_MAX, Integer.toString(10), Const.ParamsNames.FEEDBACK_QUESTION_NUMSCALE_STEP, StringHelper.toDecimalFormatString(1.0), Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE, "max", Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO, FeedbackParticipantType.INSTRUCTORS.toString(), Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE, "edit", Const.ParamsNames.FEEDBACK_QUESTION_ID, fq.getId() };
a = getAction(editScalesParams);
r = getRedirectResult(a);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_FEEDBACK_EDIT_PAGE, "FSQTT.idOfTypicalCourse1", "NUMSCALE+Session", "FSQTT.idOfInstructor1OfCourse1", false), r.getDestinationWithParams());
assertEquals(Const.StatusMessages.FEEDBACK_QUESTION_EDITED, r.getStatusMessage());
assertFalse(r.isError);
// All existing response should be deleted as the scales are edited
assertTrue(frDb.getFeedbackResponsesForQuestion(fq.getId()).isEmpty());
}
use of teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails in project teammates by TEAMMATES.
the class InstructorFeedbackSubmissionEditSaveActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
prepareTestData();
InstructorAttributes instructor1InCourse1 = dataBundle.instructors.get("instructor1InCourse1");
gaeSimulation.loginAsInstructor(instructor1InCourse1.googleId);
______TS("Unsuccessful case: test empty feedback session name parameter");
String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, dataBundle.feedbackResponses.get("response1ForQ1S1C1").courseId };
InstructorFeedbackSubmissionEditSaveAction a;
RedirectResult r;
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("Successful case: edit existing answer");
FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
FeedbackQuestionAttributes fq = fqDb.getFeedbackQuestion("First Session", "idOfCourse1", 1);
assertNotNull("Feedback question not found in database", fq);
FeedbackResponsesDb frDb = new FeedbackResponsesDb();
FeedbackResponseAttributes 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);
instructor1InCourse1 = dataBundle.instructors.get("instructor1InCourse1");
gaeSimulation.loginAsInstructor(instructor1InCourse1.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", "Edited" + fr.getResponseDetails().getAnswerString() };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
// submission confirmation email not sent if parameter does not exist
verifyNoEmailsSent(a);
______TS("Successful case: 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", "", 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.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNull(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(instructor1InCourse1.email, email.getRecipient());
// delete respondent task scheduled
verifySpecifiedTasksAdded(a, Const.TaskQueue.FEEDBACK_SESSION_UPDATE_RESPONDENT_QUEUE_NAME, 1);
______TS("Successful case: 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", "", 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.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
// submission confirmation email not sent if parameter is not "on"
verifyNoEmailsSent(a);
______TS("Successful case: 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() };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
// append respondent task scheduled
verifySpecifiedTasksAdded(a, Const.TaskQueue.FEEDBACK_SESSION_UPDATE_RESPONDENT_QUEUE_NAME, 1);
______TS("Successful case: edit response, did not specify recipient");
fq = fqDb.getFeedbackQuestion("First Session", "idOfCourse1", 2);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForQ2S1C1");
// 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", "student1InCourse1@gmail.tmt", 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);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: 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", "student1InCourse1@gmail.tmt", Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-2", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-2-0", fr.getResponseDetails().getAnswerString() };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: private session");
fq = fqDb.getFeedbackQuestion("Private Session", "idOfCourse1", 1);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForPrivateSession");
// 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 + "-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() };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Unsuccessful case: modified recipient 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_email", Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0", fr.getResponseDetails().getAnswerString(), Const.ParamsNames.SEND_SUBMISSION_EMAIL, "on" };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertTrue(r.isError);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "instructor1InCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, "invalid_recipient_email"));
// submission confirmation email not sent if the action is an error, even with submission parameter "on"
verifyNoEmailsSent(a);
______TS("Successful case: mcq: typical case");
DataBundle dataBundle = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
removeAndRestoreDataBundle(dataBundle);
fq = fqDb.getFeedbackQuestion("MCQ Session", "FSQTT.idOfTypicalCourse1", 2);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForQ2S1C1");
// necessary to get the correct responseId
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
instructor1InCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1InCourse1.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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: 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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: msq: typical case");
fq = fqDb.getFeedbackQuestion("MSQ Session", "FSQTT.idOfTypicalCourse1", 2);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForQ2S2C1");
// necessary to get the correct responseId
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
instructor1InCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1InCourse1.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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful csae: 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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: numerical scale: typical case");
fq = fqDb.getFeedbackQuestion("NUMSCALE Session", "FSQTT.idOfTypicalCourse1", 2);
assertNotNull("Feedback question not found in database", fq);
FeedbackNumericalScaleQuestionDetails fqd = (FeedbackNumericalScaleQuestionDetails) fq.getQuestionDetails();
fr = dataBundle.feedbackResponses.get("response1ForQ2S3C1");
// necessary to get the correct responseId
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
instructor1InCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1InCourse1.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", "3.5", 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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: numerical scale: 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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), 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", 2);
assertNotNull("Feedback question not found in database", fq);
fr = dataBundle.feedbackResponses.get("response1ForQ2S4C1");
// 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("response2ForQ2S4C1");
// necessary to get the correct responseId
fr2 = frDb.getFeedbackResponse(fq.getId(), fr2.giver, fr2.recipient);
assertNotNull("Feedback response not found in database", fr2);
instructor1InCourse1 = dataBundle.instructors.get("instructor1OfCourse1");
gaeSimulation.loginAsInstructor(instructor1InCourse1.googleId);
submissionParams = new String[] { Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-1", "2", 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", // Const sum question needs response to each recipient to sum up properly.
Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-1-1", fr2.getId(), Const.ParamsNames.FEEDBACK_SESSION_NAME, fr2.feedbackSessionName, Const.ParamsNames.COURSE_ID, fr2.courseId, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-1", fr2.feedbackQuestionId, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-1-1", fr2.recipient, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-1", fr2.feedbackQuestionType.toString(), Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-1", "50" };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertFalse(r.isError);
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr2.giver, fr2.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.INSTRUCTOR_HOME_PAGE, r.isError, "FSQTT.idOfInstructor1OfCourse1"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______TS("Successful case: contrib qn: typical case");
// No tests since contrib qn can only be answered by students to own team members including self.
}
use of teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails 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();
}
use of teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails in project teammates by TEAMMATES.
the class FeedbackResponseDetailsTest method testCreateResponseDetails.
@Test
public void testCreateResponseDetails() {
______TS("TEXT Response");
FeedbackTextQuestionDetails textQuestionDetails = new FeedbackTextQuestionDetails();
HashMap<String, String[]> requestParameters = new HashMap<>();
requestParameters.put("questiontype-1", new String[] { "TEXT" });
requestParameters.put("responsetext-1-0", new String[] { "text answer" });
FeedbackResponseDetails responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "text answer" }, FeedbackQuestionType.TEXT, textQuestionDetails, requestParameters, 1, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.TEXT);
assertTrue(responseDetails instanceof FeedbackTextResponseDetails);
assertEquals("text answer", responseDetails.getAnswerString());
requestParameters.clear();
______TS("MCQ Response: other disabled");
FeedbackMcqQuestionDetails mcqQuestionDetails = new FeedbackMcqQuestionDetails();
requestParameters.put("questiontype-2", new String[] { "MCQ" });
requestParameters.put("responsetext-2-0", new String[] { "mcq option" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "mcq option" }, FeedbackQuestionType.MCQ, mcqQuestionDetails, requestParameters, 2, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.MCQ);
assertTrue(responseDetails instanceof FeedbackMcqResponseDetails);
assertEquals("mcq option", responseDetails.getAnswerString());
requestParameters.clear();
______TS("MCQ Response: other enabled, other option not selected");
FeedbackMcqQuestionDetails mcqQuestionDetailsWithOtherOptionOtherNotSelected = new FeedbackMcqQuestionDetails();
requestParameters.put("questiontype-3", new String[] { "MCQ" });
requestParameters.put("responsetext-3-0", new String[] { "an answer" });
requestParameters.put("mcqIsOtherOptionAnswer-3-0", new String[] { "0" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "an answer" }, FeedbackQuestionType.MCQ, mcqQuestionDetailsWithOtherOptionOtherNotSelected, requestParameters, 3, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.MCQ);
assertTrue(responseDetails instanceof FeedbackMcqResponseDetails);
assertEquals("an answer", responseDetails.getAnswerString());
assertFalse(((FeedbackMcqResponseDetails) responseDetails).isOtherOptionAnswer());
requestParameters.clear();
______TS("MCQ Response: other enabled, other option selected");
FeedbackMcqQuestionDetails mcqQuestionDetailsWithOtherOptionOtherSelected = new FeedbackMcqQuestionDetails();
requestParameters.put("questiontype-4", new String[] { "MCQ" });
requestParameters.put("responsetext-4-0", new String[] { "my answer" });
requestParameters.put("mcqIsOtherOptionAnswer-4-0", new String[] { "1" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "my answer" }, FeedbackQuestionType.MCQ, mcqQuestionDetailsWithOtherOptionOtherSelected, requestParameters, 4, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.MCQ);
assertTrue(responseDetails instanceof FeedbackMcqResponseDetails);
assertEquals("my answer", responseDetails.getAnswerString());
assertTrue(((FeedbackMcqResponseDetails) responseDetails).isOtherOptionAnswer());
requestParameters.clear();
______TS("MSQ Response: other disabled");
FeedbackMsqQuestionDetails msqQuestionDetails = new FeedbackMsqQuestionDetails();
requestParameters.put("questiontype-5", new String[] { "MSQ" });
requestParameters.put("responsetext-5-0", new String[] { "msq option 1", "msq option 2", "msq option 3" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "msq option 1", "msq option 2", "msq option 3" }, FeedbackQuestionType.MSQ, msqQuestionDetails, requestParameters, 5, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.MSQ);
assertTrue(responseDetails instanceof FeedbackMsqResponseDetails);
assertEquals("msq option 1, msq option 2, msq option 3", responseDetails.getAnswerString());
requestParameters.clear();
______TS("MSQ Response: other disabled, other option not selected");
msqQuestionDetails = new FeedbackMsqQuestionDetails();
requestParameters.put("questiontype-6", new String[] { "MSQ" });
requestParameters.put("responsetext-6-0", new String[] { "msq option 1", "msq option 2", "msq option 3" });
requestParameters.put("msqIsOtherOptionAnswer-6-0", new String[] { "0" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "msq option 1", "msq option 2", "msq option 3" }, FeedbackQuestionType.MSQ, msqQuestionDetails, requestParameters, 6, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.MSQ);
assertTrue(responseDetails instanceof FeedbackMsqResponseDetails);
assertEquals("msq option 1, msq option 2, msq option 3", responseDetails.getAnswerString());
assertFalse(((FeedbackMsqResponseDetails) responseDetails).isOtherOptionAnswer());
requestParameters.clear();
______TS("MSQ Response: other disabled, other option selected");
msqQuestionDetails = new FeedbackMsqQuestionDetails();
requestParameters.put("questiontype-7", new String[] { "MSQ" });
requestParameters.put("responsetext-7-0", new String[] { "msq option 1", "msq option 2", "msq option 3", "other answer" });
requestParameters.put("msqIsOtherOptionAnswer-7-0", new String[] { "1" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "msq option 1", "msq option 2", "msq option 3", "other answer" }, FeedbackQuestionType.MSQ, msqQuestionDetails, requestParameters, 7, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.MSQ);
assertTrue(responseDetails instanceof FeedbackMsqResponseDetails);
assertEquals("msq option 1, msq option 2, msq option 3, other answer", responseDetails.getAnswerString());
assertTrue(((FeedbackMsqResponseDetails) responseDetails).isOtherOptionAnswer());
assertEquals("other answer", ((FeedbackMsqResponseDetails) responseDetails).getOtherFieldContent());
requestParameters.clear();
______TS("NUMSCALE Response: typical case");
FeedbackNumericalScaleQuestionDetails numericalScaleQuestionDetails = new FeedbackNumericalScaleQuestionDetails();
numericalScaleQuestionDetails.setMaxScale(5);
numericalScaleQuestionDetails.setMinScale(-5);
requestParameters.put("questiontype-6", new String[] { "NUMSCALE" });
requestParameters.put("responsetext-6-0", new String[] { "-3.5" });
requestParameters.put("numscalemin-6-0", new String[] { "-5" });
requestParameters.put("numscalemax-6-0", new String[] { "5" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "-3.5" }, FeedbackQuestionType.NUMSCALE, numericalScaleQuestionDetails, requestParameters, 6, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.NUMSCALE);
assertTrue(responseDetails instanceof FeedbackNumericalScaleResponseDetails);
assertEquals("-3.5", responseDetails.getAnswerString());
requestParameters.clear();
______TS("NUMSCALE Response: wrong format");
requestParameters.put("questiontype-6", new String[] { "NUMSCALE" });
requestParameters.put("responsetext-6-0", new String[] { "-0.5.3" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "-0.5.3" }, FeedbackQuestionType.NUMSCALE, numericalScaleQuestionDetails, requestParameters, 6, 0);
assertNull(responseDetails);
requestParameters.clear();
______TS("CONSTSUM Response: typical case");
String questionText = "question text";
List<String> constSumOptions = new ArrayList<>();
constSumOptions.add("Option 1");
constSumOptions.add("Option 2");
boolean isPointsPerOption = false;
int points = 100;
boolean shouldForceUnevenDistribution = false;
FeedbackConstantSumQuestionDetails constantSumQuestionDetails = new FeedbackConstantSumQuestionDetails(questionText, constSumOptions, isPointsPerOption, points, shouldForceUnevenDistribution);
requestParameters.put("questiontype-7", new String[] { "CONSTSUM" });
requestParameters.put("responsetext-7-0", new String[] { "20", "80" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "20", "80" }, FeedbackQuestionType.CONSTSUM, constantSumQuestionDetails, requestParameters, 7, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.CONSTSUM);
assertTrue(responseDetails instanceof FeedbackConstantSumResponseDetails);
assertEquals("20, 80", responseDetails.getAnswerString());
requestParameters.clear();
______TS("CONTRIB Response: typical case");
questionText = "question text";
FeedbackContributionQuestionDetails contribQuestionDetails = new FeedbackContributionQuestionDetails(questionText);
requestParameters.put("questiontype-8", new String[] { "CONTRIB" });
requestParameters.put("responsetext-8-0", new String[] { "100" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "100" }, FeedbackQuestionType.CONTRIB, contribQuestionDetails, requestParameters, 8, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.CONTRIB);
assertTrue(responseDetails instanceof FeedbackContributionResponseDetails);
assertEquals("100", responseDetails.getAnswerString());
requestParameters.clear();
______TS("RUBRIC Response: invalid indexes in response");
questionText = "question text";
FeedbackRubricQuestionDetails rubricQuestionDetails = new FeedbackRubricQuestionDetails(questionText);
requestParameters.put("questiontype-9", new String[] { "RUBRIC" });
requestParameters.put("responsetext-9-0", new String[] { "0-0,1-0" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "0-0,1-0" }, FeedbackQuestionType.RUBRIC, rubricQuestionDetails, requestParameters, 9, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.RUBRIC);
assertTrue(responseDetails instanceof FeedbackRubricResponseDetails);
assertEquals("[]", responseDetails.getAnswerString());
requestParameters.clear();
______TS("RUBRIC Response: typical case");
rubricQuestionDetails.setNumOfRubricChoices(rubricQuestionDetails.getNumOfRubricChoices() + 1);
rubricQuestionDetails.getRubricChoices().add("choice1");
rubricQuestionDetails.setNumOfRubricSubQuestions(rubricQuestionDetails.getNumOfRubricSubQuestions() + 1);
rubricQuestionDetails.getRubricSubQuestions().add("sub-qn1");
rubricQuestionDetails.setNumOfRubricSubQuestions(rubricQuestionDetails.getNumOfRubricSubQuestions() + 1);
rubricQuestionDetails.getRubricSubQuestions().add("sub-qn2");
requestParameters.put("questiontype-9", new String[] { "RUBRIC" });
requestParameters.put("responsetext-9-0", new String[] { "0-0,1-0" });
responseDetails = FeedbackResponseDetails.createResponseDetails(new String[] { "0-0,1-0" }, FeedbackQuestionType.RUBRIC, rubricQuestionDetails, requestParameters, 9, 0);
assertEquals(responseDetails.questionType, FeedbackQuestionType.RUBRIC);
assertTrue(responseDetails instanceof FeedbackRubricResponseDetails);
assertEquals("[0, 0]", responseDetails.getAnswerString());
requestParameters.clear();
}
Aggregations