Search in sources :

Example 6 with InstructorAttributes

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

the class InstructorStudentRecordsPageActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() throws Exception {
    InstructorAttributes instructor = typicalBundle.instructors.get("instructor3OfCourse1");
    StudentAttributes student = typicalBundle.students.get("student2InCourse1");
    String instructorId = instructor.googleId;
    gaeSimulation.loginAsInstructor(instructorId);
    ______TS("Invalid parameters");
    // no params
    verifyAssumptionFailure();
    // null courseId
    String[] invalidParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, student.email };
    verifyAssumptionFailure(invalidParams);
    // null student email
    invalidParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId };
    verifyAssumptionFailure(invalidParams);
    // student not in course
    String studentEmailOfStudent1InCourse2 = typicalBundle.students.get("student1InCourse2").email;
    invalidParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, studentEmailOfStudent1InCourse2 };
    RedirectResult redirect = getRedirectResult(getAction(invalidParams));
    AssertHelper.assertContains(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, redirect.getDestinationWithParams());
    AssertHelper.assertContains(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_RECORDS, redirect.getStatusMessage());
    ______TS("Typical case: student has some records and has profile");
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email };
    InstructorStudentRecordsPageAction a = getAction(submissionParams);
    ShowPageResult r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, false, "idOfInstructor3"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("", r.getStatusMessage());
    InstructorStudentRecordsPageData actualData = (InstructorStudentRecordsPageData) r.data;
    StudentProfileAttributes expectedProfile = StudentProfileAttributes.builder(student.googleId).build();
    expectedProfile.modifiedDate = actualData.spa.modifiedDate;
    expectedProfile.pictureKey = actualData.spa.pictureKey;
    assertEquals(instructorId, actualData.account.googleId);
    assertEquals(instructor.courseId, actualData.getCourseId());
    assertEquals(6, actualData.getSessionNames().size());
    assertEquals(student.googleId, actualData.spa.googleId);
    String expectedLogMessage = "TEAMMATESLOG|||instructorStudentRecordsPage|||instructorStudentRecordsPage" + "|||true|||Instructor|||Instructor 3 of Course 1 and 2|||idOfInstructor3" + "|||instr3@course1n2.tmt|||instructorStudentRecords Page Load<br>" + "Viewing <span class=\"bold\">" + student.email + "'s</span> records " + "for Course <span class=\"bold\">[" + instructor.courseId + "]</span><br>" + "Number of sessions: 6<br>" + "Student Profile: " + SanitizationHelper.sanitizeForHtmlTag(expectedProfile.toString()) + "|||/page/instructorStudentRecordsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
    ______TS("Typical case: instructor cannot view sections");
    instructor = typicalBundle.instructors.get("helperOfCourse1");
    gaeSimulation.loginAsInstructor(instructor.googleId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email };
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, false, "idOfHelperOfCourse1"), r.getDestinationWithParams());
    assertFalse(r.isError);
    assertEquals("Normally, we would show the student’s profile here. " + "However, you do not have access to view this student's profile<br>" + "No records were found for this student", r.getStatusMessage());
    ______TS("Typical case: student has no records, no profiles");
    String instructor4Id = typicalBundle.instructors.get("instructor4").googleId;
    // re-login as another instructor for new test
    gaeSimulation.loginAsInstructor(instructor4Id);
    String courseIdWithNoSession = "idOfCourseNoEvals";
    StudentAttributes testStudent = createStudentInTypicalDataBundleForCourseWithNoSession();
    String[] submissionParamsWithNoSession = new String[] { Const.ParamsNames.COURSE_ID, courseIdWithNoSession, Const.ParamsNames.STUDENT_EMAIL, "emailTemp@gmail.tmt" };
    InstructorStudentRecordsPageAction aWithNoSession = getAction(submissionParamsWithNoSession);
    ShowPageResult rWithNoSession = getShowPageResult(aWithNoSession);
    List<String> expectedMessages = new ArrayList<>();
    expectedMessages.add("No records were found for this student");
    expectedMessages.add(Const.StatusMessages.STUDENT_NOT_JOINED_YET_FOR_RECORDS);
    AssertHelper.assertContains(expectedMessages, rWithNoSession.getStatusMessage());
    ______TS("Typical case: student has profile but no records");
    testStudent.googleId = "valid.no.sessions";
    StudentsLogic.inst().updateStudentCascadeWithoutDocument(testStudent.email, testStudent);
    logic.createAccount(testStudent.googleId, testStudent.name, false, testStudent.email, "valid institute");
    a = getAction(submissionParamsWithNoSession);
    r = getShowPageResult(a);
    AssertHelper.assertContains("No records were found for this student", r.getStatusMessage());
    ______TS("Typical case: student has profile with script injection");
    instructor = typicalBundle.instructors.get("instructor1OfTestingSanitizationCourse");
    instructorId = instructor.googleId;
    String studentId = "student1InTestingSanitizationCourse";
    student = typicalBundle.students.get(studentId);
    expectedProfile = typicalBundle.accounts.get(studentId).studentProfile;
    gaeSimulation.loginAsInstructor(instructorId);
    submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor.courseId, Const.ParamsNames.STUDENT_EMAIL, student.email };
    a = getAction(submissionParams);
    r = getShowPageResult(a);
    actualData = (InstructorStudentRecordsPageData) r.data;
    expectedProfile.modifiedDate = actualData.spa.modifiedDate;
    assertEquals(getPageResultDestination(Const.ViewURIs.INSTRUCTOR_STUDENT_RECORDS, false, instructorId), r.getDestinationWithParams());
    assertFalse(r.isError);
    expectedLogMessage = "TEAMMATESLOG|||instructorStudentRecordsPage|||instructorStudentRecordsPage" + "|||true|||Instructor|||Instructor&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt;" + "|||" + instructorId + "|||instructor1@sanitization.tmt|||instructorStudentRecords Page Load<br>" + "Viewing <span class=\"bold\">" + student.email + "'s</span> records " + "for Course <span class=\"bold\">[" + instructor.courseId + "]</span><br>" + "Number of sessions: 1<br>" + "Student Profile: " + SanitizationHelper.sanitizeForHtmlTag(expectedProfile.toString()) + "|||/page/instructorStudentRecordsPage";
    AssertHelper.assertLogMessageEquals(expectedLogMessage, a.getLogMessage());
}
Also used : ShowPageResult(teammates.ui.controller.ShowPageResult) InstructorStudentRecordsPageAction(teammates.ui.controller.InstructorStudentRecordsPageAction) RedirectResult(teammates.ui.controller.RedirectResult) ArrayList(java.util.ArrayList) InstructorStudentRecordsPageData(teammates.ui.pagedata.InstructorStudentRecordsPageData) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 7 with InstructorAttributes

use of teammates.common.datatransfer.attributes.InstructorAttributes 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 InstructorAttributes

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

the class AdminHomePageUiTest method testCreateInstructorAction.

private void testCreateInstructorAction() throws Exception {
    InstructorAttributes instructor = new InstructorAttributes();
    instructor.name = "AHPUiT Instrúctör WithPlusInEmail";
    instructor.email = "AHPUiT+++_.instr1!@gmail.tmt";
    String institute = "TEAMMATES Test Institute 1";
    String demoCourseId = "AHPUiT____.instr1_.gma-demo";
    String instructorDetails = instructor.name + " | " + instructor.email + "\n" + instructor.name + " | " + instructor.email + " | " + institute;
    ______TS("action fail & success: add multiple instructors");
    BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(demoCourseId);
    BackDoor.deleteInstructor(demoCourseId, instructor.email);
    homePage.createInstructorByInstructorDetailsSingleLineForm(instructorDetails);
    InstructorAttributes instructorInBackend = getInstructorWithRetry(demoCourseId, instructor.email);
    assertEquals("Instructor Details must have 3 columns", homePage.getMessageFromResultTable(1));
    String encryptedKey = getKeyForInstructorWithRetry(demoCourseId, instructor.email);
    // use AppUrl from Config because the join link takes its base URL from build.properties
    String expectedjoinUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(encryptedKey).withInstructorInstitution(institute).toAbsoluteString();
    assertEquals("Instructor AHPUiT Instrúctör WithPlusInEmail has been successfully created " + Const.JOIN_LINK, homePage.getMessageFromResultTable(2));
    assertEquals(expectedjoinUrl, homePage.getJoinLink(homePage.getMessageFromResultTable(2)));
    assertEquals(instructor.getName(), instructorInBackend.getName());
    assertEquals(instructor.getEmail(), instructorInBackend.getEmail());
    homePage.clearInstructorDetailsSingleLineForm();
    ______TS("action success: displayed instructor details are properly HTML-encoded");
    InstructorAttributes dangerousInstructor = new InstructorAttributes();
    dangerousInstructor.name = "Malicious <script>alert('dangerous');</script>Instrúctör";
    dangerousInstructor.email = "malicious.instr1<>!@gmail.tmt";
    String dangerousInstitute = "TEAMMATES Malicious Institute <!@!@!>";
    String dangerousDemoCourseId = "malicious.instr1___.gma-demo";
    BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(dangerousDemoCourseId);
    BackDoor.deleteInstructor(dangerousDemoCourseId, dangerousInstructor.email);
    homePage.createInstructor(dangerousInstructor, dangerousInstitute);
    assertEquals(dangerousInstructor.name, homePage.getNameFromResultTable(1));
    assertEquals(dangerousInstructor.email, homePage.getEmailFromResultTable(1));
    assertEquals(dangerousInstitute, homePage.getInstitutionFromResultTable(1));
    ______TS("action success : create instructor account and the account is created successfully " + "after user's verification");
    BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(demoCourseId);
    BackDoor.deleteInstructor(demoCourseId, instructor.email);
    homePage.createInstructor(instructor, institute);
    encryptedKey = getKeyForInstructorWithRetry(demoCourseId, instructor.email);
    // use AppUrl from Config because the join link takes its base URL from build.properties
    expectedjoinUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(encryptedKey).withInstructorInstitution(institute).toAbsoluteString();
    assertEquals("Instructor AHPUiT Instrúctör WithPlusInEmail has been successfully created " + Const.JOIN_LINK, homePage.getMessageFromResultTable(1));
    assertEquals(expectedjoinUrl, homePage.getJoinLink(homePage.getMessageFromResultTable(1)));
    homePage.logout();
    // verify the instructor and the demo course have been created
    assertNotNull(getCourseWithRetry(demoCourseId));
    assertNotNull(getInstructorWithRetry(demoCourseId, instructor.email));
    // get the joinURL which sent to the requester's email
    String regkey = getKeyForInstructorWithRetry(demoCourseId, instructor.email);
    String joinLink = createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(regkey).withInstructorInstitution(institute).toAbsoluteString();
    // simulate the user's verification here because it is added by admin
    browser.driver.get(joinLink);
    InstructorCourseJoinConfirmationPage confirmationPage = AppPage.createCorrectLoginPageType(browser).loginAsJoiningInstructor(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
    confirmationPage.clickCancelButton();
    browser.driver.get(joinLink);
    confirmationPage = AppPage.createCorrectLoginPageType(browser).loginAsJoiningInstructor(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
    confirmationPage.clickConfirmButtonWithRetry();
    // check a account has been created for the requester successfully
    assertNotNull(getAccountWithRetry(TestProperties.TEST_INSTRUCTOR_ACCOUNT));
    // verify sample course is accessible for newly joined instructor as an instructor
    ______TS("new instructor can see sample course in homepage");
    InstructorHomePage instructorHomePage = AppPage.getNewPageInstance(browser, InstructorHomePage.class);
    instructorHomePage.verifyHtmlMainContent("/newlyJoinedInstructorHomePage.html");
    ______TS("new instructor can access sample course details page");
    InstructorCourseEnrollPage enrollPage = instructorHomePage.clickCourseEnrollLink(demoCourseId);
    instructorHomePage = enrollPage.goToPreviousPage(InstructorHomePage.class);
    InstructorCourseDetailsPage detailsPage = instructorHomePage.clickCourseViewLink(demoCourseId);
    detailsPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseDetailsPage.html");
    ______TS("new instructor can access sample course edit page");
    instructorHomePage = detailsPage.goToPreviousPage(InstructorHomePage.class);
    InstructorCourseEditPage editPage = instructorHomePage.clickCourseEditLink(demoCourseId);
    editPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseEditPage.html");
    ______TS("new instructor can view feedback sessions of sample course");
    AppUrl url = createUrl(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE).withUserId(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
    coursesPage = AppPage.getNewPageInstance(browser, url, InstructorCoursesPage.class);
    coursesPage.waitForAjaxLoadCoursesSuccess();
    verifyCanViewSessionResults(demoCourseId, "First team feedback session", "/newlyJoinedInstructorFirstFeedbackSessionResultsPage.html");
    verifyCanViewSessionResults(demoCourseId, "Second team feedback session", "/newlyJoinedInstructorSecondFeedbackSessionResultsPage.html");
    verifyCanViewSessionResults(demoCourseId, "Session with different question types", "/newlyJoinedInstructorThirdFeedbackSessionResultsPage.html");
    ______TS("action failure : trying to create instructor with an invalid email");
    AppUrl homeUrl = createUrl(Const.ActionURIs.ADMIN_HOME_PAGE);
    homePage = loginAdminToPage(homeUrl, AdminHomePage.class);
    instructor.email = "AHPUiT.email.tmt";
    homePage.createInstructor(instructor, institute);
    assertEquals(getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, instructor.email, FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.EMAIL_MAX_LENGTH), homePage.getMessageFromResultTable(1));
    ______TS("action success: course is accessible for newly joined instructor as student");
    // in staging server, the student account uses the hardcoded email above, so this can only be test on dev server
    if (!TestProperties.isDevServer()) {
        BackDoor.deleteCourse(demoCourseId);
        BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
        BackDoor.deleteInstructor(demoCourseId, instructor.email);
        return;
    }
    // verify sample course is accessible for newly joined instructor as an student
    StudentHomePage studentHomePage = getHomePage().clickStudentLogin().loginAsStudent(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
    studentHomePage.verifyContains(demoCourseId);
    studentHomePage.clickViewTeam();
    StudentCourseDetailsPage courseDetailsPage = AppPage.getNewPageInstance(browser, StudentCourseDetailsPage.class);
    courseDetailsPage.verifyHtmlMainContent("/newlyJoinedInstructorStudentCourseDetailsPage.html");
    studentHomePage = courseDetailsPage.goToPreviousPage(StudentHomePage.class);
    studentHomePage.clickViewFeedbackButton("First team feedback session");
    StudentFeedbackResultsPage sfrp = AppPage.getNewPageInstance(browser, StudentFeedbackResultsPage.class);
    sfrp.verifyHtmlMainContent("/newlyJoinedInstructorStudentFeedbackResultsPage.html");
    studentHomePage = sfrp.goToPreviousPage(StudentHomePage.class);
    studentHomePage.clickEditFeedbackButton("First team feedback session");
    FeedbackSubmitPage fsp = AppPage.getNewPageInstance(browser, FeedbackSubmitPage.class);
    fsp.verifyHtmlMainContent("/newlyJoinedInstructorStudentFeedbackSubmissionEdit.html");
    studentHomePage = fsp.loadStudentHomeTab();
    StudentProfilePage spp = studentHomePage.loadProfileTab();
    spp.verifyContains("Student Profile");
    spp.verifyContains("AHPUiT Instrúctör WithPlusInEmail");
    studentHomePage.logout();
    // login in as instructor again to test sample course deletion
    instructorHomePage = getHomePage().clickInstructorLogin().loginAsInstructor(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
    instructorHomePage.clickAndConfirm(instructorHomePage.getDeleteCourseLink(demoCourseId));
    assertTrue(instructorHomePage.getTextsForAllStatusMessagesToUser().contains("The course " + demoCourseId + " has been deleted."));
    instructorHomePage.logout();
    BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(demoCourseId);
    BackDoor.deleteInstructor(demoCourseId, instructor.email);
    BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
    BackDoor.deleteCourse(dangerousDemoCourseId);
    BackDoor.deleteInstructor(dangerousDemoCourseId, dangerousInstructor.email);
}
Also used : StudentFeedbackResultsPage(teammates.test.pageobjects.StudentFeedbackResultsPage) InstructorCourseEnrollPage(teammates.test.pageobjects.InstructorCourseEnrollPage) AppUrl(teammates.common.util.AppUrl) InstructorCoursesPage(teammates.test.pageobjects.InstructorCoursesPage) FeedbackSubmitPage(teammates.test.pageobjects.FeedbackSubmitPage) StudentCourseDetailsPage(teammates.test.pageobjects.StudentCourseDetailsPage) StudentProfilePage(teammates.test.pageobjects.StudentProfilePage) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorCourseEditPage(teammates.test.pageobjects.InstructorCourseEditPage) AdminHomePage(teammates.test.pageobjects.AdminHomePage) InstructorCourseDetailsPage(teammates.test.pageobjects.InstructorCourseDetailsPage) InstructorHomePage(teammates.test.pageobjects.InstructorHomePage) StudentHomePage(teammates.test.pageobjects.StudentHomePage) InstructorCourseJoinConfirmationPage(teammates.test.pageobjects.InstructorCourseJoinConfirmationPage)

Example 9 with InstructorAttributes

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

the class AdminSearchPageUiTest method testSanitization.

private void testSanitization() {
    ______TS("search for student with data requiring sanitization");
    searchPage.clearSearchBox();
    String searchContent = "searchUI.normal@sanitization.tmt";
    searchPage.inputSearchContent(searchContent);
    searchPage.clickSearchButton();
    StudentAttributes student = testData.students.get("student1InTestingSanitizationCourse");
    InstructorAttributes instructor = testData.instructors.get("instructor1OfTestingSanitizationCourse");
    CourseAttributes course = testData.courses.get("testingSanitizationCourse");
    assertStudentRowDisplayed(student, instructor, course);
    ______TS("search for instructor with data requiring sanitization");
    searchPage.clearSearchBox();
    searchContent = "searchUI.instructor1@sanitization.tmt";
    searchPage.inputSearchContent(searchContent);
    searchPage.clickSearchButton();
    assertInstructorRowDisplayed(instructor, course);
}
Also used : StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 10 with InstructorAttributes

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

the class FeedbackSessionRemindEmailWorkerActionTest method allTests.

@Test
public void allTests() throws Exception {
    ______TS("Send feedback session reminder email");
    FeedbackSessionAttributes session1 = dataBundle.feedbackSessions.get("session1InCourse1");
    InstructorAttributes instructor1 = dataBundle.instructors.get("instructor1OfCourse1");
    // re-read from Datastore to update the respondents list
    session1 = fsLogic.getFeedbackSession(session1.getFeedbackSessionName(), session1.getCourseId());
    String[] submissionParams = new String[] { ParamsNames.SUBMISSION_FEEDBACK, session1.getFeedbackSessionName(), ParamsNames.SUBMISSION_COURSE, session1.getCourseId(), ParamsNames.USER_ID, instructor1.getGoogleId() };
    FeedbackSessionRemindEmailWorkerAction action = getAction(submissionParams);
    action.execute();
    // 2 students and 4 instructors sent reminder, 1 instructor notified
    verifySpecifiedTasksAdded(action, Const.TaskQueue.SEND_EMAIL_QUEUE_NAME, 7);
    List<String> studentRecipientList = new ArrayList<>();
    for (StudentAttributes student : studentsLogic.getStudentsForCourse(session1.getCourseId())) {
        if (!fsLogic.isFeedbackSessionCompletedByStudent(session1, student.email)) {
            studentRecipientList.add(student.email);
        }
    }
    List<String> instructorRecipientList = new ArrayList<>();
    List<String> instructorNotifiedList = new ArrayList<>();
    for (InstructorAttributes instructor : instructorsLogic.getInstructorsForCourse(session1.getCourseId())) {
        if (!fsLogic.isFeedbackSessionCompletedByInstructor(session1, instructor.email)) {
            instructorRecipientList.add(instructor.email);
        }
    }
    instructorNotifiedList.add(instructorsLogic.getInstructorForGoogleId(session1.getCourseId(), instructor1.getGoogleId()).email);
    String courseName = coursesLogic.getCourse(session1.getCourseId()).getName();
    List<TaskWrapper> tasksAdded = action.getTaskQueuer().getTasksAdded();
    for (TaskWrapper task : tasksAdded) {
        Map<String, String[]> paramMap = task.getParamMap();
        assertEquals(String.format(EmailType.FEEDBACK_SESSION_REMINDER.getSubject(), courseName, session1.getSessionName()), paramMap.get(ParamsNames.EMAIL_SUBJECT)[0]);
        String header = "The email below has been sent to students of course: [" + session1.getCourseId() + "]";
        String content = paramMap.get(ParamsNames.EMAIL_CONTENT)[0];
        String recipient = paramMap.get(ParamsNames.EMAIL_RECEIVER)[0];
        if (content.contains(header)) {
            // notification to only requesting instructors
            assertTrue(instructorNotifiedList.contains(recipient));
            instructorNotifiedList.remove(recipient);
            continue;
        }
        if (studentRecipientList.contains(recipient)) {
            studentRecipientList.remove(recipient);
            continue;
        }
        if (instructorRecipientList.contains(recipient)) {
            instructorRecipientList.remove(recipient);
            continue;
        }
        fail("Email recipient " + recipient + " is not in the list!");
    }
    // Ensure that every email recipient is accounted for
    assertTrue(String.valueOf(studentRecipientList.size()), studentRecipientList.isEmpty());
    assertTrue(String.valueOf(instructorRecipientList.size()), instructorRecipientList.isEmpty());
    assertTrue(instructorNotifiedList.isEmpty());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) TaskWrapper(teammates.common.util.TaskWrapper) FeedbackSessionRemindEmailWorkerAction(teammates.ui.automated.FeedbackSessionRemindEmailWorkerAction) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Aggregations

InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)325 Test (org.testng.annotations.Test)127 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)84 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)77 ArrayList (java.util.ArrayList)58 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)46 RedirectResult (teammates.ui.controller.RedirectResult)46 StatusMessage (teammates.common.util.StatusMessage)34 ShowPageResult (teammates.ui.controller.ShowPageResult)31 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)29 HashMap (java.util.HashMap)25 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)24 InvalidParametersException (teammates.common.exception.InvalidParametersException)24 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)20 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)18 EmailWrapper (teammates.common.util.EmailWrapper)15 InstructorPrivileges (teammates.common.datatransfer.InstructorPrivileges)14 DataBundle (teammates.common.datatransfer.DataBundle)13