Search in sources :

Example 11 with StudentAttributes

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

the class StudentCourseJoinAuthenticatedActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    dataBundle = loadDataBundle("/StudentCourseJoinAuthenticatedTest.json");
    StudentsDb studentsDb = new StudentsDb();
    AccountsDb accountsDb = new AccountsDb();
    StudentAttributes student1InCourse1 = dataBundle.students.get("student1InCourse1");
    student1InCourse1 = studentsDb.getStudentForGoogleId(student1InCourse1.course, student1InCourse1.googleId);
    gaeSimulation.loginAsStudent(student1InCourse1.googleId);
    ______TS("not enough parameters");
    verifyAssumptionFailure();
    ______TS("invalid key");
    String invalidKey = StringHelper.encrypt("invalid key");
    String[] submissionParams = new String[] { Const.ParamsNames.REGKEY, invalidKey, Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_HOME_PAGE };
    try {
        StudentCourseJoinAuthenticatedAction authenticatedAction = getAction(submissionParams);
        getRedirectResult(authenticatedAction);
    } catch (UnauthorizedAccessException uae) {
        assertEquals("No student with given registration key:" + invalidKey, uae.getMessage());
    }
    ______TS("already registered student");
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(student1InCourse1.key), Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE };
    StudentCourseJoinAuthenticatedAction authenticatedAction = getAction(submissionParams);
    RedirectResult redirectResult = getRedirectResult(authenticatedAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, true, student1InCourse1.googleId), redirectResult.getDestinationWithParams());
    assertTrue(redirectResult.isError);
    assertEquals("You (student1InCourse1) have already joined this course", redirectResult.getStatusMessage());
    /*______TS("student object belongs to another account");

        StudentAttributes student2InCourse1 = dataBundle.students
                .get("student2InCourse1");
        student2InCourse1 = studentsDb.getStudentForGoogleId(
                student2InCourse1.course, student2InCourse1.googleId);

        submissionParams = new String[] {
                Const.ParamsNames.REGKEY,
                StringHelper.encrypt(student2InCourse1.key),
                Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_HOME_PAGE
        };

        authenticatedAction = getAction(submissionParams);
        redirectResult = getRedirectResult(authenticatedAction);

        assertEquals(
                Const.ActionURIs.STUDENT_HOME_PAGE
                        + "?persistencecourse=" + student1InCourse1.course
                        + "&error=true&user=" + student1InCourse1.googleId,
                redirectResult.getDestinationWithParams());
        assertTrue(redirectResult.isError);
        assertEquals(
                "The join link used belongs to a different user"
                        + " whose Google ID is stude..ourse1 "
                        + "(only part of the Google ID is shown to protect privacy)."
                        + " If that Google ID is owned by you, "
                        + "please logout and re-login using that Google account."
                        + " If it doesn’t belong to you, please "
                        + "<a href=\"mailto:" + Config.SUPPORT_EMAIL
                        + "?body=Your name:%0AYour course:%0AYour university:\">"
                        + "contact us</a> so that we can investigate.",
                redirectResult.getStatusMessage());
*/
    ______TS("join course with no feedback sessions, profile is empty");
    AccountAttributes studentWithEmptyProfile = dataBundle.accounts.get("noFSStudent");
    studentWithEmptyProfile = accountsDb.getAccount(studentWithEmptyProfile.googleId, true);
    assertNotNull(studentWithEmptyProfile.studentProfile);
    assertEquals("", studentWithEmptyProfile.studentProfile.pictureKey);
    assertEquals("", studentWithEmptyProfile.studentProfile.shortName);
    assertEquals("", studentWithEmptyProfile.studentProfile.nationality);
    assertEquals("", studentWithEmptyProfile.studentProfile.moreInfo);
    assertEquals("", studentWithEmptyProfile.studentProfile.email);
    StudentAttributes studentWithEmptyProfileAttributes = dataBundle.students.get("noFSStudentWithNoProfile");
    studentWithEmptyProfileAttributes = studentsDb.getStudentForEmail(studentWithEmptyProfileAttributes.course, studentWithEmptyProfileAttributes.email);
    gaeSimulation.loginUser("idOfNoFSStudent");
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(studentWithEmptyProfileAttributes.key), Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_HOME_PAGE };
    authenticatedAction = getAction(submissionParams);
    redirectResult = getRedirectResult(authenticatedAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, "idOfCourseNoEvals", false, "idOfNoFSStudent"), redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    assertEquals(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, "[idOfCourseNoEvals] Typical Course 3 with 0 Evals") + "<br>" + String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, "[idOfCourseNoEvals] Typical Course 3 with 0 Evals") + "<br>" + Const.StatusMessages.STUDENT_UPDATE_PROFILE, redirectResult.getStatusMessage());
    ______TS("join course with no feedback sessions, profile has only one missing field");
    AccountAttributes studentWithoutProfilePicture = dataBundle.accounts.get("noFSStudent2");
    studentWithoutProfilePicture = accountsDb.getAccount(studentWithoutProfilePicture.googleId, true);
    assertNotNull(studentWithoutProfilePicture.studentProfile);
    assertEquals("", studentWithoutProfilePicture.studentProfile.pictureKey);
    assertFalse(studentWithoutProfilePicture.studentProfile.nationality.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.shortName.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.moreInfo.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.email.isEmpty());
    StudentAttributes studentWithoutProfilePictureAttributes = dataBundle.students.get("noFSStudentWithPartialProfile");
    studentWithoutProfilePictureAttributes = studentsDb.getStudentForEmail(studentWithoutProfilePictureAttributes.course, studentWithoutProfilePictureAttributes.email);
    gaeSimulation.loginUser("idOfNoFSStudent2");
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(studentWithoutProfilePictureAttributes.key), Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_HOME_PAGE };
    authenticatedAction = getAction(submissionParams);
    redirectResult = getRedirectResult(authenticatedAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, "idOfCourseNoEvals", false, "idOfNoFSStudent2"), redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    assertEquals(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, "[idOfCourseNoEvals] Typical Course 3 with 0 Evals") + "<br>" + String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, "[idOfCourseNoEvals] Typical Course 3 with 0 Evals") + "<br>" + Const.StatusMessages.STUDENT_UPDATE_PROFILE_PICTURE, redirectResult.getStatusMessage());
    ______TS("join course with no feedback sessions, profile has no missing field");
    AccountAttributes studentWithFullProfile = dataBundle.accounts.get("noFSStudent3");
    studentWithFullProfile = accountsDb.getAccount(studentWithFullProfile.googleId, true);
    assertNotNull(studentWithFullProfile.studentProfile);
    assertFalse(studentWithFullProfile.studentProfile.pictureKey.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.nationality.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.shortName.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.moreInfo.isEmpty());
    assertFalse(studentWithoutProfilePicture.studentProfile.email.isEmpty());
    StudentAttributes studentWithFullProfileAttributes = dataBundle.students.get("noFSStudentWithFullProfile");
    studentWithFullProfileAttributes = studentsDb.getStudentForEmail(studentWithFullProfileAttributes.course, studentWithFullProfileAttributes.email);
    gaeSimulation.loginUser("idOfNoFSStudent3");
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(studentWithFullProfileAttributes.key), Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_HOME_PAGE };
    authenticatedAction = getAction(submissionParams);
    redirectResult = getRedirectResult(authenticatedAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_HOME_PAGE, "idOfCourseNoEvals", false, "idOfNoFSStudent3"), redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    assertEquals(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, "[idOfCourseNoEvals] Typical Course 3 with 0 Evals") + "<br>" + String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, "[idOfCourseNoEvals] Typical Course 3 with 0 Evals"), redirectResult.getStatusMessage());
    ______TS("typical case");
    AccountAttributes newStudentAccount = AccountAttributes.builder().withGoogleId("idOfNewStudent").withName("nameOfNewStudent").withEmail("newStudent@gmail.com").withInstitute("TEAMMATES Test Institute 5").withIsInstructor(false).withDefaultStudentProfileAttributes("idOfNewStudent").build();
    accountsDb.createAccount(newStudentAccount);
    StudentAttributes newStudentAttributes = StudentAttributes.builder(student1InCourse1.course, "nameOfNewStudent", "newStudent@course1.com").withSection(student1InCourse1.section).withTeam(student1InCourse1.team).withComments("This is a new student").build();
    studentsDb.createEntity(newStudentAttributes);
    newStudentAttributes = studentsDb.getStudentForEmail(newStudentAttributes.course, newStudentAttributes.email);
    gaeSimulation.loginUser("idOfNewStudent");
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(newStudentAttributes.key), Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE };
    authenticatedAction = getAction(submissionParams);
    redirectResult = getRedirectResult(authenticatedAction);
    assertEquals(getPageResultDestination(Const.ActionURIs.STUDENT_PROFILE_PAGE, "idOfTypicalCourse1", false, "idOfNewStudent"), redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    assertEquals(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, "[idOfTypicalCourse1] Typical Course 1 with 2 Evals"), redirectResult.getStatusMessage());
    ______TS("typical case: data requires sanitization");
    AccountAttributes accountTestSanitization = dataBundle.accounts.get("student1InTestingSanitizationCourse");
    StudentAttributes studentTestSanitization = dataBundle.students.get("student1InTestingSanitizationCourse");
    CourseAttributes courseTestSanitization = dataBundle.courses.get("testingSanitizationCourse");
    gaeSimulation.loginUser(accountTestSanitization.googleId);
    // retrieve student from datastore to get regkey
    studentTestSanitization = studentsDb.getStudentForEmail(studentTestSanitization.course, studentTestSanitization.email);
    submissionParams = new String[] { Const.ParamsNames.REGKEY, StringHelper.encrypt(studentTestSanitization.key), Const.ParamsNames.NEXT_URL, Const.ActionURIs.STUDENT_PROFILE_PAGE };
    authenticatedAction = getAction(submissionParams);
    redirectResult = getRedirectResult(authenticatedAction);
    assertEquals(Const.ActionURIs.STUDENT_PROFILE_PAGE + "?persistencecourse=" + courseTestSanitization.getId() + "&error=false&user=" + accountTestSanitization.googleId, redirectResult.getDestinationWithParams());
    assertFalse(redirectResult.isError);
    String courseIdentifier = "[" + courseTestSanitization.getId() + "] " + SanitizationHelper.sanitizeForHtml(courseTestSanitization.getName());
    String expectedStatusMessage = String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, courseIdentifier) + "<br>" + String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, courseIdentifier) + "<br>" + accountTestSanitization.studentProfile.generateUpdateMessageForStudent();
    assertEquals(expectedStatusMessage, redirectResult.getStatusMessage());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) AccountsDb(teammates.storage.api.AccountsDb) RedirectResult(teammates.ui.controller.RedirectResult) UnauthorizedAccessException(teammates.common.exception.UnauthorizedAccessException) StudentCourseJoinAuthenticatedAction(teammates.ui.controller.StudentCourseJoinAuthenticatedAction) StudentsDb(teammates.storage.api.StudentsDb) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) Test(org.testng.annotations.Test)

Example 12 with StudentAttributes

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

the class StudentHomePageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    String unregUserId = "unreg.user";
    StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    String studentId = student1InCourse1.googleId;
    String adminUserId = "admin.user";
    String[] submissionParams = new String[] {};
    ______TS("unregistered student");
    gaeSimulation.loginUser(unregUserId);
    StudentHomePageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    AssertHelper.assertContainsRegex(getPageResultDestination(Const.ViewURIs.STUDENT_HOME, false, "unreg.user"), r.getDestinationWithParams());
    assertFalse(r.isError);
    AssertHelper.assertContainsRegex("Ooops! Your Google account is not known to TEAMMATES{*}use the new Gmail address.", r.getStatusMessage());
    StudentHomePageData data = (StudentHomePageData) r.data;
    assertEquals(0, data.getCourseTables().size());
    String expectedLogMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage" + "|||true|||Unregistered|||Unknown|||unreg.user|||Unknown" + "|||Servlet Action Failure :Student with Google ID " + "unreg.user does not exist|||/page/studentHomePage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("registered student with no courses");
    // Note: this can happen only if the course was deleted after the student joined it.
    // The 'welcome stranger' response is not really appropriate for this situation, but
    // we keep it because the situation is rare and not worth extra coding.
    // Create a student account without courses
    AccountAttributes studentWithoutCourses = AccountAttributes.builder().withGoogleId("googleId.without.courses").withName("Student Without Courses").withEmail("googleId.without.courses@email.tmt").withInstitute("TEAMMATES Test Institute 5").withIsInstructor(false).withDefaultStudentProfileAttributes("googleId.without.courses").build();
    AccountsDb accountsDb = new AccountsDb();
    accountsDb.createAccount(studentWithoutCourses);
    assertNotNull(accountsDb.getAccount(studentWithoutCourses.googleId));
    gaeSimulation.loginUser(studentWithoutCourses.googleId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    AssertHelper.assertContainsRegex(getPageResultDestination(Const.ViewURIs.STUDENT_HOME, false, studentWithoutCourses.googleId), r.getDestinationWithParams());
    assertFalse(r.isError);
    AssertHelper.assertContainsRegex("Ooops! Your Google account is not known to TEAMMATES{*}use the new Gmail address.", r.getStatusMessage());
    data = (StudentHomePageData) r.data;
    assertEquals(0, data.getCourseTables().size());
    expectedLogMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage|||true" + "|||Unregistered|||Student Without Courses|||googleId.without.courses" + "|||googleId.without.courses@email.tmt|||Servlet Action Failure " + ":Student with Google ID googleId.without.courses does not exist" + "|||/page/studentHomePage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("typical user, masquerade mode");
    gaeSimulation.loginAsAdmin(adminUserId);
    studentId = typicalBundle.students.get("student2InCourse2").googleId;
    // Access page in masquerade mode
    a = getAction(addUserIdToParams(studentId, submissionParams));
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.STUDENT_HOME, false, studentId), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    data = (StudentHomePageData) r.data;
    assertEquals(2, data.getCourseTables().size());
    expectedLogMessage = "TEAMMATESLOG|||studentHomePage|||studentHomePage|||true" + "|||Student(M)|||Student in two courses|||student2InCourse1" + "|||student2InCourse1@gmail.tmt" + "|||studentHome Page Load<br>Total courses: 2" + "|||/page/studentHomePage";
    AssertHelper.assertLogMessageEqualsInMasqueradeMode(expectedLogMessage, a.getLogMessage(), adminUserId);
    ______TS("New student with no existing course, course join affected by eventual consistency");
    submissionParams = new String[] { Const.ParamsNames.CHECK_PERSISTENCE_COURSE, "idOfTypicalCourse1" };
    studentId = "newStudent";
    gaeSimulation.loginUser(studentId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    data = (StudentHomePageData) r.data;
    assertEquals(1, data.getCourseTables().size());
    assertEquals("idOfTypicalCourse1", data.getCourseTables().get(0).getCourseId());
    ______TS("Registered student with existing courses, course join affected by eventual consistency");
    submissionParams = new String[] { Const.ParamsNames.CHECK_PERSISTENCE_COURSE, "idOfTypicalCourse2" };
    student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    studentId = student1InCourse1.googleId;
    gaeSimulation.loginUser(studentId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    data = (StudentHomePageData) r.data;
    assertEquals(2, data.getCourseTables().size());
    assertEquals("idOfTypicalCourse2", data.getCourseTables().get(1).getCourseId());
    ______TS("Just joined course, course join not affected by eventual consistency and appears in list");
    submissionParams = new String[] { Const.ParamsNames.CHECK_PERSISTENCE_COURSE, "idOfTypicalCourse1" };
    student1InCourse1 = typicalBundle.students.get("student1InCourse1");
    studentId = student1InCourse1.googleId;
    gaeSimulation.loginUser(studentId);
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    data = (StudentHomePageData) r.data;
    assertEquals(1, data.getCourseTables().size());
    // Delete additional sessions that were created
    CoursesLogic.inst().deleteCourseCascade("typicalCourse2");
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) AccountsDb(teammates.storage.api.AccountsDb) StudentHomePageAction(teammates.ui.controller.StudentHomePageAction) StudentHomePageData(teammates.ui.pagedata.StudentHomePageData) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 13 with StudentAttributes

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

the class StudentFeedbackResultsPageUiTest method testAll.

@Test
public void testAll() throws Exception {
    ______TS("unreg student");
    logout();
    // Open Session
    StudentAttributes unreg = testData.students.get("DropOut");
    resultsPage = loginToStudentFeedbackResultsPage(unreg, "Open Session", StudentFeedbackResultsPage.class);
    resultsPage.verifyHtmlMainContent("/unregisteredStudentFeedbackResultsPageOpen.html");
    // Mcq Session
    resultsPage = loginToStudentFeedbackResultsPage(unreg, "MCQ Session", StudentFeedbackResultsPage.class);
    // This is the full HTML verification for Unregistered Student Feedback Results Page,
    // the rest can all be verifyMainHtml
    resultsPage.verifyHtml("/unregisteredStudentFeedbackResultsPageMCQ.html");
    ______TS("no responses");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "Empty Session");
    // This is the full HTML verification for Registered Student Feedback Results Page,
    // the rest can all be verifyMainHtml
    resultsPage.verifyHtml("/studentFeedbackResultsPageEmpty.html");
    ______TS("standard session results");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "Open Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageOpen.html");
    ______TS("team-to-team session results");
    resultsPage = loginToStudentFeedbackResultsPage("Benny", "Open Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageTeamToTeam.html");
    ______TS("MCQ session results");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "MCQ Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageMCQ.html");
    String additionalInfoId = "";
    int qnNumber = 4;
    verifyQuestionAdditionalInfoExpand(qnNumber, additionalInfoId);
    verifyQuestionAdditionalInfoCollapse(qnNumber, additionalInfoId);
    additionalInfoId = "";
    qnNumber = 5;
    verifyQuestionAdditionalInfoExpand(qnNumber, additionalInfoId);
    verifyQuestionAdditionalInfoCollapse(qnNumber, additionalInfoId);
    ______TS("MSQ session results");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "MSQ Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageMSQ.html");
    additionalInfoId = "";
    qnNumber = 4;
    verifyQuestionAdditionalInfoExpand(qnNumber, additionalInfoId);
    verifyQuestionAdditionalInfoCollapse(qnNumber, additionalInfoId);
    additionalInfoId = "";
    qnNumber = 5;
    verifyQuestionAdditionalInfoExpand(qnNumber, additionalInfoId);
    verifyQuestionAdditionalInfoCollapse(qnNumber, additionalInfoId);
    ______TS("NUMSCALE session results");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "NUMSCALE Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageNUMSCALE.html");
    ______TS("CONSTSUM session results");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "CONSTSUM Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageCONSTSUM.html");
    ______TS("CONTRIB session results");
    resultsPage = loginToStudentFeedbackResultsPage("Alice", "CONTRIB Session");
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageCONTRIB.html");
    ______TS("unreg student logged in as a student in another course: registered after logging out");
    String student1Username = TestProperties.TEST_STUDENT1_ACCOUNT;
    String student1Password = TestProperties.TEST_STUDENT1_PASSWORD;
    logout();
    LoginPage loginPage = AppPage.getNewPageInstance(browser, HomePage.class).clickStudentLogin();
    loginPage.loginAsStudent(student1Username, student1Password);
    StudentCourseJoinConfirmationPage confirmationPage = loginToStudentFeedbackResultsPage(unreg, "Open Session", StudentCourseJoinConfirmationPage.class);
    confirmationPage.verifyHtmlMainContent("/studentCourseJoinConfirmationLoggedInHTML.html");
    loginPage = confirmationPage.clickCancelButton();
    loginPage.loginAsStudent(student1Username, student1Password, StudentFeedbackResultsPage.class);
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageNewlyRegistered.html");
    // clear the googleId
    BackDoor.editStudent(unreg.email, unreg);
    ______TS("unreg student logged in as a student in another course: registered without logging out");
    logout();
    loginPage = AppPage.getNewPageInstance(browser, HomePage.class).clickStudentLogin();
    loginPage.loginAsStudent(student1Username, student1Password);
    confirmationPage = loginToStudentFeedbackResultsPage(unreg, "Open Session", StudentCourseJoinConfirmationPage.class);
    confirmationPage.verifyHtmlMainContent("/studentCourseJoinConfirmationLoggedInHTML.html");
    resultsPage = confirmationPage.clickConfirmButton(StudentFeedbackResultsPage.class);
    resultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageNewlyRegistered.html");
    BackDoor.deleteStudent(unreg.course, unreg.email);
}
Also used : StudentFeedbackResultsPage(teammates.test.pageobjects.StudentFeedbackResultsPage) HomePage(teammates.test.pageobjects.HomePage) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) LoginPage(teammates.test.pageobjects.LoginPage) StudentCourseJoinConfirmationPage(teammates.test.pageobjects.StudentCourseJoinConfirmationPage) Test(org.testng.annotations.Test)

Example 14 with StudentAttributes

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

the class StudentProfilePictureActionTest method testActionForStudentWithEmptyGoogleId.

private void testActionForStudentWithEmptyGoogleId() {
    ______TS("Failure case: no profile available (unreg student)");
    StudentAttributes student = typicalBundle.students.get("student2InUnregisteredCourse");
    assertTrue(student.googleId.isEmpty());
    String[] submissionParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, StringHelper.encrypt(student.email), Const.ParamsNames.COURSE_ID, StringHelper.encrypt(student.course) };
    StudentProfilePictureAction action = getAction(submissionParams);
    ImageResult result = getImageResult(action);
    assertEquals("", result.blobKey);
}
Also used : ImageResult(teammates.ui.controller.ImageResult) StudentProfilePictureAction(teammates.ui.controller.StudentProfilePictureAction) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 15 with StudentAttributes

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

the class FeedbackResponseAdjustmentWorkerActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("typical case : existing student changes team");
    FeedbackSessionAttributes session = dataBundle.feedbackSessions.get("session2InCourse1");
    StudentAttributes student = dataBundle.students.get("student1InCourse1");
    // Verify pre-existing submissions and responses
    List<FeedbackResponseAttributes> oldResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertFalse(oldResponsesForSession.isEmpty());
    String oldTeam = student.team;
    String oldSection = student.section;
    String newTeam = "Team 1.2";
    String newSection = "Section 2";
    student.team = newTeam;
    student.section = newSection;
    StudentEnrollDetails enrollDetails = new StudentEnrollDetails(StudentUpdateStatus.MODIFIED, student.course, student.email, oldTeam, newTeam, oldSection, newSection);
    List<StudentEnrollDetails> enrollList = new ArrayList<>();
    enrollList.add(enrollDetails);
    studentsLogic.updateStudentCascadeWithSubmissionAdjustmentScheduled(student.email, student, false);
    String[] submissionParams = new String[] { ParamsNames.COURSE_ID, student.course, ParamsNames.FEEDBACK_SESSION_NAME, session.getFeedbackSessionName(), ParamsNames.ENROLLMENT_DETAILS, JsonUtils.toJson(enrollList) };
    FeedbackResponseAdjustmentWorkerAction action = getAction(submissionParams);
    action.execute();
    List<FeedbackResponseAttributes> newResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertTrue(newResponsesForSession.isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) ArrayList(java.util.ArrayList) FeedbackResponseAdjustmentWorkerAction(teammates.ui.automated.FeedbackResponseAdjustmentWorkerAction) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) 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