Search in sources :

Example 1 with AssessmentModePage

use of org.olat.selenium.page.course.AssessmentModePage in project openolat by klemens.

the class AssessmentTest method assessmentMode_manual.

/**
 * An author upload a test, create a course with a test course
 * element, publish the course, add 2 students (Ryomou and Kanu)
 * to the course, configure an assessment.<br />
 * A first student log in before the assessment is started by the
 * author, the second log-in after the begin of the assessment.
 * Both pass the test. The Author ends the assessment. The two
 * students wait the end of the assessment and go back to normal
 * activities. The author checks the students pass the test in the
 * assessment tool.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void assessmentMode_manual(@InitialPage LoginPage authorLoginPage, @Drone @Student WebDriver ryomouBrowser, @Drone @Participant WebDriver kanuBrowser) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
    UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("Kanu");
    // upload a test
    String qtiTestTitle = "QTI-Test-1.2-" + UUID.randomUUID();
    URL qtiTestUrl = JunitTestHelper.class.getResource("file_resources/e4_test.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile);
    // create a course
    String courseTitle = "Course-With-QTI-Test-1.2-" + UUID.randomUUID();
    navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
    // create a course element of type CP with the CP that we create above
    String testNodeTitle = "Test-QTI-1.2";
    CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser).edit();
    courseEditor.createNode("iqtest").nodeTitle(testNodeTitle).selectTabLearnContent().chooseTest(qtiTestTitle);
    // publish the course
    courseEditor.publish().quickPublish();
    // open the course and see the test start page
    CoursePageFragment courseRuntime = courseEditor.clickToolbarBack();
    courseRuntime.clickTree().selectWithTitle(testNodeTitle);
    OOGraphene.closeBlueMessageWindow(browser);
    // check that the title of the start page of test is correct
    WebElement testH2 = browser.findElement(By.cssSelector("div.o_course_run h2"));
    Assert.assertEquals(testNodeTitle, testH2.getText().trim());
    // add Ryomou and Kanu as a course member
    courseRuntime.members().quickAdd(ryomou);
    courseRuntime.members().quickAdd(kanu);
    // Kanu log in
    LoginPage kanuLoginPage = LoginPage.getLoginPage(kanuBrowser, deploymentUrl);
    kanuLoginPage.loginAs(kanu.getLogin(), kanu.getPassword()).resume();
    // prepare and start an assessment
    Calendar cal = Calendar.getInstance();
    Date begin = cal.getTime();
    cal.add(Calendar.MINUTE, 5);
    Date end = cal.getTime();
    String assessmentName = "Assessment-" + UUID.randomUUID();
    courseRuntime.assessmentConfiguration().createAssessmentMode().editAssessment(assessmentName, begin, end, true).save().start(assessmentName).confirmStart();
    // Ryomou opens the course
    LoginPage ryomouLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl);
    ryomouLoginPage.loginAs(ryomou.getLogin(), ryomou.getPassword());
    // start the assessment
    AssessmentModePage ryomouAssessment = new AssessmentModePage(ryomouBrowser).startAssessment(false);
    // go to the test
    CoursePageFragment ryomouTestCourse = new CoursePageFragment(ryomouBrowser);
    ryomouTestCourse.clickTree().selectWithTitle(testNodeTitle);
    // pass the test
    QTI12Page.getQTI12Page(ryomouBrowser).passE4(ryomou);
    // Kanu makes the test
    AssessmentModePage kanuAssessment = new AssessmentModePage(kanuBrowser).startAssessment(true);
    // go to the test
    CoursePageFragment kanuTestCourse = new CoursePageFragment(kanuBrowser);
    kanuTestCourse.clickTree().selectWithTitle(testNodeTitle);
    // pass the test
    QTI12Page.getQTI12Page(kanuBrowser).passE4(kanu);
    // Author ends the test
    courseRuntime.assessmentConfiguration().stop(assessmentName).confirmStop();
    By continueBy = By.className("o_sel_assessment_continue");
    OOGraphene.waitElement(continueBy, 10, ryomouBrowser);
    OOGraphene.waitElement(continueBy, 10, kanuBrowser);
    kanuAssessment.backToOpenOLAT();
    ryomouAssessment.backToOpenOLAT();
    // Author check if they pass the test
    navBar.openMyCourses().select(courseTitle);
    // open the assessment tool
    AssessmentToolPage assessmentTool = new CoursePageFragment(browser).assessmentTool();
    assessmentTool.users().assertOnUsers(ryomou).assertOnUsers(kanu).selectUser(ryomou).assertPassed(ryomou);
}
Also used : CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) Calendar(java.util.Calendar) WebElement(org.openqa.selenium.WebElement) URL(java.net.URL) LoginPage(org.olat.selenium.page.LoginPage) Date(java.util.Date) UserRestClient(org.olat.test.rest.UserRestClient) AssessmentModePage(org.olat.selenium.page.course.AssessmentModePage) CourseEditorPageFragment(org.olat.selenium.page.course.CourseEditorPageFragment) UserVO(org.olat.user.restapi.UserVO) By(org.openqa.selenium.By) AssessmentToolPage(org.olat.selenium.page.course.AssessmentToolPage) File(java.io.File) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 2 with AssessmentModePage

use of org.olat.selenium.page.course.AssessmentModePage in project OpenOLAT by OpenOLAT.

the class AssessmentTest method assessmentMode_manual.

/**
 * An author upload a test, create a course with a test course
 * element, publish the course, add 2 students (Ryomou and Kanu)
 * to the course, configure an assessment.<br />
 * A first student log in before the assessment is started by the
 * author, the second log-in after the begin of the assessment.
 * Both pass the test. The Author ends the assessment. The two
 * students wait the end of the assessment and go back to normal
 * activities. The author checks the students pass the test in the
 * assessment tool.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void assessmentMode_manual(@InitialPage LoginPage authorLoginPage, @Drone @Student WebDriver ryomouBrowser, @Drone @Participant WebDriver kanuBrowser) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
    UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("Kanu");
    // upload a test
    String qtiTestTitle = "QTI-Test-1.2-" + UUID.randomUUID();
    URL qtiTestUrl = JunitTestHelper.class.getResource("file_resources/e4_test.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile);
    // create a course
    String courseTitle = "Course-With-QTI-Test-1.2-" + UUID.randomUUID();
    navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
    // create a course element of type CP with the CP that we create above
    String testNodeTitle = "Test-QTI-1.2";
    CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser).edit();
    courseEditor.createNode("iqtest").nodeTitle(testNodeTitle).selectTabLearnContent().chooseTest(qtiTestTitle);
    // publish the course
    courseEditor.publish().quickPublish();
    // open the course and see the test start page
    CoursePageFragment courseRuntime = courseEditor.clickToolbarBack();
    courseRuntime.clickTree().selectWithTitle(testNodeTitle);
    OOGraphene.closeBlueMessageWindow(browser);
    // check that the title of the start page of test is correct
    WebElement testH2 = browser.findElement(By.cssSelector("div.o_course_run h2"));
    Assert.assertEquals(testNodeTitle, testH2.getText().trim());
    // add Ryomou and Kanu as a course member
    courseRuntime.members().quickAdd(ryomou);
    courseRuntime.members().quickAdd(kanu);
    // Kanu log in
    LoginPage kanuLoginPage = LoginPage.getLoginPage(kanuBrowser, deploymentUrl);
    kanuLoginPage.loginAs(kanu.getLogin(), kanu.getPassword()).resume();
    // prepare and start an assessment
    Calendar cal = Calendar.getInstance();
    Date begin = cal.getTime();
    cal.add(Calendar.MINUTE, 5);
    Date end = cal.getTime();
    String assessmentName = "Assessment-" + UUID.randomUUID();
    courseRuntime.assessmentConfiguration().createAssessmentMode().editAssessment(assessmentName, begin, end, true).save().start(assessmentName).confirmStart();
    // Ryomou opens the course
    LoginPage ryomouLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl);
    ryomouLoginPage.loginAs(ryomou.getLogin(), ryomou.getPassword());
    // start the assessment
    AssessmentModePage ryomouAssessment = new AssessmentModePage(ryomouBrowser).startAssessment(false);
    // go to the test
    CoursePageFragment ryomouTestCourse = new CoursePageFragment(ryomouBrowser);
    ryomouTestCourse.clickTree().selectWithTitle(testNodeTitle);
    // pass the test
    QTI12Page.getQTI12Page(ryomouBrowser).passE4(ryomou);
    // Kanu makes the test
    AssessmentModePage kanuAssessment = new AssessmentModePage(kanuBrowser).startAssessment(true);
    // go to the test
    CoursePageFragment kanuTestCourse = new CoursePageFragment(kanuBrowser);
    kanuTestCourse.clickTree().selectWithTitle(testNodeTitle);
    // pass the test
    QTI12Page.getQTI12Page(kanuBrowser).passE4(kanu);
    // Author ends the test
    courseRuntime.assessmentConfiguration().stop(assessmentName).confirmStop();
    By continueBy = By.className("o_sel_assessment_continue");
    OOGraphene.waitElement(continueBy, 10, ryomouBrowser);
    OOGraphene.waitElement(continueBy, 10, kanuBrowser);
    kanuAssessment.backToOpenOLAT();
    ryomouAssessment.backToOpenOLAT();
    // Author check if they pass the test
    navBar.openMyCourses().select(courseTitle);
    // open the assessment tool
    AssessmentToolPage assessmentTool = new CoursePageFragment(browser).assessmentTool();
    assessmentTool.users().assertOnUsers(ryomou).assertOnUsers(kanu).selectUser(ryomou).assertPassed(ryomou);
}
Also used : CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) Calendar(java.util.Calendar) WebElement(org.openqa.selenium.WebElement) URL(java.net.URL) LoginPage(org.olat.selenium.page.LoginPage) Date(java.util.Date) UserRestClient(org.olat.test.rest.UserRestClient) AssessmentModePage(org.olat.selenium.page.course.AssessmentModePage) CourseEditorPageFragment(org.olat.selenium.page.course.CourseEditorPageFragment) UserVO(org.olat.user.restapi.UserVO) By(org.openqa.selenium.By) AssessmentToolPage(org.olat.selenium.page.course.AssessmentToolPage) File(java.io.File) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Aggregations

File (java.io.File)2 URL (java.net.URL)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)2 Test (org.junit.Test)2 LoginPage (org.olat.selenium.page.LoginPage)2 AssessmentModePage (org.olat.selenium.page.course.AssessmentModePage)2 AssessmentToolPage (org.olat.selenium.page.course.AssessmentToolPage)2 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)2 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)2 UserRestClient (org.olat.test.rest.UserRestClient)2 UserVO (org.olat.user.restapi.UserVO)2 By (org.openqa.selenium.By)2 WebElement (org.openqa.selenium.WebElement)2