use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method getViewableFeedbackResponsesForStudentForQuestion.
private List<FeedbackResponseAttributes> getViewableFeedbackResponsesForStudentForQuestion(FeedbackQuestionAttributes question, String studentEmail) {
List<FeedbackResponseAttributes> viewableResponses = new ArrayList<>();
if (question.isResponseVisibleTo(FeedbackParticipantType.STUDENTS)) {
addNewResponses(viewableResponses, getFeedbackResponsesForQuestion(question.getId()));
// Early return as STUDENTS covers all other student types.
return viewableResponses;
}
StudentAttributes student = studentsLogic.getStudentForEmail(question.courseId, studentEmail);
if (question.recipientType.isTeam() && 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;
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method deleteResponsesFromUserToTeam.
private void deleteResponsesFromUserToTeam(String courseId, String userEmail) {
FeedbackQuestionAttributes question;
List<FeedbackResponseAttributes> responsesFromUser = getFeedbackResponsesFromGiverForCourse(courseId, userEmail);
for (FeedbackResponseAttributes response : responsesFromUser) {
question = fqLogic.getFeedbackQuestion(response.feedbackQuestionId);
if (question.giverType == FeedbackParticipantType.TEAMS || isRecipientTypeTeamMembers(question)) {
frDb.deleteEntity(response);
}
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackResponsesLogic method deleteFeedbackResponsesForStudentAndCascade.
public void deleteFeedbackResponsesForStudentAndCascade(String courseId, String studentEmail) {
String studentTeam = "";
StudentAttributes student = studentsLogic.getStudentForEmail(courseId, studentEmail);
if (student != null) {
studentTeam = student.team;
}
List<FeedbackResponseAttributes> responses = getFeedbackResponsesFromGiverForCourse(courseId, studentEmail);
responses.addAll(getFeedbackResponsesForReceiverForCourse(courseId, studentEmail));
// Delete responses to team as well if student is last person in team.
if (studentsLogic.getStudentsForTeam(studentTeam, courseId).size() <= 1) {
responses.addAll(getFeedbackResponsesForReceiverForCourse(courseId, studentTeam));
}
for (FeedbackResponseAttributes response : responses) {
this.deleteFeedbackResponseAndCascade(response);
}
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method updateRespondentsForSession.
public void updateRespondentsForSession(String feedbackSessionName, String courseId) throws InvalidParametersException, EntityDoesNotExistException {
clearInstructorRespondents(feedbackSessionName, courseId);
clearStudentRespondents(feedbackSessionName, courseId);
FeedbackSessionAttributes fsa = getFeedbackSession(feedbackSessionName, courseId);
List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession(feedbackSessionName, courseId);
List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(courseId);
Map<String, List<String>> instructorQuestionsMap = new HashMap<>();
for (InstructorAttributes instructor : instructors) {
List<FeedbackQuestionAttributes> instructorQns = fqLogic.getFeedbackQuestionsForInstructor(questions, fsa.isCreator(instructor.email));
if (!instructorQns.isEmpty()) {
List<String> questionIds = new ArrayList<>();
for (FeedbackQuestionAttributes question : instructorQns) {
questionIds.add(question.getId());
}
instructorQuestionsMap.put(instructor.email, questionIds);
}
}
Set<String> respondingStudentList = new HashSet<>();
Set<String> respondingInstructorList = new HashSet<>();
List<FeedbackResponseAttributes> responses = frLogic.getFeedbackResponsesForSession(feedbackSessionName, courseId);
for (FeedbackResponseAttributes response : responses) {
List<String> instructorQuestions = instructorQuestionsMap.get(response.giver);
if (instructorQuestions != null && instructorQuestions.contains(response.feedbackQuestionId)) {
respondingInstructorList.add(response.giver);
} else {
respondingStudentList.add(response.giver);
}
}
addInstructorRespondents(new ArrayList<>(respondingInstructorList), feedbackSessionName, courseId);
addStudentRespondents(new ArrayList<>(respondingStudentList), feedbackSessionName, courseId);
}
use of teammates.common.datatransfer.attributes.FeedbackResponseAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getResponseComments.
private Map<String, List<FeedbackResponseCommentAttributes>> getResponseComments(String feedbackSessionName, String courseId, String userEmail, UserRole role, CourseRoster roster, Map<String, FeedbackQuestionAttributes> relevantQuestions, String section, StudentAttributes student, Set<String> studentsEmailInTeam, Map<String, FeedbackResponseAttributes> relevantResponse) {
Map<String, List<FeedbackResponseCommentAttributes>> responseComments = new HashMap<>();
List<FeedbackResponseCommentAttributes> allResponseComments = frcLogic.getFeedbackResponseCommentForSessionInSection(courseId, feedbackSessionName, section);
for (FeedbackResponseCommentAttributes frc : allResponseComments) {
FeedbackResponseAttributes relatedResponse = relevantResponse.get(frc.feedbackResponseId);
FeedbackQuestionAttributes relatedQuestion = relevantQuestions.get(frc.feedbackQuestionId);
boolean isVisibleResponseComment = frcLogic.isResponseCommentVisibleForUser(userEmail, role, student, studentsEmailInTeam, relatedResponse, relatedQuestion, frc);
if (isVisibleResponseComment) {
if (!frcLogic.isNameVisibleToUser(frc, relatedResponse, userEmail, roster)) {
frc.giverEmail = Const.DISPLAYED_NAME_FOR_ANONYMOUS_PARTICIPANT;
}
List<FeedbackResponseCommentAttributes> frcList = responseComments.get(frc.feedbackResponseId);
if (frcList == null) {
frcList = new ArrayList<>();
frcList.add(frc);
responseComments.put(frc.feedbackResponseId, frcList);
} else {
frcList.add(frc);
}
}
}
for (List<FeedbackResponseCommentAttributes> responseCommentList : responseComments.values()) {
sortByCreatedDate(responseCommentList);
}
return responseComments;
}
Aggregations