@Override protected ActionResult execute() throws EntityDoesNotExistException { // TODO: Looks like this class is handling multiple actions. Break up? String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); Assumption.assertNotNull(courseId); Assumption.assertNotNull(feedbackSessionName); new GateKeeper() .verifyAccessible( logic.getInstructorForGoogleId(courseId, account.googleId), logic.getFeedbackSession(feedbackSessionName, courseId), true); String editType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_EDITTYPE); FeedbackQuestionAttributes updatedQuestion = extractFeedbackQuestionData(requestParameters); try { if (editType.equals("edit")) { if (updatedQuestion.questionNumber != 0) { // Question number was updated logic.updateFeedbackQuestionNumber(updatedQuestion); statusToUser.add(Const.StatusMessages.FEEDBACK_QUESTION_EDITED); } else { logic.updateFeedbackQuestion(updatedQuestion); statusToUser.add(Const.StatusMessages.FEEDBACK_QUESTION_EDITED); statusToAdmin = "Feedback Question " + updatedQuestion.questionNumber + " for session:<span class=\"bold\">(" + updatedQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + updatedQuestion.courseId + "]</span> edited.<br>" + "<span class=\"bold\">" + updatedQuestion.getQuestionDetails().getQuestionTypeDisplayName() + ":</span> " + updatedQuestion.getQuestionDetails().questionText; } } else if (editType.equals("delete")) { logic.deleteFeedbackQuestion(updatedQuestion.getId()); statusToUser.add(Const.StatusMessages.FEEDBACK_QUESTION_DELETED); statusToAdmin = "Feedback Question " + updatedQuestion.questionNumber + " for session:<span class=\"bold\">(" + updatedQuestion.feedbackSessionName + ")</span> for Course <span class=\"bold\">[" + updatedQuestion.courseId + "]</span> deleted.<br>"; } } catch (InvalidParametersException e) { setStatusForException(e); } return createRedirectResult( new PageData(account).getInstructorFeedbackSessionEditLink(courseId, feedbackSessionName)); }
public void testEditResponse() { ______TS("edit responses"); FeedbackQuestionAttributes fq = BackDoor.getFeedbackQuestion("IESFPTCourse", "First feedback session", 1); FeedbackResponseAttributes fr = BackDoor.getFeedbackResponse( fq.getId(), "*****@*****.**", "*****@*****.**"); assertEquals("Student 1 self feedback.", fr.getResponseDetails().getAnswerString()); submitPage = loginToInstructorEditStudentFeedbackPage( "IESFPTCourseinstr", "*****@*****.**", "session1InIESFPTCourse"); // Full HTML verification already done in InstructorFeedbackSubmitPageUiTest submitPage.verifyHtmlMainContent("/InstructorEditStudentFeedbackPageOpen.html"); submitPage.fillResponseTextBox(1, 0, "Good design"); submitPage.clickSubmitButton(); assertEquals(submitPage.getStatus(), Const.StatusMessages.FEEDBACK_RESPONSES_SAVED); fq = BackDoor.getFeedbackQuestion("IESFPTCourse", "First feedback session", 1); fr = BackDoor.getFeedbackResponse( fq.getId(), "*****@*****.**", "*****@*****.**"); assertEquals("Good design", fr.getResponseDetails().getAnswerString()); }
/** Get existing feedback responses from student or his team for the given question. */ public List<FeedbackResponseAttributes> getFeedbackResponsesFromStudentOrTeamForQuestion( FeedbackQuestionAttributes question, StudentAttributes student) { if (question.giverType == FeedbackParticipantType.TEAMS) { return getFeedbackResponsesFromTeamForQuestion( question.getId(), question.courseId, student.team); } else { return frDb.getFeedbackResponsesFromGiverForQuestion(question.getId(), student.email); } }
public void testQuestionAttributes() { StudentFeedbackSubmissionEditQuestionsWithResponses questionWithResponses = pageData.getQuestionsWithResponses().get(0); assertEquals(question.questionType, questionWithResponses.getQuestion().getQuestionType()); assertEquals(question.courseId, questionWithResponses.getQuestion().getCourseId()); assertEquals(question.questionNumber, questionWithResponses.getQuestion().getQuestionNumber()); assertEquals( question.getQuestionDetails().getQuestionText(), questionWithResponses.getQuestion().getQuestionText()); assertEquals( question.numberOfEntitiesToGiveFeedbackTo, questionWithResponses.getQuestion().getNumberOfEntitiesToGiveFeedbackTo()); assertEquals(question.getId(), questionWithResponses.getQuestion().getQuestionId()); }
private static FeedbackSessionRow getFeedbackSessionRow(FeedbackSessionResultsBundle bundle) { List<QuestionTable> questionTables = new ArrayList<QuestionTable>(); FeedbackSessionAttributes session = bundle.feedbackSession; Map<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> questionToResponsesMap = bundle.getQuestionResponseMap(); for (FeedbackQuestionAttributes question : questionToResponsesMap.keySet()) { List<ResponseRow> responseRows = new ArrayList<ResponseRow>(); List<FeedbackResponseAttributes> responses = questionToResponsesMap.get(question); for (FeedbackResponseAttributes response : responses) { List<FeedbackResponseComment> feedbackResponseCommentRows = new ArrayList<FeedbackResponseComment>(); List<FeedbackResponseCommentAttributes> responseComments = bundle.responseComments.get(response.getId()); for (FeedbackResponseCommentAttributes responseComment : responseComments) { FeedbackResponseComment feedbackResponseCommentRow = new FeedbackResponseComment(responseComment, responseComment.giverEmail); feedbackResponseCommentRows.add(feedbackResponseCommentRow); } String giverName = bundle.getGiverNameForResponse(response); String giverTeamName = bundle.getTeamNameForEmail(response.giverEmail); giverName = bundle.appendTeamNameToName(giverName, giverTeamName); String recipientName = bundle.getRecipientNameForResponse(response); String recipientTeamName = bundle.getTeamNameForEmail(response.recipientEmail); recipientName = bundle.appendTeamNameToName(recipientName, recipientTeamName); String responseText = response.getResponseDetails().getAnswerHtml(question.getQuestionDetails()); ResponseRow responseRow = new ResponseRow(giverName, recipientName, responseText, feedbackResponseCommentRows); responseRows.add(responseRow); } int questionNumber = question.questionNumber; String questionText = bundle.getQuestionText(question.getId()); String additionalInfo = question.getQuestionDetails().getQuestionAdditionalInfoHtml(question.questionNumber, ""); QuestionTable questionTable = new QuestionTable(questionNumber, questionText, additionalInfo, responseRows); questionTables.add(questionTable); } FeedbackSessionRow sessionRow = new FeedbackSessionRow(session.feedbackSessionName, session.courseId, questionTables); return sessionRow; }
private void testAddResponse() { ______TS("test new response"); submitPage.fillResponseTextBox(2, 0, "4"); submitPage.clickSubmitButton(); assertEquals(submitPage.getStatus(), Const.StatusMessages.FEEDBACK_RESPONSES_SAVED); FeedbackQuestionAttributes fq = BackDoor.getFeedbackQuestion("IESFPTCourse", "First feedback session", 2); FeedbackResponseAttributes fr = BackDoor.getFeedbackResponse( fq.getId(), "*****@*****.**", "*****@*****.**"); assertEquals("4", fr.getResponseDetails().getAnswerString()); // Full HTML verification already done in InstructorFeedbackSubmitPageUiTest submitPage.verifyHtmlMainContent("/InstructorEditStudentFeedbackPageModified.html"); }
/** * Creates a single FeedbackSessionResultsBundle object which comprises a single feedback session, * a single question, a single response and a single response comment */ private static FeedbackSessionResultsBundle getSingleFeedbackSessionResultsBundle( CourseRoster roster) { FeedbackSessionAttributes session = dataBundle.feedbackSessions.get("session1InCourse1"); FeedbackResponseAttributes response = dataBundle.feedbackResponses.get("response1ForQ1S1C1"); response.setId("1"); List<FeedbackResponseAttributes> responses = Arrays.asList(response); Map<String, FeedbackQuestionAttributes> relevantQuestions = new HashMap<String, FeedbackQuestionAttributes>(); FeedbackQuestionAttributes question = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"); question.setId("1"); relevantQuestions.put(question.getId(), question); Map<String, String> emailNameTable = new HashMap<String, String>(); Map<String, String> emailLastNameTable = new HashMap<String, String>(); Map<String, String> emailTeamNameTable = new HashMap<String, String>(); Map<String, boolean[]> visibilityTable = new HashMap<String, boolean[]>(); Map<String, List<FeedbackResponseCommentAttributes>> responseComments = new HashMap<String, List<FeedbackResponseCommentAttributes>>(); emailNameTable.put(sampleStudent.email, sampleStudent.name); emailLastNameTable.put(sampleStudent.email, sampleStudent.lastName); emailTeamNameTable.put(sampleStudent.email, sampleStudent.team); boolean[] visibility = {true, true}; visibilityTable.put(response.getId(), visibility); FeedbackSessionResponseStatus responseStatus = new FeedbackSessionResponseStatus(); responseStatus.emailNameTable.put(sampleStudent.email, sampleStudent.name); responseStatus.emailTeamNameTable.put(sampleStudent.email, sampleStudent.team); FeedbackResponseCommentAttributes responseComment = dataBundle.feedbackResponseComments.get("comment1FromT1C1ToR1Q1S1C1"); List<FeedbackResponseCommentAttributes> responseCommentsList = Arrays.asList(responseComment); responseComments.put(response.getId(), responseCommentsList); boolean isComplete = true; return new FeedbackSessionResultsBundle( session, responses, relevantQuestions, emailNameTable, emailLastNameTable, emailTeamNameTable, visibilityTable, responseStatus, roster, responseComments, isComplete); }
private void repairResponsesForQuestion( FeedbackQuestionAttributes question, boolean needRepairGiverSection, boolean needRepairRecipientSection) throws InvalidParametersException, EntityAlreadyExistsException, EntityDoesNotExistException { List<FeedbackResponseAttributes> responses = logic.getFeedbackResponsesForQuestion(question.getId()); for (FeedbackResponseAttributes response : responses) { boolean needUpdateResponse = false; String originalGiverSection = ""; String originalRecipientSection = ""; if (needRepairGiverSection) { StudentAttributes student = logic.getStudentForEmail(question.courseId, response.giver); if (!response.giverSection.equals(student.section)) { originalGiverSection = response.giverSection; response.giverSection = student.section; needUpdateResponse = true; } } if (needRepairRecipientSection) { if (isTeamRecipient(question.recipientType)) { String recipientSection = logic.getStudentsForTeam(response.recipient, question.courseId).get(0).section; if (!recipientSection.equals(response.recipientSection)) { originalRecipientSection = response.recipientSection; response.recipientSection = recipientSection; needUpdateResponse = true; } } else { StudentAttributes student = logic.getStudentForEmail(question.courseId, response.recipient); if (!response.recipientSection.equals(student.section)) { originalRecipientSection = response.recipientSection; response.recipientSection = student.section; needUpdateResponse = true; } } } if (needUpdateResponse) { System.out.println( "Repairing giver section:" + originalGiverSection + "-->" + response.giverSection + " receiver section:" + originalRecipientSection + "-->" + response.recipientSection); logic.updateFeedbackResponse(response); } } }
public List<FeedbackResponseAttributes> getViewableFeedbackResponsesForQuestionInSection( FeedbackQuestionAttributes question, String userEmail, UserType.Role role, String section) throws EntityDoesNotExistException { List<FeedbackResponseAttributes> viewableResponses = new ArrayList<FeedbackResponseAttributes>(); // Add responses that the user submitted himself addNewResponses( viewableResponses, getFeedbackResponsesFromGiverForQuestionInSection(question.getId(), userEmail, section)); // Add responses that user is a receiver of when question is visible to // receiver. if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) { addNewResponses( viewableResponses, getFeedbackResponsesForReceiverForQuestionInSection( question.getId(), userEmail, section)); } switch (role) { case STUDENT: addNewResponses( viewableResponses, // many queries getViewableFeedbackResponsesForStudentForQuestion(question, userEmail)); break; case INSTRUCTOR: if (question.isResponseVisibleTo(FeedbackParticipantType.INSTRUCTORS)) { addNewResponses( viewableResponses, getFeedbackResponsesForQuestionInSection(question.getId(), section)); } break; default: Assumption.fail("The role of the requesting use has to be Student or Instructor"); } return viewableResponses; }
private void testDeleteResponse() { ______TS("test delete response"); submitPage.fillResponseTextBox(2, 0, ""); submitPage.fillResponseTextBox(1, 0, ""); submitPage.clickSubmitButton(); assertEquals(submitPage.getStatus(), Const.StatusMessages.FEEDBACK_RESPONSES_SAVED); FeedbackQuestionAttributes fq = BackDoor.getFeedbackQuestion("IESFPTCourse", "First feedback session", 1); FeedbackResponseAttributes fr = BackDoor.getFeedbackResponse( fq.getId(), "*****@*****.**", "*****@*****.**"); assertNull(fr); fq = BackDoor.getFeedbackQuestion("IESFPTCourse", "First feedback session", 2); fr = BackDoor.getFeedbackResponse( fq.getId(), "*****@*****.**", "*****@*****.**"); assertNull(fr); }
public void createData(StudentAttributes student) { FeedbackSessionAttributes feedbackSession = dataBundle.feedbackSessions.get("session1InCourse1"); question = dataBundle.feedbackQuestions.get("qn1InSession1InCourse1"); responses.add(dataBundle.feedbackResponses.get("response1ForQ1S1C1")); responses.add(dataBundle.feedbackResponses.get("response2ForQ1S1C1")); questionResponseBundle.put(question, responses); recipients.put(student.email, Const.USER_NAME_FOR_SELF); recipientList.put(question.getId(), recipients); pageData.bundle = new FeedbackSessionQuestionsBundle(feedbackSession, questionResponseBundle, recipientList); pageData.bundle.questionResponseBundle.put(question, responses); }
private List<FeedbackResponseAttributes> getViewableFeedbackResponsesForStudentForQuestion( FeedbackQuestionAttributes question, String studentEmail) { List<FeedbackResponseAttributes> viewableResponses = new ArrayList<FeedbackResponseAttributes>(); StudentAttributes student = studentsLogic.getStudentForEmail(question.courseId, studentEmail); if (question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS)) { addNewResponses(viewableResponses, getFeedbackResponsesForQuestion(question.getId())); // Early return as STUDENTS covers all other student types. return viewableResponses; } if (question.recipientType == FeedbackParticipantType.TEAMS && question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER)) { addNewResponses( viewableResponses, getFeedbackResponsesForReceiverForQuestion(question.getId(), student.team)); } if (question.giverType == FeedbackParticipantType.TEAMS || question.isResponseVisibleTo(FeedbackParticipantType.OWN_TEAM_MEMBERS)) { addNewResponses( viewableResponses, getFeedbackResponsesFromTeamForQuestion( question.getId(), question.courseId, student.team)); } if (question.isResponseVisibleTo(FeedbackParticipantType.RECEIVER_TEAM_MEMBERS)) { addNewResponses( viewableResponses, getFeedbackResponsesForTeamMembersOfStudent(question.getId(), student)); } return viewableResponses; }
private static FeedbackQuestionAttributes extractFeedbackQuestionData( Map<String, String[]> requestParameters) { FeedbackQuestionAttributes newQuestion = new FeedbackQuestionAttributes(); newQuestion.setId( HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_ID)); Assumption.assertNotNull("Null question id", newQuestion.getId()); newQuestion.courseId = HttpRequestHelper.getValueFromParamMap(requestParameters, Const.ParamsNames.COURSE_ID); Assumption.assertNotNull("Null course id", newQuestion.courseId); newQuestion.feedbackSessionName = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_SESSION_NAME); Assumption.assertNotNull("Null feedback session name", newQuestion.feedbackSessionName); // TODO thoroughly investigate when and why these parameters can be null // and check all possibilities in the tests // should only be null when deleting. might be good to separate the delete action from this // class // Can be null String giverType = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_GIVERTYPE); if (giverType != null) { newQuestion.giverType = FeedbackParticipantType.valueOf(giverType); } // Can be null String recipientType = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_RECIPIENTTYPE); if (recipientType != null) { newQuestion.recipientType = FeedbackParticipantType.valueOf(recipientType); } String questionNumber = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_NUMBER); Assumption.assertNotNull("Null question number", questionNumber); newQuestion.questionNumber = Integer.parseInt(questionNumber); // Can be null String nEntityTypes = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIESTYPE); if (numberOfEntitiesIsUserDefined(newQuestion.recipientType, nEntityTypes)) { String nEntities; nEntities = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_NUMBEROFENTITIES); Assumption.assertNotNull(nEntities); newQuestion.numberOfEntitiesToGiveFeedbackTo = Integer.parseInt(nEntities); } else { newQuestion.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS; } newQuestion.showResponsesTo = getParticipantListFromParams( HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_SHOWRESPONSESTO)); newQuestion.showGiverNameTo = getParticipantListFromParams( HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_SHOWGIVERTO)); newQuestion.showRecipientNameTo = getParticipantListFromParams( HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_SHOWRECIPIENTTO)); String questionType = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_TYPE); Assumption.assertNotNull(questionType); newQuestion.questionType = FeedbackQuestionType.valueOf(questionType); // Can be null String questionText = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_TEXT); if (questionText != null) { FeedbackAbstractQuestionDetails questionDetails = FeedbackAbstractQuestionDetails.createQuestionDetails( requestParameters, newQuestion.questionType); newQuestion.setQuestionDetails(questionDetails); } return newQuestion; }
@Override protected ActionResult execute() throws EntityDoesNotExistException { courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID); feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME); Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId); Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName); setAdditionalParameters(); verifyAccesibleForSpecificUser(); String userEmailForCourse = getUserEmailForCourse(); String userTeamForCourse = getUserTeamForCourse(); String userSectionForCourse = getUserSectionForCourse(); data = new FeedbackSubmissionEditPageData(account, student); data.bundle = getDataBundle(userEmailForCourse); Assumption.assertNotNull( "Feedback session " + feedbackSessionName + " does not exist in " + courseId + ".", data.bundle); checkAdditionalConstraints(); setStatusToAdmin(); if (!isSessionOpenForSpecificUser(data.bundle.feedbackSession)) { isError = true; statusToUser.add( new StatusMessage( Const.StatusMessages.FEEDBACK_SUBMISSIONS_NOT_OPEN, StatusMessageColor.WARNING)); return createSpecificRedirectResult(); } int numOfQuestionsToGet = data.bundle.questionResponseBundle.size(); for (int questionIndx = 1; questionIndx <= numOfQuestionsToGet; questionIndx++) { String totalResponsesForQuestion = getRequestParamValue( Const.ParamsNames.FEEDBACK_QUESTION_RESPONSETOTAL + "-" + questionIndx); if (totalResponsesForQuestion == null) { continue; // question has been skipped (not displayed). } List<FeedbackResponseAttributes> responsesForQuestion = new ArrayList<FeedbackResponseAttributes>(); String questionId = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx); FeedbackQuestionAttributes questionAttributes = data.bundle.getQuestionAttributes(questionId); if (questionAttributes == null) { statusToUser.add( new StatusMessage( "The feedback session or questions may have changed while you were submitting. " + "Please check your responses to make sure they are saved correctly.", StatusMessageColor.WARNING)); isError = true; log.warning( "Question not found. (deleted or invalid id passed?) id: " + questionId + " index: " + questionIndx); continue; } FeedbackQuestionDetails questionDetails = questionAttributes.getQuestionDetails(); int numOfResponsesToGet = Integer.parseInt(totalResponsesForQuestion); String qnId = ""; Set<String> emailSet = data.bundle.getRecipientEmails(questionAttributes.getId()); emailSet.add(""); emailSet = StringHelper.recoverFromSanitizedText(emailSet); ArrayList<String> responsesRecipients = new ArrayList<String>(); List<String> errors = new ArrayList<String>(); for (int responseIndx = 0; responseIndx < numOfResponsesToGet; responseIndx++) { FeedbackResponseAttributes response = extractFeedbackResponseData( requestParameters, questionIndx, responseIndx, questionAttributes); if (response.feedbackQuestionType != questionAttributes.questionType) { errors.add( String.format( Const.StatusMessages.FEEDBACK_RESPONSES_WRONG_QUESTION_TYPE, questionIndx)); } qnId = response.feedbackQuestionId; boolean isExistingResponse = response.getId() != null; // test that if editing an existing response, that the edited response's id // came from the original set of existing responses loaded on the submission page if (isExistingResponse && !isExistingResponseValid(response)) { errors.add( String.format(Const.StatusMessages.FEEDBACK_RESPONSES_INVALID_ID, questionIndx)); continue; } responsesRecipients.add(response.recipientEmail); // if the answer is not empty but the recipient is empty if (response.recipientEmail.isEmpty() && !response.responseMetaData.getValue().isEmpty()) { errors.add( String.format( Const.StatusMessages.FEEDBACK_RESPONSES_MISSING_RECIPIENT, questionIndx)); } if (response.responseMetaData.getValue().isEmpty()) { // deletes the response since answer is empty saveResponse(response); } else { response.giverEmail = questionAttributes.giverType.isTeam() ? userTeamForCourse : userEmailForCourse; response.giverSection = userSectionForCourse; responsesForQuestion.add(response); } } List<String> questionSpecificErrors = questionDetails.validateResponseAttributes( responsesForQuestion, data.bundle.recipientList.get(qnId).size()); errors.addAll(questionSpecificErrors); if (!emailSet.containsAll(responsesRecipients)) { errors.add( String.format(Const.StatusMessages.FEEDBACK_RESPONSE_INVALID_RECIPIENT, questionIndx)); } if (errors.isEmpty()) { for (FeedbackResponseAttributes response : responsesForQuestion) { saveResponse(response); } } else { List<StatusMessage> errorMessages = new ArrayList<StatusMessage>(); for (String error : errors) { errorMessages.add(new StatusMessage(error, StatusMessageColor.DANGER)); } statusToUser.addAll(errorMessages); isError = true; } } if (!isError) { statusToUser.add( new StatusMessage( Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, StatusMessageColor.SUCCESS)); } if (isUserRespondentOfSession()) { appendRespondant(); } else { removeRespondant(); } return createSpecificRedirectResult(); }
private FeedbackResponseAttributes extractFeedbackResponseData( Map<String, String[]> requestParameters, int questionIndx, int responseIndx, FeedbackQuestionAttributes feedbackQuestionAttributes) { FeedbackQuestionDetails questionDetails = feedbackQuestionAttributes.getQuestionDetails(); FeedbackResponseAttributes response = new FeedbackResponseAttributes(); // This field can be null if the response is new response.setId( HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-" + questionIndx + "-" + responseIndx)); response.feedbackSessionName = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_SESSION_NAME); Assumption.assertNotNull("Null feedback session name", response.feedbackSessionName); response.courseId = HttpRequestHelper.getValueFromParamMap(requestParameters, Const.ParamsNames.COURSE_ID); Assumption.assertNotNull("Null feedback courseId", response.courseId); response.feedbackQuestionId = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx); Assumption.assertNotNull("Null feedbackQuestionId", response.feedbackQuestionId); Assumption.assertEquals( "feedbackQuestionId Mismatch", feedbackQuestionAttributes.getId(), response.feedbackQuestionId); response.recipientEmail = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx); Assumption.assertNotNull("Null feedback recipientEmail", response.recipientEmail); String feedbackQuestionType = HttpRequestHelper.getValueFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx); Assumption.assertNotNull("Null feedbackQuestionType", feedbackQuestionType); response.feedbackQuestionType = FeedbackQuestionType.valueOf(feedbackQuestionType); FeedbackParticipantType recipientType = feedbackQuestionAttributes.recipientType; if (recipientType == FeedbackParticipantType.INSTRUCTORS || recipientType == FeedbackParticipantType.NONE) { response.recipientSection = Const.DEFAULT_SECTION; } else if (recipientType == FeedbackParticipantType.TEAMS) { response.recipientSection = StudentsLogic.inst().getSectionForTeam(courseId, response.recipientEmail); } else if (recipientType == FeedbackParticipantType.STUDENTS) { StudentAttributes student = logic.getStudentForEmail(courseId, response.recipientEmail); response.recipientSection = (student == null) ? Const.DEFAULT_SECTION : student.section; } else { response.recipientSection = getUserSectionForCourse(); } // This field can be null if the question is skipped String[] answer = HttpRequestHelper.getValuesFromParamMap( requestParameters, Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-" + questionIndx + "-" + responseIndx); if (!questionDetails.isQuestionSkipped(answer)) { FeedbackResponseDetails responseDetails = FeedbackResponseDetails.createResponseDetails( answer, questionDetails.questionType, questionDetails, requestParameters, questionIndx, responseIndx); response.setResponseDetails(responseDetails); } else { response.responseMetaData = new Text(""); } return response; }