Search in sources :

Example 6 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class InstructorStudentRecordsPageActionTest method createStudentInTypicalDataBundleForCourseWithNoSession.

private StudentAttributes createStudentInTypicalDataBundleForCourseWithNoSession() throws EntityAlreadyExistsException, InvalidParametersException, EntityDoesNotExistException {
    StudentAttributes student = StudentAttributes.builder("idOfCourseNoEvals", "nameOfStudent", "emailTemp@gmail.tmt").withSection("section").withTeam("team").withComments("No comment").build();
    logic.createStudentWithoutDocument(student);
    return student;
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 7 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class StudentCourseDetailsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    String idOfCourseOfStudent = student1InCourse1.course;
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, idOfCourseOfStudent };
    ______TS("Invalid parameters");
    // parameters missing.
    verifyAssumptionFailure(new String[] {});
    ______TS("Typical case, student in the same course");
    StudentCourseDetailsPageAction pageAction = getAction(submissionParams);
    ShowPageResult pageResult = getShowPageResult(pageAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_COURSE_DETAILS, false, "student1InCourse1"), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    StudentCourseDetailsPageData pageData = (StudentCourseDetailsPageData) pageResult.data;
    assertEquals(student1InCourse1.course, pageData.getStudentCourseDetailsPanel().getCourseId());
    assertEquals(student1InCourse1.googleId, pageData.account.googleId);
    assertEquals(student1InCourse1.getIdentificationString(), pageData.student.getIdentificationString());
    assertEquals(student1InCourse1.team, pageData.getStudentCourseDetailsPanel().getStudentTeam());
    List<StudentAttributes> expectedStudentsList = StudentsLogic.inst().getStudentsForTeam(student1InCourse1.team, student1InCourse1.course);
    List<StudentAttributes> actualStudentsList = pageData.getStudentCourseDetailsPanel().getTeammates();
    AssertHelper.assertSameContentIgnoreOrder(expectedStudentsList, actualStudentsList);
    // assertEquals(StudentsLogic.inst().getStudentsForTeam(student1InCourse1.team, student1InCourse1), pageData.);
    // above comparison method failed, so use the one below
    List<InstructorAttributes> expectedInstructorsList = InstructorsLogic.inst().getInstructorsForCourse(student1InCourse1.course);
    List<InstructorAttributes> actualInstructorsList = pageData.getStudentCourseDetailsPanel().getInstructors();
    AssertHelper.assertSameContentIgnoreOrder(expectedInstructorsList, actualInstructorsList);
    String expectedLogMessage = "TEAMMATESLOG|||studentCourseDetailsPage|||studentCourseDetailsPage|||true|||" + "Student|||Student 1 in course 1|||student1InCourse1|||" + "student1InCourse1@gmail.tmt|||studentCourseDetails Page Load<br>" + "Viewing team details for <span class=\"bold\">[idOfTypicalCourse1] " + "Typical Course 1 with 2 Evals</span>|||/page/studentCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
    ______TS("Typical case, the student is not in the course");
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, "idOfTypicalCourse2" };
    StudentCourseDetailsPageAction redirectAction = getAction(submissionParams);
    RedirectResult redirectResult = this.getRedirectResult(redirectAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, true, "student1InCourse1"), redirectResult.getDestinationWithParams());
    assertTrue(redirectResult.isError);
    assertEquals("You are not registered in the course idOfTypicalCourse2", redirectResult.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||studentCourseDetailsPage|||studentCourseDetailsPage|||true|||" + "Student|||Student 1 in course 1|||student1InCourse1|||" + "student1InCourse1@gmail.tmt|||studentCourseDetails Page Load<br>" + "Viewing team details for <span class=\"bold\">[idOfTypicalCourse1] " + "Typical Course 1 with 2 Evals</span>|||/page/studentCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
    ______TS("Typical case, student contains data requiring sanitization");
    StudentAttributes studentTestingSanitization = typicalBundle.students.get("student1InTestingSanitizationCourse");
    gaeSimulation.loginAsStudent(studentTestingSanitization.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, studentTestingSanitization.course };
    pageAction = getAction(submissionParams);
    pageResult = getShowPageResult(pageAction);
    assertEquals(Const.ViewURIs.STUDENT_COURSE_DETAILS + "?error=false&user=" + studentTestingSanitization.googleId, pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals("", pageResult.getStatusMessage());
    expectedLogMessage = "TEAMMATESLOG|||studentCourseDetailsPage|||studentCourseDetailsPage|||true|||" + "Student|||" + SanitizationHelper.sanitizeForHtml("Stud1<script> alert('hi!'); </script>") + "|||student1InTestingSanitizationCourse|||" + "normal@sanitization.tmt|||studentCourseDetails Page Load<br>" + "Viewing team details for <span class=\"bold\">[idOfTestingSanitizationCourse] " + SanitizationHelper.sanitizeForHtml("Testing<script> alert('hi!'); </script>") + "</span>|||/page/studentCourseDetailsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, pageAction.getLogMessage());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) RedirectResult(teammates.ui.controller.RedirectResult) StudentCourseDetailsPageData(teammates.ui.pagedata.StudentCourseDetailsPageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentCourseDetailsPageAction(teammates.ui.controller.StudentCourseDetailsPageAction) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 8 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class StudentCourseJoinActionLegacyTest method testAccessControl.

@Test
@Override
protected void testAccessControl() throws Exception {
    StudentAttributes unregStudent1 = typicalBundle.students.get("student2InUnregisteredCourse");
    String key = StudentsLogic.inst().getStudentForEmail(unregStudent1.course, unregStudent1.email).key;
    String[] submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(key) };
    verifyAccessibleWithoutLogin(submissionParams);
    verifyAccessibleForUnregisteredUsers(submissionParams);
    verifyAccessibleForStudents(submissionParams);
    verifyAccessibleForInstructorsOfOtherCourses(submissionParams);
    verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 9 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class StudentCourseJoinActionTest method testAccessControl.

@Override
@Test
protected void testAccessControl() throws Exception {
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, typicalBundle.courses.get("typicalCourse1").getId() };
    verifyAccessibleWithoutLogin(submissionParams);
    StudentAttributes unregStudent1 = typicalBundle.students.get("student1InUnregisteredCourse");
    String key = StudentsLogic.inst().getStudentForEmail(unregStudent1.course, unregStudent1.email).key;
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(key), Const.ParamsNames.COURSE_ID, unregStudent1.course, Const.ParamsNames.STUDENT_EMAIL, unregStudent1.email };
    verifyAccessibleForUnregisteredUsers(submissionParams);
    verifyAccessibleForStudents(submissionParams);
    verifyAccessibleForInstructorsOfOtherCourses(submissionParams);
    verifyAccessibleForAdminToMasqueradeAsInstructor(submissionParams);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 10 with StudentAttributes

use of teammates.common.datatransfer.attributes.StudentAttributes in project teammates by TEAMMATES.

the class StudentCourseJoinActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    StudentCourseJoinAction joinAction;
    RedirectResult redirectResult;
    String[] submissionParams;
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    StudentsDb studentsDb = new StudentsDb();
    student1InCourse1 = studentsDb.getStudentForGoogleId(student1InCourse1.course, student1InCourse1.googleId);
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    ______TS("not enough parameters");
    verifyAssumptionFailure();
    ______TS("typical case");
    String idOfNewStudent = "idOfNewStudent";
    StudentAttributes newStudentData = StudentAttributes.builder(student1InCourse1.course, "nameOfNewStudent", "newStudent@course1.com").withSection(student1InCourse1.section).withTeam(student1InCourse1.team).withComments("This is a new student").build();
    studentsDb.createEntity(newStudentData);
    gaeSimulation.loginUser(idOfNewStudent);
    String newStudentKey = StringHelper.encrypt(studentsDb.getStudentForEmail(newStudentData.course, newStudentData.email).key);
    /*
         * Reason why get student attributes for student just added again from
         * StudentsDb:below test needs the student's key, which is auto
         * generated when creating the student instance.So the reg key needs to
         * be obtained by calling the getter from logic to retrieve again
         */
    submissionParams = new String[] { Const.ParamsNames.REGKEY, newStudentKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE };
    joinAction = getAction(submissionParams);
    ShowPageResult pageResult = getShowPageResult(joinAction);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_COURSE_JOIN_CONFIRMATION, false, idOfNewStudent), pageResult.getDestinationWithParams());
    assertFalse(pageResult.isError);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_COURSE_JOIN_AUTHENTICATED, newStudentKey, Const.ActionURIs.STUDENT_PROFILE_PAGE), ((StudentCourseJoinConfirmationPageData) pageResult.data).getConfirmUrl());
    assertEquals("", pageResult.getStatusMessage());
    ______TS("skip confirmation");
    gaeSimulation.logoutUser();
    submissionParams = new String[] { Const.ParamsNames.REGKEY, newStudentKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE, Const.ParamsNames.STUDENT_EMAIL, newStudentData.email, Const.ParamsNames.COURSE_ID, newStudentData.course };
    joinAction = getAction(submissionParams);
    redirectResult = getRedirectResult(joinAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_COURSE_JOIN_AUTHENTICATED, newStudentKey, Const.ActionURIs.STUDENT_PROFILE_PAGE.replace("/", "%2F"), false), redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    // delete the new student
    studentsDb.deleteStudentWithoutDocument(newStudentData.course, newStudentData.email);
    ______TS("Non-existent student attempting to join course displays error");
    gaeSimulation.loginUser(idOfNewStudent);
    submissionParams = new String[] { Const.ParamsNames.REGKEY, newStudentKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE, Const.ParamsNames.STUDENT_EMAIL, newStudentData.email, Const.ParamsNames.COURSE_ID, newStudentData.course };
    joinAction = getAction(submissionParams);
    redirectResult = getRedirectResult(joinAction);
    assertEquals(Const.ActionURIs.STUDENT_HOME_PAGE, redirectResult.destination);
    assertEquals(String.format(Const.StatusMessages.NON_EXISTENT_STUDENT_ATTEMPTING_TO_JOIN_COURSE, newStudentData.course), redirectResult.getStatusMessage());
    assertEquals("warning", redirectResult.getStatusMessageColor());
    assertTrue(redirectResult.isError);
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) RedirectResult(teammates.ui.controller.RedirectResult) StudentCourseJoinAction(teammates.ui.controller.StudentCourseJoinAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) StudentsDb(teammates.storage.api.StudentsDb) Test(org.testng.annotations.Test)

Aggregations

StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)241 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)85 Test (org.testng.annotations.Test)80 ArrayList (java.util.ArrayList)55 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)33 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)33 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)27 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)22 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)17 ShowPageResult (teammates.ui.controller.ShowPageResult)15 HashMap (java.util.HashMap)14 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)14 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 EmailWrapper (teammates.common.util.EmailWrapper)13 RedirectResult (teammates.ui.controller.RedirectResult)12 List (java.util.List)11 StatusMessage (teammates.common.util.StatusMessage)10 HashSet (java.util.HashSet)9 StudentEnrollDetails (teammates.common.datatransfer.StudentEnrollDetails)9