use of teammates.ui.template.StudentListSectionData in project teammates by TEAMMATES.
the class InstructorSearchPageData method createStudentRows.
private List<StudentListSectionData> createStudentRows(String courseId, StudentSearchResultBundle studentSearchResultBundle) {
List<StudentListSectionData> rows = new ArrayList<>();
List<StudentAttributes> studentsInCourse = filterStudentsByCourse(courseId, studentSearchResultBundle);
Map<String, Set<String>> sectionNameToTeamNameMap = new HashMap<>();
Map<String, List<StudentAttributes>> teamNameToStudentsMap = new HashMap<>();
Map<String, String> emailToPhotoUrlMap = new HashMap<>();
for (StudentAttributes student : studentsInCourse) {
String teamName = student.team;
String sectionName = student.section;
String viewPhotoLink = addUserIdToUrl(student.getPublicProfilePictureUrl());
emailToPhotoUrlMap.put(student.email, viewPhotoLink);
teamNameToStudentsMap.computeIfAbsent(teamName, key -> new ArrayList<>()).add(student);
sectionNameToTeamNameMap.computeIfAbsent(sectionName, key -> new HashSet<>()).add(teamName);
}
List<SectionDetailsBundle> sections = new ArrayList<>();
sectionNameToTeamNameMap.forEach((sectionName, teamNameList) -> {
SectionDetailsBundle sdb = new SectionDetailsBundle();
sdb.name = sectionName;
ArrayList<TeamDetailsBundle> teams = new ArrayList<>();
for (String teamName : teamNameList) {
TeamDetailsBundle tdb = new TeamDetailsBundle();
tdb.name = teamName;
tdb.students = teamNameToStudentsMap.get(teamName);
teams.add(tdb);
}
sdb.teams = teams;
sections.add(sdb);
});
for (SectionDetailsBundle section : sections) {
InstructorAttributes instructor = studentSearchResultBundle.courseIdInstructorMap.get(courseId);
boolean isAllowedToViewStudentInSection = instructor.isAllowedForPrivilege(section.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
boolean isAllowedToModifyStudent = instructor.isAllowedForPrivilege(section.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
rows.add(new StudentListSectionData(section, isAllowedToViewStudentInSection, isAllowedToModifyStudent, emailToPhotoUrlMap, account.googleId, getSessionToken()));
}
return rows;
}
use of teammates.ui.template.StudentListSectionData in project teammates by TEAMMATES.
the class InstructorCourseDetailsPageData method init.
public void init(InstructorAttributes currentInstructor, CourseDetailsBundle courseDetails, List<InstructorAttributes> instructors) {
this.currentInstructor = currentInstructor;
this.courseDetails = courseDetails;
this.instructors = instructors;
boolean isDisabled = !currentInstructor.isAllowedForPrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
String courseId = sanitizeForJs(courseDetails.course.getId());
String href = sanitizeForJs(getInstructorCourseRemindLink(courseDetails.course.getId()));
courseRemindButton = createButton(null, "btn btn-primary", "button_remind", href, Const.Tooltips.COURSE_REMIND, "tooltip", courseId, isDisabled);
String hrefDeleteStudents = sanitizeForJs(getInstructorCourseStudentDeleteAllLink(courseId));
courseDeleteAllButton = createButton(null, "btn btn-danger course-student-delete-all-link", "button-delete-all", hrefDeleteStudents, null, null, courseId, isDisabled);
this.sections = new ArrayList<>();
for (SectionDetailsBundle section : courseDetails.sections) {
Map<String, String> emailPhotoUrlMapping = new HashMap<>();
for (TeamDetailsBundle teamDetails : section.teams) {
for (StudentAttributes student : teamDetails.students) {
String studentPhotoUrl = student.getPublicProfilePictureUrl();
studentPhotoUrl = Url.addParamToUrl(studentPhotoUrl, Const.ParamsNames.USER_ID, account.googleId);
emailPhotoUrlMapping.put(student.email, studentPhotoUrl);
}
}
boolean isAllowedToViewStudentInSection = currentInstructor.isAllowedForPrivilege(section.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS);
boolean isAllowedToModifyStudent = currentInstructor.isAllowedForPrivilege(section.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
this.sections.add(new StudentListSectionData(section, isAllowedToViewStudentInSection, isAllowedToModifyStudent, emailPhotoUrlMapping, account.googleId, getSessionToken()));
}
if (sections.size() == 1) {
StudentListSectionData section = sections.get(0);
this.hasSection = !"None".equals(section.getSectionName());
} else {
this.hasSection = true;
}
}
Aggregations