use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.
the class StudentsLogic method getTeamDetailsForStudent.
public TeamDetailsBundle getTeamDetailsForStudent(StudentAttributes student) {
if (student != null) {
TeamDetailsBundle teamResult = new TeamDetailsBundle();
teamResult.name = student.team;
teamResult.students = getStudentsForTeam(student.team, student.course);
StudentAttributes.sortByNameAndThenByEmail(teamResult.students);
return teamResult;
}
return null;
}
use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.
the class StudentsLogicTest method testGetTeamForStudent.
/*
* NOTE: enrollStudents() tested in SubmissionsAdjustmentTest.
* This is because it uses Task Queues for scheduling and therefore has to be
* tested in a separate class.
*/
private void testGetTeamForStudent() {
______TS("Typical case: get team of existing student");
String courseId = "idOfTypicalCourse1";
String googleId = "student1InCourse1";
StudentAttributes student = StudentsLogic.inst().getStudentForCourseIdAndGoogleId(courseId, googleId);
TeamDetailsBundle team = StudentsLogic.inst().getTeamDetailsForStudent(student);
assertEquals("Team 1.1</td></div>'\"", team.name);
assertNotNull(team.students);
assertEquals(4, team.students.size());
______TS("Typical case: get team of non-existing student");
courseId = "idOfTypicalCourse1";
googleId = "idOfNonExistingStudent";
student = StudentsLogic.inst().getStudentForCourseIdAndGoogleId(courseId, googleId);
team = StudentsLogic.inst().getTeamDetailsForStudent(student);
assertNull(team);
}
use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.
the class CoursesLogicTest method testGetTeamsForCourse.
private void testGetTeamsForCourse() throws Exception {
______TS("typical case");
CourseAttributes course = dataBundle.courses.get("typicalCourse1");
List<TeamDetailsBundle> teams = coursesLogic.getTeamsForCourse(course.getId());
assertEquals(2, teams.size());
assertEquals("Team 1.1</td></div>'\"", teams.get(0).name);
assertEquals("Team 1.2", teams.get(1).name);
______TS("course without students");
StudentProfileAttributes spa = StudentProfileAttributes.builder("instructor1").build();
AccountsLogic.inst().createAccount(AccountAttributes.builder().withGoogleId("instructor1").withName("Instructor 1").withEmail("instructor@email.tmt").withInstitute("TEAMMATES Test Institute 1").withIsInstructor(true).withStudentProfileAttributes(spa).build());
coursesLogic.createCourseAndInstructor("instructor1", "course1", "course 1", "UTC");
teams = coursesLogic.getTeamsForCourse("course1");
assertEquals(0, teams.size());
coursesLogic.deleteCourseCascade("course1");
accountsDb.deleteAccount("instructor1");
______TS("non-existent");
try {
coursesLogic.getTeamsForCourse("non-existent-course");
signalFailureToDetectException();
} catch (EntityDoesNotExistException e) {
AssertHelper.assertContains("does not exist", e.getMessage());
}
______TS("null parameter");
try {
coursesLogic.getTeamsForCourse(null);
signalFailureToDetectException();
} catch (AssertionError e) {
assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getMessage());
}
}
use of teammates.common.datatransfer.TeamDetailsBundle in project teammates by TEAMMATES.
the class CoursesLogic method getSectionsForCourseWithoutStats.
/**
* Returns a list of {@link SectionDetailsBundle} for a given course using courseId.
*/
public List<SectionDetailsBundle> getSectionsForCourseWithoutStats(String courseId) throws EntityDoesNotExistException {
verifyCourseIsPresent(courseId);
List<StudentAttributes> students = studentsLogic.getStudentsForCourse(courseId);
StudentAttributes.sortBySectionName(students);
List<SectionDetailsBundle> sections = new ArrayList<>();
SectionDetailsBundle section = null;
int teamIndexWithinSection = 0;
for (int i = 0; i < students.size(); i++) {
StudentAttributes s = students.get(i);
if (section == null) {
// First student of first section
section = new SectionDetailsBundle();
section.name = s.section;
section.teams.add(new TeamDetailsBundle());
section.teams.get(teamIndexWithinSection).name = s.team;
section.teams.get(teamIndexWithinSection).students.add(s);
} else if (s.section.equals(section.name)) {
if (s.team.equals(section.teams.get(teamIndexWithinSection).name)) {
section.teams.get(teamIndexWithinSection).students.add(s);
} else {
teamIndexWithinSection++;
section.teams.add(new TeamDetailsBundle());
section.teams.get(teamIndexWithinSection).name = s.team;
section.teams.get(teamIndexWithinSection).students.add(s);
}
} else {
// first student of subsequent section
sections.add(section);
teamIndexWithinSection = 0;
section = new SectionDetailsBundle();
section.name = s.section;
section.teams.add(new TeamDetailsBundle());
section.teams.get(teamIndexWithinSection).name = s.team;
section.teams.get(teamIndexWithinSection).students.add(s);
}
boolean isLastStudent = i == students.size() - 1;
if (isLastStudent) {
sections.add(section);
}
}
return sections;
}
use of teammates.common.datatransfer.TeamDetailsBundle 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;
}
Aggregations