Search in sources :

Example 6 with QTI21ConfigurationCEPage

use of org.olat.selenium.page.qti.QTI21ConfigurationCEPage in project openolat by klemens.

the class ImsQTI21Test method qti21Course.

/**
 * Upload a test in QTI 2.1 format, create a course, bind
 * the test in a course element, run it and check if
 * the attempt go up.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21Course(@InitialPage LoginPage authorLoginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    // upload a test
    String qtiTestTitle = "Simple QTI 2.1 " + UUID.randomUUID();
    URL qtiTestUrl = JunitTestHelper.class.getResource("file_resources/qti21/simple_QTI_21_test.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile);
    // create a course
    String courseTitle = "Course QTI 2.1 " + UUID.randomUUID();
    navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
    String testNodeTitle = "QTI21Test-1";
    // create a course element of type CP with the CP that we create above
    CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser).edit();
    courseEditor.createNode("iqtest").nodeTitle(testNodeTitle).selectTabLearnContent().chooseTest(qtiTestTitle);
    QTI21ConfigurationCEPage configPage = new QTI21ConfigurationCEPage(browser);
    configPage.selectConfiguration().showScoreOnHomepage(true).saveConfiguration();
    // publish the course
    courseEditor.publish().quickPublish();
    // open the course and see the CP
    CoursePageFragment course = courseEditor.clickToolbarBack();
    course.clickTree().selectWithTitle(testNodeTitle);
    // 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());
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.start().answerSingleChoiceWithParagraph("Right").saveAnswer().endTest().assertOnCourseAttempts(1).assertOnCourseAssessmentTestScore(1);
}
Also used : CourseEditorPageFragment(org.olat.selenium.page.course.CourseEditorPageFragment) UserVO(org.olat.user.restapi.UserVO) QTI21ConfigurationCEPage(org.olat.selenium.page.qti.QTI21ConfigurationCEPage) CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) WebElement(org.openqa.selenium.WebElement) File(java.io.File) URL(java.net.URL) UserRestClient(org.olat.test.rest.UserRestClient) QTI21Page(org.olat.selenium.page.qti.QTI21Page) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Aggregations

File (java.io.File)6 URL (java.net.URL)6 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)6 Test (org.junit.Test)6 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)6 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)6 QTI21ConfigurationCEPage (org.olat.selenium.page.qti.QTI21ConfigurationCEPage)6 QTI21Page (org.olat.selenium.page.qti.QTI21Page)6 UserRestClient (org.olat.test.rest.UserRestClient)6 UserVO (org.olat.user.restapi.UserVO)6 WebElement (org.openqa.selenium.WebElement)6 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)2