use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.
the class FeedbackQuestionsLogicTest method testUpdateQuestion.
private void testUpdateQuestion() throws Exception {
______TS("standard update, no existing responses, with 'keep existing' policy");
FeedbackQuestionAttributes questionToUpdate = getQuestionFromDatastore("qn2InSession2InCourse2");
questionToUpdate.questionMetaData = new Text("new question text");
questionToUpdate.questionNumber = 3;
List<FeedbackParticipantType> newVisibility = new LinkedList<>();
newVisibility.add(FeedbackParticipantType.INSTRUCTORS);
questionToUpdate.showResponsesTo = newVisibility;
// Check keep existing policy.
String originalCourseId = questionToUpdate.courseId;
questionToUpdate.courseId = null;
fqLogic.updateFeedbackQuestion(questionToUpdate);
questionToUpdate.courseId = originalCourseId;
FeedbackQuestionAttributes updatedQuestion = fqLogic.getFeedbackQuestion(questionToUpdate.getId());
assertEquals(updatedQuestion.toString(), questionToUpdate.toString());
______TS("cascading update, non-destructive changes, existing responses are preserved");
questionToUpdate = getQuestionFromDatastore("qn2InSession1InCourse1");
questionToUpdate.questionMetaData = new Text("new question text 2");
questionToUpdate.numberOfEntitiesToGiveFeedbackTo = 2;
int numberOfResponses = frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).size();
fqLogic.updateFeedbackQuestion(questionToUpdate);
updatedQuestion = fqLogic.getFeedbackQuestion(questionToUpdate.getId());
assertEquals(updatedQuestion.toString(), questionToUpdate.toString());
assertEquals(frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).size(), numberOfResponses);
______TS("cascading update, destructive changes, delete all existing responses");
questionToUpdate = getQuestionFromDatastore("qn2InSession1InCourse1");
questionToUpdate.questionMetaData = new Text("new question text 3");
questionToUpdate.recipientType = FeedbackParticipantType.INSTRUCTORS;
assertFalse(frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).isEmpty());
fqLogic.updateFeedbackQuestion(questionToUpdate);
updatedQuestion = fqLogic.getFeedbackQuestion(questionToUpdate.getId());
assertEquals(updatedQuestion.toString(), questionToUpdate.toString());
assertEquals(frLogic.getFeedbackResponsesForQuestion(questionToUpdate.getId()).size(), 0);
______TS("failure: question does not exist");
questionToUpdate = getQuestionFromDatastore("qn3InSession1InCourse1");
fqLogic.deleteFeedbackQuestionCascade(questionToUpdate.getId());
try {
fqLogic.updateFeedbackQuestion(questionToUpdate);
signalFailureToDetectException("Expected EntityDoesNotExistException not caught.");
} catch (EntityDoesNotExistException e) {
assertEquals(e.getMessage(), "Trying to update a feedback question that does not exist.");
}
______TS("failure: invalid parameters");
questionToUpdate = getQuestionFromDatastore("qn3InSession1InCourse1");
questionToUpdate.giverType = FeedbackParticipantType.TEAMS;
questionToUpdate.recipientType = FeedbackParticipantType.OWN_TEAM_MEMBERS;
try {
fqLogic.updateFeedbackQuestion(questionToUpdate);
signalFailureToDetectException("Expected InvalidParametersException not caught.");
} catch (InvalidParametersException e) {
assertEquals(e.getMessage(), String.format(FieldValidator.PARTICIPANT_TYPE_TEAM_ERROR_MESSAGE, questionToUpdate.recipientType.toDisplayRecipientName(), questionToUpdate.giverType.toDisplayGiverName()));
}
}
use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.
the class InstructorFeedbackResponseCommentAjaxPageData method getResponseVisibilities.
private Map<FeedbackParticipantType, Boolean> getResponseVisibilities() {
FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
Map<FeedbackParticipantType, Boolean> responseVisibilities = new HashMap<>();
for (FeedbackParticipantType type : relevantTypes) {
responseVisibilities.put(type, isResponseVisibleTo(type, question));
}
return responseVisibilities;
}
use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageData method buildFeedbackResponseCommentAddForm.
private FeedbackResponseCommentRow buildFeedbackResponseCommentAddForm(FeedbackQuestionAttributes question, FeedbackResponseAttributes response, Map<FeedbackParticipantType, Boolean> responseVisibilityMap, String giverName, String recipientName) {
FeedbackResponseCommentAttributes frca = FeedbackResponseCommentAttributes.builder(question.courseId, question.feedbackSessionName, "", new Text("")).withFeedbackResponseId(response.getId()).withFeedbackQuestionId(question.getId()).build();
FeedbackParticipantType[] relevantTypes = { FeedbackParticipantType.GIVER, FeedbackParticipantType.RECEIVER, FeedbackParticipantType.OWN_TEAM_MEMBERS, FeedbackParticipantType.RECEIVER_TEAM_MEMBERS, FeedbackParticipantType.STUDENTS, FeedbackParticipantType.INSTRUCTORS };
frca.showCommentTo = new ArrayList<>();
frca.showGiverNameTo = new ArrayList<>();
for (FeedbackParticipantType type : relevantTypes) {
if (isResponseCommentVisibleTo(question, type)) {
frca.showCommentTo.add(type);
}
if (isResponseCommentGiverNameVisibleTo(question, type)) {
frca.showGiverNameTo.add(type);
}
}
return new FeedbackResponseCommentRow(frca, giverName, recipientName, getResponseCommentVisibilityString(question), getResponseCommentGiverNameVisibilityString(question), responseVisibilityMap, bundle.getTimeZone());
}
use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageData method buildResponsePanels.
private List<InstructorFeedbackResultsResponsePanel> buildResponsePanels(final String additionalInfoId, int primaryParticipantIndex, int secondaryRecipientIndex, List<FeedbackResponseAttributes> giverResponses) {
List<InstructorFeedbackResultsResponsePanel> responsePanels = new ArrayList<>();
for (int responseIndex = 0; responseIndex < giverResponses.size(); responseIndex++) {
FeedbackResponseAttributes response = giverResponses.get(responseIndex);
String questionId = response.feedbackQuestionId;
FeedbackQuestionAttributes question = bundle.questions.get(questionId);
String questionText = bundle.getQuestionText(questionId);
int giverIndex = viewType.isPrimaryGroupingOfGiverType() ? primaryParticipantIndex : secondaryRecipientIndex;
int recipientIndex = viewType.isPrimaryGroupingOfGiverType() ? secondaryRecipientIndex : primaryParticipantIndex;
String additionalInfoText = questionToDetailsMap.get(question).getQuestionAdditionalInfoHtml(question.getQuestionNumber(), String.format(additionalInfoId, giverIndex, recipientIndex));
String displayableResponse = bundle.getResponseAnswerHtml(response, question);
String giverName = bundle.getNameForEmail(response.giver);
String recipientName = bundle.getNameForEmail(response.recipient);
String giverTeam = bundle.getTeamNameForEmail(response.giver);
String recipientTeam = bundle.getTeamNameForEmail(response.recipient);
giverName = bundle.appendTeamNameToName(giverName, giverTeam);
recipientName = bundle.appendTeamNameToName(recipientName, recipientTeam);
List<FeedbackResponseCommentRow> comments = buildResponseComments(giverName, recipientName, question, response);
boolean isAllowedToSubmitSessionsInBothSection = instructor.isAllowedForPrivilege(response.giverSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS) && instructor.isAllowedForPrivilege(response.recipientSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS);
boolean isCommentsOnResponsesAllowed = question.getQuestionDetails().isCommentsOnResponsesAllowed();
Matcher matcher = sectionIdPattern.matcher(additionalInfoId);
if (matcher.find()) {
sectionId = Integer.parseInt(matcher.group(1));
}
InstructorFeedbackResultsResponsePanel responsePanel = new InstructorFeedbackResultsResponsePanel(question, response, questionText, sectionId, additionalInfoText, null, displayableResponse, comments, isAllowedToSubmitSessionsInBothSection, isCommentsOnResponsesAllowed);
responsePanel.setCommentsIndexes(recipientIndex, giverIndex, responseIndex + 1);
if (isCommentsOnResponsesAllowed) {
Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
FeedbackResponseCommentRow frcForAdding = buildFeedbackResponseCommentAddForm(question, response, responseVisibilityMap, giverName, recipientName);
responsePanel.setFrcForAdding(frcForAdding);
}
responsePanels.add(responsePanel);
}
return responsePanels;
}
use of teammates.common.datatransfer.FeedbackParticipantType in project teammates by TEAMMATES.
the class InstructorFeedbackResultsPageData method buildResponseComment.
private FeedbackResponseCommentRow buildResponseComment(String giverName, String recipientName, FeedbackQuestionAttributes question, FeedbackResponseAttributes response, FeedbackResponseCommentAttributes frcAttributes) {
boolean isInstructorGiver = instructor.email.equals(frcAttributes.giverEmail);
boolean isInstructorWithPrivilegesToModify = instructor.isAllowedForPrivilege(response.giverSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS) && instructor.isAllowedForPrivilege(response.recipientSection, response.feedbackSessionName, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS);
boolean isInstructorAllowedToEditAndDeleteComment = isInstructorGiver || isInstructorWithPrivilegesToModify;
Map<FeedbackParticipantType, Boolean> responseVisibilityMap = getResponseVisibilityMap(question);
String whoCanSeeComment = null;
boolean isVisibilityIconShown = false;
if (bundle.feedbackSession.isPublished()) {
boolean isResponseCommentPublicToRecipient = !frcAttributes.showCommentTo.isEmpty();
isVisibilityIconShown = isResponseCommentPublicToRecipient;
if (isVisibilityIconShown) {
whoCanSeeComment = getTypeOfPeopleCanViewComment(frcAttributes, question);
}
}
FeedbackResponseCommentRow frc = new FeedbackResponseCommentRow(frcAttributes, frcAttributes.giverEmail, giverName, recipientName, getResponseCommentVisibilityString(frcAttributes, question), getResponseCommentGiverNameVisibilityString(frcAttributes, question), responseVisibilityMap, bundle.instructorEmailNameTable, bundle.getTimeZone());
frc.setVisibilityIcon(isVisibilityIconShown, whoCanSeeComment);
if (isInstructorAllowedToEditAndDeleteComment) {
frc.enableEditDelete();
}
return frc;
}
Aggregations