use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class CoursesLogic method getCoursesForStudentAccount.
/**
* Returns a list of {@link CourseAttributes} for all courses a given student is enrolled in.
*
* @param googleId The Google ID of the student
*/
public List<CourseAttributes> getCoursesForStudentAccount(String googleId) throws EntityDoesNotExistException {
List<StudentAttributes> studentDataList = studentsLogic.getStudentsForGoogleId(googleId);
if (studentDataList.isEmpty()) {
throw new EntityDoesNotExistException("Student with Google ID " + googleId + " does not exist");
}
List<String> courseIds = new ArrayList<>();
for (StudentAttributes s : studentDataList) {
courseIds.add(s.course);
}
return coursesDb.getCourses(courseIds);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackMsqQuestionDetails method generateOptionList.
private List<String> generateOptionList(String courseId) {
List<String> optionList = new ArrayList<>();
switch(generateOptionsFor) {
case NONE:
optionList = msqChoices;
break;
case STUDENTS:
// fallthrough
case STUDENTS_EXCLUDING_SELF:
List<StudentAttributes> studentList = StudentsLogic.inst().getStudentsForCourse(courseId);
if (generateOptionsFor == FeedbackParticipantType.STUDENTS_EXCLUDING_SELF) {
studentList.removeIf(studentInList -> studentInList.email.equals(studentDoingQuestion.email));
}
for (StudentAttributes student : studentList) {
optionList.add(student.name + " (" + student.team + ")");
}
optionList.sort(null);
break;
case TEAMS:
// fallthrough
case TEAMS_EXCLUDING_SELF:
try {
List<TeamDetailsBundle> teamList = CoursesLogic.inst().getTeamsForCourse(courseId);
if (generateOptionsFor == FeedbackParticipantType.TEAMS_EXCLUDING_SELF) {
teamList.removeIf(teamInList -> teamInList.name.equals(studentDoingQuestion.team));
}
for (TeamDetailsBundle team : teamList) {
optionList.add(team.name);
}
optionList.sort(null);
} catch (EntityDoesNotExistException e) {
Assumption.fail("Course disappeared");
}
break;
case INSTRUCTORS:
List<InstructorAttributes> instructorList = InstructorsLogic.inst().getInstructorsForCourse(courseId);
for (InstructorAttributes instructor : instructorList) {
optionList.add(instructor.name);
}
optionList.sort(null);
break;
default:
Assumption.fail("Trying to generate options for neither students, teams nor instructors");
break;
}
return optionList;
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class FeedbackMcqQuestionDetails method generateOptionList.
private List<String> generateOptionList(String courseId) {
List<String> optionList = new ArrayList<>();
switch(generateOptionsFor) {
case NONE:
optionList = mcqChoices;
break;
case STUDENTS:
// fallthrough
case STUDENTS_EXCLUDING_SELF:
List<StudentAttributes> studentList = StudentsLogic.inst().getStudentsForCourse(courseId);
if (generateOptionsFor == FeedbackParticipantType.STUDENTS_EXCLUDING_SELF) {
studentList.removeIf(studentInList -> studentInList.email.equals(studentDoingQuestion.email));
}
for (StudentAttributes student : studentList) {
optionList.add(student.name + " (" + student.team + ")");
}
optionList.sort(null);
break;
case TEAMS:
// fallthrough
case TEAMS_EXCLUDING_SELF:
try {
List<TeamDetailsBundle> teamList = CoursesLogic.inst().getTeamsForCourse(courseId);
if (generateOptionsFor == FeedbackParticipantType.TEAMS_EXCLUDING_SELF) {
teamList.removeIf(teamInList -> teamInList.name.equals(studentDoingQuestion.team));
}
for (TeamDetailsBundle team : teamList) {
optionList.add(team.name);
}
optionList.sort(null);
} catch (EntityDoesNotExistException e) {
Assumption.fail("Course disappeared");
}
break;
case INSTRUCTORS:
List<InstructorAttributes> instructorList = InstructorsLogic.inst().getInstructorsForCourse(courseId);
for (InstructorAttributes instructor : instructorList) {
optionList.add(instructor.name);
}
optionList.sort(null);
break;
default:
Assumption.fail("Trying to generate options for neither students, teams nor instructors");
break;
}
return optionList;
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class EmailGenerator method generateFeedbackSessionClosedEmails.
/**
* Generates the feedback session closed emails for the given {@code session}.
*/
public List<EmailWrapper> generateFeedbackSessionClosedEmails(FeedbackSessionAttributes session) {
if (session.isPrivateSession()) {
return new ArrayList<>();
}
CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
boolean isEmailNeededForStudents = false;
try {
isEmailNeededForStudents = fsLogic.isFeedbackSessionHasQuestionForStudents(session.getFeedbackSessionName(), session.getCourseId());
} catch (EntityDoesNotExistException e) {
log.severe("Course " + session.getCourseId() + " does not exist or " + "session " + session.getFeedbackSessionName() + " does not exist");
}
List<InstructorAttributes> instructors = instructorsLogic.getInstructorsForCourse(session.getCourseId());
List<StudentAttributes> students = isEmailNeededForStudents ? studentsLogic.getStudentsForCourse(session.getCourseId()) : new ArrayList<StudentAttributes>();
String template = EmailTemplates.USER_FEEDBACK_SESSION.replace("${status}", FEEDBACK_STATUS_SESSION_CLOSED);
String additionalContactInformation = getAdditionalContactInformationFragment(course);
return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_CLOSED.getSubject(), FEEDBACK_ACTION_VIEW, additionalContactInformation);
}
use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.
the class EmailGenerator method generateFeedbackSessionClosingEmails.
/**
* Generates the feedback session closing emails for the given {@code session}.
*/
public List<EmailWrapper> generateFeedbackSessionClosingEmails(FeedbackSessionAttributes session) {
List<StudentAttributes> students = new ArrayList<>();
boolean isEmailNeeded = fsLogic.isFeedbackSessionForStudentsToAnswer(session);
if (isEmailNeeded) {
List<StudentAttributes> studentsForCourse = studentsLogic.getStudentsForCourse(session.getCourseId());
for (StudentAttributes student : studentsForCourse) {
try {
if (!fsLogic.isFeedbackSessionFullyCompletedByStudent(session.getFeedbackSessionName(), session.getCourseId(), student.email)) {
students.add(student);
}
} catch (EntityDoesNotExistException e) {
log.severe("Course " + session.getCourseId() + " does not exist or " + "session " + session.getFeedbackSessionName() + " does not exist");
// Do not waste time looping through all students
break;
}
}
}
String template = EmailTemplates.USER_FEEDBACK_SESSION.replace("${status}", FEEDBACK_STATUS_SESSION_CLOSING);
CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
List<InstructorAttributes> instructors = isEmailNeeded ? instructorsLogic.getInstructorsForCourse(session.getCourseId()) : new ArrayList<InstructorAttributes>();
String additionalContactInformation = HTML_NO_ACTION_REQUIRED + getAdditionalContactInformationFragment(course);
return generateFeedbackSessionEmailBases(course, session, students, instructors, template, EmailType.FEEDBACK_CLOSING.getSubject(), FEEDBACK_ACTION_SUBMIT, additionalContactInformation);
}
Aggregations