Search in sources :

Example 16 with CourseStaffMember

use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.

the class EvaluationTestsBase method evaluateWorkspaceStudent.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateWorkspaceStudent() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    Builder mockBuilder = mocker();
    try {
        mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
        Long courseId = 1l;
        login();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", courseId.toString(), Boolean.TRUE);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        try {
            WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
            WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nT0yyez23QwFXD3G0I8HzYeK&quot;,&quot;rightAnswers&quot;:[],&quot;columns&quot;:&quot;&quot;,&quot;hint&quot;:&quot;&quot;}\" /></object></p>", 1l, "EVALUATED");
            try {
                Long assessorId = getUserEntityIdForIdentifier(String.format("STAFF-%s", admin.getId()));
                logout();
                mockBuilder.mockLogin(student).build();
                login();
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
                assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
                assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
                assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
                sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
                waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
                waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
                waitForPresentAndVisible(".notification-queue-item-success");
                waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
                logout();
                mockBuilder.mockLogin(admin).build();
                login();
                ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).setSerializationInclusion(Include.NON_NULL);
                // TODO: Move to new mocker
                OffsetDateTime assessmentCreated = OffsetDateTime.of(2015, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
                CourseAssessment courseAssessment = new CourseAssessment(1l, courseStudent.getId(), 1l, 1l, admin.getId(), assessmentCreated, "Test evaluation.", Boolean.TRUE);
                stubFor(post(urlMatching(String.format("/1/students/students/%d/courses/%d/assessments/", student.getId(), courseStudent.getCourseId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(courseAssessment)).withStatus(200)));
                navigate(String.format("/evaluation"), true);
                waitAndClick("#filter-students-by-assessment-requested");
                waitAndClick(".evaluation-student-name");
                addTextToCKEditor("Test evaluation.");
                clearElement("#evaluationDate");
                sendKeys("#evaluationDate", "2.12.2015");
                selectOption("#grade", "1/PYRAMUS@1/PYRAMUS");
                selectOption("select[name='assessor']", assessorId.toString());
                click(".save-evaluation-button");
                waitForPresent(".notification-queue-item-success");
                // There's no JSONComparator that allows different values. And since dev machine and travis testing gives different dates we can not test requestBody with CourseAssessment model.
                CourseAssessment cAss = new fi.otavanopisto.pyramus.rest.model.CourseAssessment(null, courseStudent.getId(), 1l, 1l, admin.getId(), null, "<p>Test evaluation.</p>\n", Boolean.TRUE);
                verify(postRequestedFor(urlEqualTo(String.format("/1/students/students/%d/courses/%d/assessments/", student.getId(), courseId))).withHeader("Content-Type", equalTo("application/json")).withRequestBody(equalToJson(objectMapper.writeValueAsString(cAss), true, true)));
                PyramusMocks.mockAssessedStudent1Workspace1(courseStudent, assessorId);
                waitForPresentAndVisible(".evaluation-assignment-wrapper");
                assertClassPresent(".evaluation-student-wrapper", "workspace-evaluated");
                waitAndClick(".evaluation-student-name");
                waitForPresent("#grade");
                assertValue("#grade", "1/PYRAMUS@1/PYRAMUS");
                waitForPresent("select[name='assessor']");
                assertValue("select[name='assessor']", assessorId.toString());
                waitForPresent(".cke_contents");
                assertEquals("Test evaluation.", getCKEditorContent());
            } finally {
                deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            }
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) CourseAssessment(fi.otavanopisto.pyramus.rest.model.CourseAssessment) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) OffsetDateTime(java.time.OffsetDateTime) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 17 with CourseStaffMember

use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.

the class EvaluationTestsBase method evaluateStudentWorkspaceMaterialTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateStudentWorkspaceMaterialTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    Builder mockBuilder = mocker();
    try {
        mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
        Long courseId = 1l;
        login();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        try {
            WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
            WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nT0yyez23QwFXD3G0I8HzYeK&quot;,&quot;rightAnswers&quot;:[],&quot;columns&quot;:&quot;&quot;,&quot;hint&quot;:&quot;&quot;}\" /></object></p>", 1l, "EVALUATED");
            Long assessorId = getUserEntityIdForIdentifier(String.format("STAFF-%s", admin.getId()));
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            try {
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
                assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
                assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
                assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
                sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
                waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
                waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
                waitForPresentAndVisible(".notification-queue-item-success");
                waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
                logout();
                mockBuilder.mockLogin(admin).build();
                login();
                navigate(String.format("/evaluation"), true);
                waitAndClick("#filter-students-by-assessment-requested");
                waitAndClick(".assignment-submitted");
                addTextToCKEditor("Test evaluation.");
                selectOption("#grade", "1/PYRAMUS@1/PYRAMUS");
                selectOption("select[name='assessor']", assessorId.toString());
                click(".save-evaluation-button");
                waitForPresentAndVisible(".evaluation-assignment-wrapper");
                assertClassPresent(".evaluation-assignment-wrapper", "assignment-evaluated");
                waitAndClick(".assignment-submitted");
                waitForPresent("#grade");
                assertValue("#grade", "1/PYRAMUS@1/PYRAMUS");
                waitForPresent("select[name='assessor']");
                assertValue("select[name='assessor']", assessorId.toString());
                waitForPresent(".cke_contents");
                assertEquals("Test evaluation.", getCKEditorContent());
            } finally {
                deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            }
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 18 with CourseStaffMember

use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.

the class GuiderTestsBase method uploadFileToStudentTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER })
public void uploadFileToStudentTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "Person", UserRole.ADMINISTRATOR, "090978-1234", "testadmin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(3l, 3l, "Second", "User", "teststudent@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    Builder mockBuilder = mocker();
    mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
    login();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
    MockCourseStudent mcs = new MockCourseStudent(1l, workspace.getId(), student.getId());
    CourseStaffMember courseStaffMember = new CourseStaffMember(1l, 1l, admin.getId(), 7l);
    mockBuilder.addCourseStaffMember(workspace.getId(), courseStaffMember).addCourseStudent(workspace.getId(), mcs).build();
    try {
        navigate("/guider", true);
        waitAndClick(".gt-user .gt-user-meta-topic>span");
        waitAndClick(".gt-user .gt-tool-view-profile");
        File testFile = getTestFile();
        waitForPresent(".gt-user-files .gt-user-file-add input[type=\"file\"]");
        sendKeys(".gt-user-files .gt-user-file-add input[type=\"file\"]", testFile.getAbsolutePath());
        waitForPresent(".gt-user-file .gt-user-file-name a");
        scrollIntoView(".gt-user-file .gt-user-file-name a");
        assertTextIgnoreCase(".gt-user-file .gt-user-file-name a", testFile.getName());
        logout();
        mockBuilder.mockLogin(student).build();
        login();
        navigate("/records/", true);
        waitForPresent(".mf-item .mf-files .mf-file-name a");
        assertText(".mf-item .mf-files .mf-file-name a", "img_100x100_3x8bit_RGB_circles_center_0016.png");
    } finally {
        deleteWorkspace(workspace.getId());
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) File(java.io.File) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 19 with CourseStaffMember

use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.

the class NewEvaluationTestsBase method evaluateStudentWorkspaceTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateStudentWorkspaceTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    OffsetDateTime date = OffsetDateTime.of(2016, 11, 10, 1, 1, 1, 1, ZoneOffset.UTC);
    Builder mockBuilder = mocker();
    try {
        mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
        Long courseId = 2l;
        login();
        Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        OffsetDateTime created = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime begin = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime end = OffsetDateTime.of(2045, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        MockCourse mockCourse = new MockCourse(workspace.getId(), workspace.getName(), created, "test course", begin, end);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nT0yyez23QwFXD3G0I8HzYeK&quot;,&quot;rightAnswers&quot;:[],&quot;columns&quot;:&quot;&quot;,&quot;hint&quot;:&quot;&quot;}\" /></object></p>", 1l, "EVALUATED");
        try {
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
            assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
            assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
            assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
            sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
            waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
            waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
            waitForPresentAndVisible(".notification-queue-item-success");
            waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
            mockBuilder.mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, date).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, date).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests();
            logout();
            mockBuilder.mockLogin(admin).build();
            login();
            navigate(String.format("/evaluation2"), true);
            waitAndClick(".evaluate-button");
            waitAndClick(".workspace-evaluation-form-activate-button");
            waitForNotVisible(".workspace-evaluation-form-overlay");
            waitForPresentAndVisible(".cke_contents");
            waitAndClick(".cke_contents");
            getWebDriver().switchTo().activeElement().sendKeys("Test evaluation.");
            selectOption("#workspaceGrade", "PYRAMUS-1@PYRAMUS-1");
            mockBuilder.addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, true, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests().mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello! I'd like to get assessment.", false, true, date);
            mockBuilder.mockCourseAssessments(courseStudent, admin);
            waitAndClick("#workspaceSaveButton");
            waitForPresent(".notification-queue-item-success");
            waitAndClick(".remove-button .ui-button-text");
            assertVisible(".evaluation-well-done-container");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) OffsetDateTime(java.time.OffsetDateTime) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) MockCourse(fi.otavanopisto.muikku.mock.model.MockCourse) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 20 with CourseStaffMember

use of fi.otavanopisto.pyramus.rest.model.CourseStaffMember in project muikku by otavanopisto.

the class NewEvaluationTestsBase method evaluateStudentWorkspaceExerciseTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateStudentWorkspaceExerciseTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    OffsetDateTime date = OffsetDateTime.of(2016, 11, 10, 1, 1, 1, 1, ZoneOffset.UTC);
    Builder mockBuilder = mocker();
    try {
        mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
        Long courseId = 1l;
        login();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        OffsetDateTime created = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime begin = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime end = OffsetDateTime.of(2045, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        MockCourse mockCourse = new MockCourse(workspace.getId(), workspace.getName(), created, "test course", begin, end);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test exercise", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nT0yyez23QwFXD3G0I8HzYeK&quot;,&quot;rightAnswers&quot;:[],&quot;columns&quot;:&quot;&quot;,&quot;hint&quot;:&quot;&quot;}\" /></object></p>", 1l, "EVALUATED");
        try {
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
            assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
            assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
            assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
            sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
            waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
            waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
            waitForPresentAndVisible(".notification-queue-item-success");
            waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
            mockBuilder.mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, date).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, date).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests();
            logout();
            mockBuilder.mockLogin(admin).build();
            login();
            navigate(String.format("/evaluation2"), true);
            waitAndClick(".evaluate-button");
            waitAndClick(".assignment-title-wrapper");
            waitForPresentAndVisible(".assignment-wrapper .muikku-text-field");
            assertTextIgnoreCase(".assignment-wrapper .muikku-text-field", "field value");
            waitAndClick(".assignment-evaluate-button");
            waitUntilAnimationIsDone("#evaluationAssignmentEvaluateContainer");
            getWebDriver().switchTo().frame(findElementByCssSelector("#evaluationAssignmentEvaluateContainer .evaluation-modal-evaluate-form #cke_assignmentEvaluateFormLiteralEvaluation .cke_wysiwyg_frame"));
            sendKeys(".cke_contents_ltr", "Test evaluation.");
            getWebDriver().switchTo().defaultContent();
            selectOption("#workspaceGrade", "PYRAMUS-1@PYRAMUS-1");
            waitAndClick("#assignmentSaveButton");
            waitForPresent(".notification-queue-item-success");
            waitForPresentAndVisible(".assignment-wrapper .assignment-evaluated-label");
            waitForPresentAndVisible(".assignment-wrapper .assignment-grade .assignment-grade-data");
            assertTextIgnoreCase(".assignment-wrapper .assignment-grade .assignment-grade-data", "Excellent");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) OffsetDateTime(java.time.OffsetDateTime) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) MockCourse(fi.otavanopisto.muikku.mock.model.MockCourse) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Aggregations

CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)22 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)19 Workspace (fi.otavanopisto.muikku.atests.Workspace)18 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)18 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)18 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)18 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)18 Test (org.junit.Test)18 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)13 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)10 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)10 OffsetDateTime (java.time.OffsetDateTime)10 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)5 RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)2 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)2 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)2 WorkspaceUserEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceUserEntity)2 SchoolDataIdentifier (fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier)2