use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class InstructorEditStudentFeedbackSaveActionTest method testModifyResponses.
private void testModifyResponses() {
______TS("edit existing answer");
FeedbackQuestionsDb fqDb = new FeedbackQuestionsDb();
FeedbackQuestionAttributes fq = fqDb.getFeedbackQuestion("First feedback session", "IESFPTCourse", 1);
assertNotNull("Feedback question not found in database", fq);
FeedbackResponsesDb frDb = new FeedbackResponsesDb();
FeedbackResponseAttributes fr = dataBundle.feedbackResponses.get("response1ForQ1");
// necessary to get the correct responseId
fr = frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient);
assertNotNull("Feedback response not found in database", fr);
InstructorAttributes instructor = dataBundle.instructors.get("IESFPTCourseinstr");
gaeSimulation.loginAsInstructor(instructor.googleId);
String moderatedStudentEmail = "student1InIESFPTCourse@gmail.tmt";
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(), Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
InstructorEditStudentFeedbackSaveAction a = getAction(submissionParams);
RedirectResult r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_STUDENT_FEEDBACK_PAGE, false, "student1InIESFPTCourse%40gmail.tmt", "IESFPTCourseinstr", "IESFPTCourse", "First+feedback+session"), r.getDestinationWithParams());
assertNotNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
// submission confirmation email not sent if parameter does not exist
verifyNoEmailsSent(a);
______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", "", Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail, 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_EDIT_STUDENT_FEEDBACK_PAGE, false, "student1InIESFPTCourse%40gmail.tmt", "IESFPTCourseinstr", "IESFPTCourse", "First+feedback+session"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
// submission confirmation email still not sent even if parameter is "on" because this is moderation
verifyNoEmailsSent(a);
// 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", "", Const.ParamsNames.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_STUDENT_FEEDBACK_PAGE, false, "student1InIESFPTCourse%40gmail.tmt", "IESFPTCourseinstr", "IESFPTCourse", "First+feedback+session"), r.getDestinationWithParams());
assertNull(frDb.getFeedbackResponse(fq.getId(), fr.giver, fr.recipient));
______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.FEEDBACK_SESSION_MODERATED_PERSON, moderatedStudentEmail };
a = getAction(submissionParams);
r = getRedirectResult(a);
assertFalse(r.isError);
assertEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED, r.getStatusMessage());
assertEquals(getPageResultDestination(Const.ActionURIs.INSTRUCTOR_EDIT_STUDENT_FEEDBACK_PAGE, false, "student1InIESFPTCourse%40gmail.tmt", "IESFPTCourseinstr", "IESFPTCourse", "First+feedback+session"), 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);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackSubmissionEditSaveAction method extractFeedbackResponseData.
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(getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_ID + "-" + questionIndx + "-" + responseIndx));
response.feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, response.feedbackSessionName);
response.courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, response.courseId);
response.feedbackQuestionId = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_ID + "-" + questionIndx, response.feedbackQuestionId);
Assumption.assertEquals("feedbackQuestionId Mismatch", feedbackQuestionAttributes.getId(), response.feedbackQuestionId);
response.recipient = getRequestParamValue(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_RESPONSE_RECIPIENT + "-" + questionIndx + "-" + responseIndx, response.recipient);
String feedbackQuestionType = getRequestParamValue(Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx);
Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_QUESTION_TYPE + "-" + questionIndx, 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 = logic.getSectionForTeam(courseId, response.recipient);
} else if (recipientType == FeedbackParticipantType.STUDENTS) {
StudentAttributes student = logic.getStudentForEmail(courseId, response.recipient);
response.recipientSection = student == null ? Const.DEFAULT_SECTION : student.section;
} else {
response.recipientSection = getUserSectionForCourse();
}
// This field can be null if the question is skipped
String paramName = Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-" + questionIndx + "-" + responseIndx;
String[] answer = getRequestParamValues(paramName);
if (questionDetails.isQuestionSkipped(answer)) {
response.responseMetaData = new Text("");
} else {
FeedbackResponseDetails responseDetails = FeedbackResponseDetails.createResponseDetails(answer, questionDetails.getQuestionType(), questionDetails, requestParameters, questionIndx, responseIndx);
response.setResponseDetails(responseDetails);
}
return response;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackSubmissionEditSaveAction method updateResponses.
private void updateResponses(List<FeedbackResponseAttributes> responsesToUpdate) throws EntityDoesNotExistException {
for (FeedbackResponseAttributes response : responsesToUpdate) {
try {
logic.updateFeedbackResponse(response);
hasValidResponse = true;
} catch (EntityAlreadyExistsException | InvalidParametersException e) {
setStatusForException(e);
}
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class BackDoorLogic method injectRealIdsIntoResponses.
/**
* This method is necessary to generate the feedbackQuestionId of the
* question the response is for.<br>
* Normally, the ID is already generated on creation,
* but the json file does not contain the actual response ID. <br>
* Therefore the question number corresponding to the created response
* should be inserted in the json file in place of the actual response ID.<br>
* This method will then generate the correct ID and replace the field.
*/
private void injectRealIdsIntoResponses(Collection<FeedbackResponseAttributes> responses, Map<String, String> questionIdMap) {
for (FeedbackResponseAttributes response : responses) {
int questionNumber;
try {
questionNumber = Integer.parseInt(response.feedbackQuestionId);
} catch (NumberFormatException e) {
// question ID already injected
continue;
}
String sessionKey = makeSessionKey(response.feedbackSessionName, response.courseId);
String questionKey = makeQuestionKey(sessionKey, questionNumber);
response.feedbackQuestionId = questionIdMap.get(questionKey);
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class BackDoorLogic method updateRespondents.
private void updateRespondents(FeedbackSessionAttributes session, Set<InstructorAttributes> courseInstructors, Set<FeedbackQuestionAttributes> sessionQuestions, Set<FeedbackResponseAttributes> sessionResponses) {
String sessionKey = makeSessionKey(session.getFeedbackSessionName(), session.getCourseId());
SetMultimap<String, String> instructorQuestionKeysMap = HashMultimap.create();
for (InstructorAttributes instructor : courseInstructors) {
List<FeedbackQuestionAttributes> questionsForInstructor = feedbackQuestionsLogic.getFeedbackQuestionsForInstructor(new ArrayList<>(sessionQuestions), session.isCreator(instructor.email));
List<String> questionKeys = makeQuestionKeys(questionsForInstructor, sessionKey);
instructorQuestionKeysMap.putAll(instructor.email, questionKeys);
}
Set<String> respondingInstructors = new HashSet<>();
Set<String> respondingStudents = new HashSet<>();
for (FeedbackResponseAttributes response : sessionResponses) {
String respondent = response.giver;
// contains question number before injection
String responseQuestionNumber = response.feedbackQuestionId;
String responseQuestionKey = makeQuestionKey(sessionKey, responseQuestionNumber);
Set<String> instructorQuestionKeys = instructorQuestionKeysMap.get(respondent);
if (instructorQuestionKeys.contains(responseQuestionKey)) {
respondingInstructors.add(respondent);
} else {
respondingStudents.add(respondent);
}
}
session.setRespondingInstructorList(respondingInstructors);
session.setRespondingStudentList(respondingStudents);
}
Aggregations