use of teammates.ui.pagedata.InstructorStudentListAjaxPageData in project teammates by TEAMMATES.
the class InstructorStudentListAjaxPageActionTest method testExecuteAndPostProcess.
@Override
@Test
public void testExecuteAndPostProcess() {
InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
String instructorId = instructor.googleId;
gaeSimulation.loginAsInstructor(instructorId);
______TS("Unsuccessful case: not enough parameters");
verifyAssumptionFailure();
String[] submissionParams = new String[] {};
verifyAssumptionFailure(submissionParams);
______TS("typical successful case");
submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.COURSE_INDEX, "1" };
InstructorStudentListAjaxPageAction action = getAction(submissionParams);
ShowPageResult result = getShowPageResult(action);
InstructorStudentListAjaxPageData data = (InstructorStudentListAjaxPageData) result.data;
assertEquals(2, data.getSections().size());
assertTrue(data.isHasSection());
assertEquals(1, data.getCourseIndex());
assertEquals(instructor.courseId, data.getCourseId());
}
use of teammates.ui.pagedata.InstructorStudentListAjaxPageData in project teammates by TEAMMATES.
the class InstructorStudentListAjaxPageDataTest method initializeData.
private InstructorStudentListAjaxPageData initializeData() {
photoUrl = "validPhotoUrl";
acct = AccountAttributes.builder().withGoogleId(// only googleId is needed
"valid.id").build();
sampleStudent = StudentAttributes.builder("valid course", "1+1@email.com", "<script>alert(\"Valid name\");</script>").build();
sampleTeam = new TeamDetailsBundle();
sampleTeam.students.add(sampleStudent);
sampleTeam.name = "valid team name >.<";
sampleSection = new SectionDetailsBundle();
sampleSection.teams.add(sampleTeam);
sampleSection.name = "<valid section name>";
List<SectionDetailsBundle> sections = new ArrayList<>();
sections.add(sampleSection);
sectionPrivileges = new HashMap<>();
Map<String, Boolean> sectionPrivilege = new HashMap<>();
sectionPrivilege.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS, true);
sectionPrivilege.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, false);
sectionPrivileges.put(sampleSection.name, sectionPrivilege);
Map<String, String> emailPhotoUrlMapping = new HashMap<>();
emailPhotoUrlMapping.put(sampleStudent.email, photoUrl);
return new InstructorStudentListAjaxPageData(acct, dummySessionToken, "valid course id", 1, true, sections, sectionPrivileges, emailPhotoUrlMapping);
}
use of teammates.ui.pagedata.InstructorStudentListAjaxPageData in project teammates by TEAMMATES.
the class InstructorStudentListAjaxPageAction method execute.
@Override
protected ActionResult execute() throws EntityDoesNotExistException {
String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
String courseIndexString = getRequestParamValue(Const.ParamsNames.COURSE_INDEX);
Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_INDEX, courseIndexString);
gateKeeper.verifyInstructorPrivileges(account);
InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
CourseAttributes course = logic.getCourse(courseId);
gateKeeper.verifyAccessible(instructor, course);
List<SectionDetailsBundle> courseSectionDetails = logic.getSectionsForCourse(courseId);
int courseIndex = Integer.parseInt(courseIndexString);
boolean hasSection = logic.hasIndicatedSections(courseId);
Map<String, String> emailPhotoUrlMapping = new HashMap<>();
Map<String, Map<String, Boolean>> sectionPrivileges = new HashMap<>();
for (SectionDetailsBundle sectionDetails : courseSectionDetails) {
for (TeamDetailsBundle teamDetails : sectionDetails.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);
}
}
Map<String, Boolean> sectionPrivilege = new HashMap<>();
sectionPrivilege.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS, instructor.isAllowedForPrivilege(sectionDetails.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
sectionPrivilege.put(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT, instructor.isAllowedForPrivilege(sectionDetails.name, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
sectionPrivileges.put(sectionDetails.name, sectionPrivilege);
}
InstructorStudentListAjaxPageData data = new InstructorStudentListAjaxPageData(account, sessionToken, courseId, courseIndex, hasSection, courseSectionDetails, sectionPrivileges, emailPhotoUrlMapping);
return createShowPageResult(Const.ViewURIs.INSTRUCTOR_STUDENT_LIST_AJAX, data);
}
Aggregations