Search in sources :

Example 56 with QTI21Page

use of org.olat.selenium.page.qti.QTI21Page in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21TestFlow_suspend.

/**
 * Test suspend. An author upload a test, set "enable suspend"
 * and make the test visible to registered users. A second user
 * open the test, does nothing, suspends and log out (check a possible red
 * screen in the next step), log in, answer 3 questions, suspends
 * and log out. It log in a last time and finish the test successfully.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21TestFlow_suspend(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    // upload a test
    String qtiTestTitle = "Suspend QTI 2.1 " + UUID.randomUUID();
    URL qtiTestUrl = JunitTestHelper.class.getResource("file_resources/qti21/test_4_no_skipping.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile).clickToolbarRootCrumb();
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.options().showResults(Boolean.TRUE, QTI21AssessmentResultsOptions.allOptions()).enableSuspend().save();
    qtiPage.accessConfiguration().setUserAccess(UserAccess.registred).clickToolbarBack();
    // check simple time limit
    qtiPage.assertOnAssessmentItem("Single choice");
    // a user search the content package
    LoginPage userLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl);
    userLoginPage.loginAs(ryomou.getLogin(), ryomou.getPassword()).resume();
    NavigationPage userNavBar = new NavigationPage(ryomouBrowser);
    userNavBar.openMyCourses().openSearch().extendedSearch(qtiTestTitle).select(qtiTestTitle).start();
    QTI21Page userQtiPage = QTI21Page.getQTI12Page(ryomouBrowser);
    userQtiPage.assertOnAssessmentItem("Single choice").suspendTest();
    // log out
    new UserToolsPage(ryomouBrowser).logout();
    // log in and resume test
    userLoginPage.loginAs(ryomou.getLogin(), ryomou.getPassword()).resume();
    userQtiPage = QTI21Page.getQTI12Page(ryomouBrowser);
    userQtiPage.assertOnAssessmentItem("Single choice").answerSingleChoiceWithParagraph("Correct").saveAnswer().answerMultipleChoice("Correct").saveAnswer().assertOnAssessmentItem("Kprim").answerCorrectKPrim("True", "Right").answerIncorrectKPrim("False", "Wrong").saveAnswer().suspendTest();
    // second log out
    new UserToolsPage(ryomouBrowser).logout();
    // log in and resume test
    userLoginPage.loginAs(ryomou.getLogin(), ryomou.getPassword()).resume();
    userQtiPage = QTI21Page.getQTI12Page(ryomouBrowser);
    userQtiPage.assertOnAssessmentItem("Numerical input").answerGapText("42", "_RESPONSE_1").saveAnswer().endTest().assertOnAssessmentResults().assertOnAssessmentTestMaxScore(4).assertOnAssessmentTestScore(4).assertOnAssessmentTestPassed();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) NavigationPage(org.olat.selenium.page.NavigationPage) File(java.io.File) URL(java.net.URL) LoginPage(org.olat.selenium.page.LoginPage) 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)

Example 57 with QTI21Page

use of org.olat.selenium.page.qti.QTI21Page in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21TestFlow_noParts_noFeedbacks.

/**
 * Test the flow of the simplest possible test with our
 * optimization (jump automatically to the next question,
 * jump automatically the close test). The test has one
 * part and 2 questions, no feedbacks, no review allowed...
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21TestFlow_noParts_noFeedbacks(@InitialPage LoginPage authorLoginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    // upload a test
    String qtiTestTitle = "With parts QTI 2.1 " + UUID.randomUUID();
    URL qtiTestUrl = JunitTestHelper.class.getResource("file_resources/qti21/test_without_feedbacks.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile).clickToolbarRootCrumb();
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.assertOnAssessmentItem().answerSingleChoiceWithParagraph("Incorrect response").saveAnswer().assertOnAssessmentItem("Second question").selectItem("First question").assertOnAssessmentItem("First question").answerSingleChoiceWithParagraph("Correct response").saveAnswer().answerMultipleChoice("Correct response").saveAnswer().endTest().assertOnAssessmentTestTerminated();
}
Also used : UserVO(org.olat.user.restapi.UserVO) 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)

Example 58 with QTI21Page

use of org.olat.selenium.page.qti.QTI21Page in project OpenOLAT by OpenOLAT.

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)

Example 59 with QTI21Page

use of org.olat.selenium.page.qti.QTI21Page in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21Course_lmsHidden_results.

/**
 * Upload a test in QTI 2.1 format, create a course, bind
 * the test in a course element, customize the options
 * with full window mode, show scores and assessment results.
 * Then run it and check if the assessment results appears after
 * closing the test and on the start page of the test course element.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21Course_lmsHidden_results(@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.selectLayoutConfiguration().overrideConfiguration().fullWindow().saveLayoutConfiguration();
    configPage.selectConfiguration().showScoreOnHomepage(true).showResultsOnHomepage(Boolean.TRUE, QTI21AssessmentResultsOptions.allOptions()).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().assertOnAssessmentResults().closeAssessmentResults().assertOnCourseAttempts(1).assertOnCourseAssessmentTestScore(1).assertOnAssessmentResults();
}
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)

Example 60 with QTI21Page

use of org.olat.selenium.page.qti.QTI21Page in project OpenOLAT by OpenOLAT.

the class ImsQTI21InteractionsTest method qti21MatchInteraction.

/**
 * Check if the classic match interaction return its 3 points.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21MatchInteraction(@InitialPage LoginPage authorLoginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    // upload a test
    String qtiTestTitle = "Match QTI 2.1 " + UUID.randomUUID();
    URL qtiTestUrl = JunitTestHelper.class.getResource("file_resources/qti21/simple_QTI_21_match_ims.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile).clickToolbarRootCrumb();
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.options().showResults(Boolean.TRUE, QTI21AssessmentResultsOptions.allOptions()).save();
    // to the test and spot it
    qtiPage.clickToolbarBack().assertOnAssessmentItem().answerMatch("Prospero", "Romeo and Juliet", true).answerMatch("Capulet", "Romeo and Juliet", true).answerMatch("Demetrius", "A Midsummer", true).answerMatch("Lysander", "A Midsummer", true).answerMatch("Prospero", "Romeo and Juliet", false).answerMatch("Prospero", "The Tempest", true).saveAnswer().endTest();
    // check the results
    qtiPage.assertOnAssessmentResults().assertOnAssessmentItemScore("Characters and Plays", 3);
}
Also used : UserVO(org.olat.user.restapi.UserVO) 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

RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)96 Test (org.junit.Test)96 QTI21Page (org.olat.selenium.page.qti.QTI21Page)96 UserRestClient (org.olat.test.rest.UserRestClient)96 UserVO (org.olat.user.restapi.UserVO)96 File (java.io.File)60 URL (java.net.URL)60 QTI21EditorPage (org.olat.selenium.page.qti.QTI21EditorPage)46 LoginPage (org.olat.selenium.page.LoginPage)40 NavigationPage (org.olat.selenium.page.NavigationPage)40 QTI21MatchEditorPage (org.olat.selenium.page.qti.QTI21MatchEditorPage)10 QTI21MultipleChoiceEditorPage (org.olat.selenium.page.qti.QTI21MultipleChoiceEditorPage)8 QTI21SingleChoiceEditorPage (org.olat.selenium.page.qti.QTI21SingleChoiceEditorPage)8 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)6 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)6 QTI21ConfigurationCEPage (org.olat.selenium.page.qti.QTI21ConfigurationCEPage)6 QTI21GapEntriesEditorPage (org.olat.selenium.page.qti.QTI21GapEntriesEditorPage)6 QTI21HotspotEditorPage (org.olat.selenium.page.qti.QTI21HotspotEditorPage)6 QTI21LobEditorPage (org.olat.selenium.page.qti.QTI21LobEditorPage)6 WebElement (org.openqa.selenium.WebElement)6