use of teammates.common.datatransfer.FeedbackSessionDetailsBundle in project teammates by TEAMMATES.
the class CoursesLogic method getCourseDetailsListForStudent.
/**
* Returns a list of {@link CourseDetailsBundle} for all
* courses a given student is enrolled in.
*
* @param googleId The Google ID of the student
*/
public List<CourseDetailsBundle> getCourseDetailsListForStudent(String googleId) throws EntityDoesNotExistException {
List<CourseAttributes> courseList = getCoursesForStudentAccount(googleId);
CourseAttributes.sortById(courseList);
List<CourseDetailsBundle> courseDetailsList = new ArrayList<>();
for (CourseAttributes c : courseList) {
StudentAttributes s = studentsLogic.getStudentForCourseIdAndGoogleId(c.getId(), googleId);
if (s == null) {
// TODO Remove excessive logging after the reason why s can be null is found
StringBuilder logMsgBuilder = new StringBuilder();
String logMsg = "Student is null in CoursesLogic.getCourseDetailsListForStudent(String googleId)" + "<br> Student Google ID: " + googleId + "<br> Course: " + c.getId() + "<br> All Courses Retrieved using the Google ID:";
logMsgBuilder.append(logMsg);
for (CourseAttributes course : courseList) {
logMsgBuilder.append("<br>").append(course.getId());
}
log.severe(logMsgBuilder.toString());
// TODO Failing might not be the best course of action here.
// Maybe throw a custom exception and tell user to wait due to eventual consistency?
Assumption.fail("Student should not be null at this point.");
}
// Skip the course existence check since the course ID is obtained from a
// valid CourseAttributes resulting from query
List<FeedbackSessionAttributes> feedbackSessionList = feedbackSessionsLogic.getFeedbackSessionsForUserInCourseSkipCheck(c.getId(), s.email);
CourseDetailsBundle cdd = new CourseDetailsBundle(c);
for (FeedbackSessionAttributes fs : feedbackSessionList) {
cdd.feedbackSessions.add(new FeedbackSessionDetailsBundle(fs));
}
courseDetailsList.add(cdd);
}
return courseDetailsList;
}
use of teammates.common.datatransfer.FeedbackSessionDetailsBundle in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionDetails.
public FeedbackSessionDetailsBundle getFeedbackSessionDetails(FeedbackSessionAttributes fsa) throws EntityDoesNotExistException {
FeedbackSessionDetailsBundle details = new FeedbackSessionDetailsBundle(fsa);
details.stats.expectedTotal = 0;
details.stats.submittedTotal = 0;
switch(fsa.getFeedbackSessionType()) {
case STANDARD:
List<StudentAttributes> students = studentsLogic.getStudentsForCourse(fsa.getCourseId());
List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(fsa.getCourseId());
List<FeedbackQuestionAttributes> questions = fqLogic.getFeedbackQuestionsForSession(fsa.getFeedbackSessionName(), fsa.getCourseId());
List<FeedbackQuestionAttributes> studentQns = fqLogic.getFeedbackQuestionsForStudents(questions);
if (!studentQns.isEmpty()) {
details.stats.expectedTotal += students.size();
}
for (InstructorAttributes instructor : instructors) {
List<FeedbackQuestionAttributes> instructorQns = fqLogic.getFeedbackQuestionsForInstructor(questions, fsa.isCreator(instructor.email));
if (!instructorQns.isEmpty()) {
details.stats.expectedTotal += 1;
}
}
details.stats.submittedTotal += fsa.getRespondingStudentList().size() + fsa.getRespondingInstructorList().size();
break;
case PRIVATE:
List<FeedbackQuestionAttributes> instructorQuestions = fqLogic.getFeedbackQuestionsForInstructor(fsa.getFeedbackSessionName(), fsa.getCourseId(), fsa.getCreatorEmail());
List<FeedbackQuestionAttributes> validQuestions = fqLogic.getQuestionsWithRecipients(instructorQuestions, fsa.getCreatorEmail());
if (validQuestions.isEmpty()) {
break;
}
details.stats.expectedTotal = 1;
if (isFeedbackSessionFullyCompletedByInstructor(fsa.getFeedbackSessionName(), fsa.getCourseId(), fsa.getCreatorEmail())) {
details.stats.submittedTotal = 1;
}
break;
default:
break;
}
return details;
}
use of teammates.common.datatransfer.FeedbackSessionDetailsBundle in project teammates by TEAMMATES.
the class StudentHomePageAction method generateFeedbackSessionSubmissionStatusMap.
private Map<FeedbackSessionAttributes, Boolean> generateFeedbackSessionSubmissionStatusMap(List<CourseDetailsBundle> courses, String googleId) {
Map<FeedbackSessionAttributes, Boolean> returnValue = new HashMap<>();
for (CourseDetailsBundle c : courses) {
for (FeedbackSessionDetailsBundle fsb : c.feedbackSessions) {
FeedbackSessionAttributes f = fsb.feedbackSession;
returnValue.put(f, getStudentStatusForSession(f, googleId));
}
}
return returnValue;
}
Aggregations