Search in sources :

Example 1 with InstructorStudentListAjaxPageData

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());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorStudentListAjaxPageData(teammates.ui.pagedata.InstructorStudentListAjaxPageData) InstructorStudentListAjaxPageAction(teammates.ui.controller.InstructorStudentListAjaxPageAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 2 with InstructorStudentListAjaxPageData

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);
}
Also used : TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructorStudentListAjaxPageData(teammates.ui.pagedata.InstructorStudentListAjaxPageData) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle)

Example 3 with InstructorStudentListAjaxPageData

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);
}
Also used : HashMap(java.util.HashMap) InstructorStudentListAjaxPageData(teammates.ui.pagedata.InstructorStudentListAjaxPageData) SectionDetailsBundle(teammates.common.datatransfer.SectionDetailsBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) TeamDetailsBundle(teammates.common.datatransfer.TeamDetailsBundle) HashMap(java.util.HashMap) Map(java.util.Map) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

InstructorStudentListAjaxPageData (teammates.ui.pagedata.InstructorStudentListAjaxPageData)3 HashMap (java.util.HashMap)2 SectionDetailsBundle (teammates.common.datatransfer.SectionDetailsBundle)2 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)2 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)1 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)1 InstructorStudentListAjaxPageAction (teammates.ui.controller.InstructorStudentListAjaxPageAction)1 ShowPageResult (teammates.ui.controller.ShowPageResult)1