use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes 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.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method isFeedbackSessionViewableToStudents.
public boolean isFeedbackSessionViewableToStudents(FeedbackSessionAttributes session) {
// Allow students to view the feedback session if there are questions for them
List<FeedbackQuestionAttributes> questionsToAnswer = fqLogic.getFeedbackQuestionsForStudents(session.getFeedbackSessionName(), session.getCourseId());
if (session.isVisible() && !questionsToAnswer.isEmpty()) {
return true;
}
// Allow students to view the feedback session
// if there are any questions for instructors to answer
// where the responses of the questions are visible to the students
List<FeedbackQuestionAttributes> questionsWithVisibleResponses = new ArrayList<>();
List<FeedbackQuestionAttributes> questionsForInstructors = fqLogic.getFeedbackQuestionsForCreatorInstructor(session);
for (FeedbackQuestionAttributes question : questionsForInstructors) {
if (frLogic.isResponseOfFeedbackQuestionVisibleToStudent(question)) {
questionsWithVisibleResponses.add(question);
}
}
return session.isVisible() && !questionsWithVisibleResponses.isEmpty();
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes 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;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionResultsSummaryInSectionAsCsv.
public String getFeedbackSessionResultsSummaryInSectionAsCsv(String feedbackSessionName, String courseId, String userEmail, String section, String questionId, boolean isMissingResponsesShown, boolean isStatsShown) throws EntityDoesNotExistException, ExceedingRangeException {
FeedbackSessionResultsBundle results;
int indicatedRange = section == null ? Const.INSTRUCTOR_VIEW_RESPONSE_LIMIT : -1;
if (questionId == null) {
results = getFeedbackSessionResultsForInstructorInSectionWithinRangeFromView(feedbackSessionName, courseId, userEmail, section, indicatedRange, Const.FeedbackSessionResults.GRQ_SORT_TYPE);
} else if (section == null) {
results = getFeedbackSessionResultsForInstructorFromQuestion(feedbackSessionName, courseId, userEmail, questionId);
} else {
results = getFeedbackSessionResultsForInstructorFromQuestionInSection(feedbackSessionName, courseId, userEmail, questionId, section);
}
if (!results.isComplete) {
throw new ExceedingRangeException(ERROR_NUMBER_OF_RESPONSES_EXCEEDS_RANGE);
}
// sort responses by giver > recipient > qnNumber
results.responses.sort(results.compareByGiverRecipientQuestion);
StringBuilder exportBuilder = new StringBuilder(100);
exportBuilder.append(String.format("Course,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getCourseId()))).append(System.lineSeparator()).append(String.format("Session Name,%s", SanitizationHelper.sanitizeForCsv(results.feedbackSession.getFeedbackSessionName()))).append(System.lineSeparator());
if (section != null) {
exportBuilder.append(String.format("Section Name,%s", SanitizationHelper.sanitizeForCsv(section))).append(System.lineSeparator());
}
exportBuilder.append(System.lineSeparator()).append(System.lineSeparator());
Set<Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>>> entrySet = results.getQuestionResponseMap().entrySet();
for (Map.Entry<FeedbackQuestionAttributes, List<FeedbackResponseAttributes>> entry : entrySet) {
exportBuilder.append(getFeedbackSessionResultsForQuestionInCsvFormat(results, entry, isMissingResponsesShown, isStatsShown, section));
}
return exportBuilder.toString();
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogicTest method testCopyFeedbackSession.
private void testCopyFeedbackSession() throws Exception {
______TS("Test copy");
FeedbackSessionAttributes session1InCourse1 = dataBundle.feedbackSessions.get("session1InCourse1");
InstructorAttributes instructor2OfCourse1 = dataBundle.instructors.get("instructor2OfCourse1");
CourseAttributes typicalCourse2 = dataBundle.courses.get("typicalCourse2");
FeedbackSessionAttributes copiedSession = fsLogic.copyFeedbackSession("Copied Session", typicalCourse2.getId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
verifyPresentInDatastore(copiedSession);
assertEquals("Copied Session", copiedSession.getFeedbackSessionName());
assertEquals(typicalCourse2.getId(), copiedSession.getCourseId());
List<FeedbackQuestionAttributes> questions1 = fqLogic.getFeedbackQuestionsForSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId());
List<FeedbackQuestionAttributes> questions2 = fqLogic.getFeedbackQuestionsForSession(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
assertEquals(questions1.size(), questions2.size());
for (int i = 0; i < questions1.size(); i++) {
FeedbackQuestionAttributes question1 = questions1.get(i);
FeedbackQuestionDetails questionDetails1 = question1.getQuestionDetails();
FeedbackQuestionAttributes question2 = questions2.get(i);
FeedbackQuestionDetails questionDetails2 = question2.getQuestionDetails();
assertEquals(questionDetails1.getQuestionText(), questionDetails2.getQuestionText());
assertEquals(question1.giverType, question2.giverType);
assertEquals(question1.recipientType, question2.recipientType);
assertEquals(question1.questionType, question2.questionType);
assertEquals(question1.numberOfEntitiesToGiveFeedbackTo, question2.numberOfEntitiesToGiveFeedbackTo);
}
assertEquals(0, copiedSession.getRespondingInstructorList().size());
assertEquals(0, copiedSession.getRespondingStudentList().size());
______TS("Failure case: duplicate session");
try {
fsLogic.copyFeedbackSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
signalFailureToDetectException();
} catch (EntityAlreadyExistsException e) {
ignoreExpectedException();
}
fsLogic.deleteFeedbackSessionCascade(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
}
Aggregations