Search in sources :

Example 1 with StudentAttributes

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

the class InstructorStudentListPageUiTest method testShowPhoto.

private void testShowPhoto() throws Exception {
    // Mouseover actions do not work on Selenium-Chrome
    if ("chrome".equals(TestProperties.BROWSER)) {
        return;
    }
    if (System.getenv("APPVEYOR") != null) {
        // TODO fix this
        return;
    }
    String instructorId = testData.instructors.get("instructorOfCourse2").googleId;
    AppUrl viewPageUrl = createUrl(Const.ActionURIs.INSTRUCTOR_STUDENT_LIST_PAGE).withUserId(instructorId);
    viewPage = loginAdminToPage(viewPageUrl, InstructorStudentListPage.class);
    ______TS("default image");
    StudentAttributes student = testData.students.get("Student1Course2");
    viewPage.checkCourse(0);
    viewPage.checkCourse(1);
    viewPage.clickShowPhoto(student.course, student.name);
    viewPage.verifyProfilePhoto(student.course, student.name, Const.SystemParams.DEFAULT_PROFILE_PICTURE_PATH);
    ______TS("student has uploaded an image");
    StudentAttributes student2 = testData.students.get("Student3Course3");
    viewPage.clickShowPhoto(student2.course, student2.name);
    String photoUrl = createUrl(Const.ActionURIs.STUDENT_PROFILE_PICTURE).withStudentEmail(StringHelper.encrypt(student2.email)).withCourseId(StringHelper.encrypt(student2.course)).withUserId(instructorId).toAbsoluteString();
    viewPage.verifyProfilePhoto(student2.course, student2.name, photoUrl);
    viewPage.verifyHtmlMainContent("/instructorStudentListPageWithPicture.html");
}
Also used : AppUrl(teammates.common.util.AppUrl) InstructorStudentListPage(teammates.test.pageobjects.InstructorStudentListPage) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes)

Example 2 with StudentAttributes

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

the class InstructorStudentRecordsPageUiTest method testPanelsCollapseExpand.

private void testPanelsCollapseExpand() {
    DataBundle testDataQuestionType = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
    InstructorAttributes instructor = testDataQuestionType.instructors.get("instructor1OfCourse1");
    StudentAttributes student = testDataQuestionType.students.get("student1InCourse1");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    ______TS("Typical case: panels expand/collapse");
    viewPage.clickAllRecordPanelHeadings();
    viewPage.waitForPanelsToCollapse();
    assertTrue(viewPage.areRecordsHidden());
    viewPage.clickAllRecordPanelHeadings();
    viewPage.waitForPanelsToExpand();
    assertTrue(viewPage.areRecordsVisible());
}
Also used : DataBundle(teammates.common.datatransfer.DataBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 3 with StudentAttributes

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

the class InstructorStudentRecordsPageUiTest method testContent.

private void testContent() throws Exception {
    InstructorAttributes instructor;
    StudentAttributes student;
    ______TS("content: typical case, normal student records with comments");
    instructor = testData.instructors.get("teammates.test.CS2104");
    student = testData.students.get("benny.c.tmms@ISR.CS2104");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    // This is the full HTML verification for Instructor Student Records Page, the rest can all be verifyMainHtml
    viewPage.verifyHtml("/instructorStudentRecords.html");
    ______TS("content: typical case, normal student records with comments, helper view");
    instructor = testData.instructors.get("teammates.test.CS2104.Helper");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    viewPage.verifyHtmlMainContent("/instructorStudentRecordsWithHelperView.html");
    ______TS("content: normal student records with other instructor's comments, private feedback session");
    instructor = testData.instructors.get("teammates.test.CS1101");
    student = testData.students.get("teammates.test@ISR.CS1101");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    viewPage.verifyHtmlMainContent("/instructorStudentRecordsPageWithPrivateFeedback.html");
    ______TS("content: no student records, no profiles");
    instructor = testData.instructors.get("teammates.noeval");
    student = testData.students.get("alice.b.tmms@ISR.NoEval");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    viewPage.verifyHtmlMainContent("/instructorStudentRecordsPageNoRecords.html");
    ______TS("content: multiple feedback session type student record");
    DataBundle testDataQuestionType = loadDataBundle("/FeedbackSessionQuestionTypeTest.json");
    removeAndRestoreDataBundle(testDataQuestionType);
    instructor = testDataQuestionType.instructors.get("instructor1OfCourse1");
    student = testDataQuestionType.students.get("student1InCourse1");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    viewPage.verifyHtmlMainContent("/instructorStudentRecordsPageMixedQuestionType.html");
    ______TS("content: profile with attemoted script and html injection with comment");
    instructor = testData.instructors.get("instructor1OfTestingSanitizationCourse");
    student = testData.students.get("student1InTestingSanitizationCourse");
    instructorId = instructor.googleId;
    courseId = instructor.courseId;
    studentEmail = student.email;
    viewPage = getStudentRecordsPage();
    viewPage.verifyHtmlMainContent("/instructorStudentRecordsPageWithScriptInjectionProfile.html");
}
Also used : DataBundle(teammates.common.datatransfer.DataBundle) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 4 with StudentAttributes

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

the class InstructorSubmissionAdjustmentUiTest method testAdjustmentOfSubmission.

@Test
public void testAdjustmentOfSubmission() throws MaximumRetriesExceededException {
    // load the enrollPage
    loadEnrollmentPage();
    ______TS("typical case: enroll new student to existing course");
    StudentAttributes newStudent = StudentAttributes.builder("idOfTypicalCourse1", "someName", "random@g.tmt").withComments("comments").withTeam("Team 1.1</td></div>'\"").withSection("None").build();
    String enrollString = "Section | Team | Name | Email | Comment" + System.lineSeparator() + newStudent.toEnrollmentString();
    enrollPage.enroll(enrollString);
    // Wait briefly to allow task queue to successfully execute tasks
    ThreadHelper.waitFor(2000);
    ______TS("typical case : existing student changes team");
    loadEnrollmentPage();
    final FeedbackSessionAttributes session = testData.feedbackSessions.get("session2InCourse1");
    final StudentAttributes student = testData.students.get("student1InCourse1");
    // Verify pre-existing submissions and responses
    List<FeedbackResponseAttributes> oldResponsesForSession = getAllResponsesForStudentForSession(student, session.getFeedbackSessionName());
    assertFalse(oldResponsesForSession.isEmpty());
    String newTeam = "Team 1.2";
    student.team = newTeam;
    enrollString = "Section | Team | Name | Email | Comment" + System.lineSeparator() + student.toEnrollmentString();
    enrollPage.enroll(enrollString);
    // It might take a while for the submission adjustment to persist (especially on the live server),
    // during which the pre-existing submissions and responses would be counted.
    // Hence, this needs to be retried several times until the count becomes zero.
    persistenceRetryManager.runUntilSuccessful(new RetryableTaskReturns<Integer>("Assert outdated responses removed") {

        @Override
        public Integer run() {
            return getAllResponsesForStudentForSession(student, session.getFeedbackSessionName()).size();
        }

        @Override
        public boolean isSuccessful(Integer numberOfResponses) {
            return numberOfResponses == 0;
        }
    });
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) Test(org.testng.annotations.Test)

Example 5 with StudentAttributes

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

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