Skip to content

Commit

Permalink
[TEAMMATES#11737] Change way of getting giver set in FeedbackResponse…
Browse files Browse the repository at this point in the history
…sLogic
  • Loading branch information
u6656793 committed Oct 28, 2022
1 parent 1119391 commit 6fc23b1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ void initLogicDependencies() {
* Gets a set of giver identifiers that has at least one response under a feedback session.
*/
public Set<String> getGiverSetThatAnswerFeedbackSession(String courseId, String feedbackSessionName) {
return frDb.getGiverSetThatAnswerFeedbackSession(courseId, feedbackSessionName);
Set<String> giverSet = frDb.getGiverSetThatAnswerFeedbackSession(courseId, feedbackSessionName);
List<String> instructorSet = instructorsLogic.getInstructorEmailsForCourse(courseId);
if (!fqLogic.sessionHasQuestionsForGiverType(feedbackSessionName,courseId,FeedbackParticipantType.INSTRUCTORS)) {
giverSet.addAll(instructorSet);
}
return giverSet;
}

/**
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/teammates/logic/core/FeedbackSessionsLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,19 @@ public boolean isFeedbackSessionAttemptedByStudent(FeedbackSessionAttributes fsa
* <p>If there is no question for instructors, the feedback session is considered as attempted.</p>
*/
public boolean isFeedbackSessionAttemptedByInstructor(FeedbackSessionAttributes fsa, String userEmail) {
if (frLogic.hasGiverRespondedForSession(userEmail, fsa.getFeedbackSessionName(), fsa.getCourseId())) {
String fbSN = fsa.getFeedbackSessionName();
String courseId = fsa.getCourseId();
if (frLogic.hasGiverRespondedForSession(userEmail, fbSN, courseId)) {
return true;
}

// if there is no question for instructor, session is attempted
// return !fqLogic.hasFeedbackQuestionsForInstructors(fsa, fsa.isCreator(userEmail));
fqLogic.hasFeedbackQuestionsForInstructors(fsa,fsa.isCreator(userEmail));
return !fqLogic.sessionHasQuestionsForGiverType(fsa.getFeedbackSessionName(),fsa.getCourseId(),FeedbackParticipantType.INSTRUCTORS)
|| !fqLogic.sessionHasQuestionsForGiverType(fsa.getFeedbackSessionName(),fsa.getCourseId(),FeedbackParticipantType.SELF);
// return !fqLogic.hasFeedbackQuestionsForInstructors(fsa, fsa.isCreator(userEmail));
if (fqLogic.sessionHasQuestionsForGiverType(fbSN, courseId, FeedbackParticipantType.GIVER)) {
return true;
}
fqLogic.hasFeedbackQuestionsForInstructors(fsa, fsa.isCreator(userEmail));
return !fqLogic.sessionHasQuestionsForGiverType(fbSN, courseId, FeedbackParticipantType.INSTRUCTORS);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/teammates/storage/api/FeedbackQuestionsDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ private List<FeedbackQuestion> getFeedbackQuestionEntitiesForGiverType(

private boolean hasFeedbackQuestionEntitiesForGiverType(
String feedbackSessionName, String courseId, FeedbackParticipantType giverType) {
return load()
return !load()
.filter("feedbackSessionName =", feedbackSessionName)
.filter("courseId =", courseId)
.filter("giverType =", giverType)
.keys()
.list()
.size() != 0;
.list().isEmpty();
//.size() != 0
}

@Override
Expand Down

0 comments on commit 6fc23b1

Please sign in to comment.