Search in sources :

Example 31 with UserToolsPage

use of org.olat.selenium.page.user.UserToolsPage in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21Course_suspend.

/**
 * 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, allow suspending the test,
 * show scores and assessment results.<br>
 * Then run it and at the middle of the test, suspend it, log out.
 * Return with resume to the course and resume the test, finish 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_suspend(@InitialPage LoginPage authorLoginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    // upload a test
    String qtiTestTitle = "No skipping 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);
    // 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().selectLayoutConfiguration().overrideConfiguration().enableSuspend().saveLayoutConfiguration();
    // 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("Correct").saveAnswer().answerMultipleChoice("Correct").saveAnswer().suspendTest();
    // log out
    new UserToolsPage(browser).logout();
    // return
    authorLoginPage.loginAs(author.getLogin(), author.getPassword()).resume();
    // resume the course, resume the test
    qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.start().assertOnAssessmentItem("Kprim").answerCorrectKPrim("True", "Right").answerIncorrectKPrim("False", "Wrong").saveAnswer().answerGapText("43", "_RESPONSE_1").saveAnswer().endTest().assertOnAssessmentResults().assertOnAssessmentTestMaxScore(4).assertOnAssessmentTestScore(4).assertOnAssessmentTestPassed().closeAssessmentResults();
    // check the result on the start page
    qtiPage.assertOnCourseAssessmentTestScore(4).assertOnCourseAttempts(1);
}
Also used : CourseEditorPageFragment(org.olat.selenium.page.course.CourseEditorPageFragment) UserToolsPage(org.olat.selenium.page.user.UserToolsPage) 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 32 with UserToolsPage

use of org.olat.selenium.page.user.UserToolsPage 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 33 with UserToolsPage

use of org.olat.selenium.page.user.UserToolsPage in project OpenOLAT by OpenOLAT.

the class UserTest method resumeDisabled.

/**
 * Disable the resume function and check that the resume
 * popup don't stay in our way after login.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void resumeDisabled(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    // set the preferences to resume automatically
    UserToolsPage userTools = new UserToolsPage(browser);
    userTools.openUserToolsMenu().openMySettings().openPreferences().setResume(ResumeOption.none);
    // logout
    userTools.logout();
    // login again
    loginPage.assertOnLoginPage().loginAs(user.getLogin(), user.getPassword()).assertLoggedIn(user);
    // and check that we don't see the resume button
    List<WebElement> resumeButtons = browser.findElements(LoginPage.resumeButton);
    Assert.assertTrue(resumeButtons.isEmpty());
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 34 with UserToolsPage

use of org.olat.selenium.page.user.UserToolsPage in project OpenOLAT by OpenOLAT.

the class UserTest method loginInHomeWithRestUrl.

/**
 * Jump to notifications in home, go to the courses and return
 * to home's notification with a REST url.
 *
 * @see https://jira.openolat.org/browse/OO-1962
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void loginInHomeWithRestUrl(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserRestClient userClient = new UserRestClient(deploymentUrl);
    UserVO user = userClient.createRandomUser();
    // load dmz
    loginPage.assertOnLoginPage();
    String jumpToNotificationsUrl = deploymentUrl.toString() + "url/HomeSite/" + user.getKey() + "/notifications/0";
    browser.get(jumpToNotificationsUrl);
    loginPage.loginAs(user.getLogin(), user.getPassword());
    // must see the notification
    new UserToolsPage(browser).assertOnNotifications();
    // go to courses
    navBar.openMyCourses();
    // use url to go to notifications
    String goToNotificationsUrl = deploymentUrl.toString() + "auth/HomeSite/" + user.getKey() + "/notifications/0";
    browser.get(goToNotificationsUrl);
    // must see the notification
    new UserToolsPage(browser).assertOnNotifications();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 35 with UserToolsPage

use of org.olat.selenium.page.user.UserToolsPage in project OpenOLAT by OpenOLAT.

the class UserTest method resumeCourseAutomatically.

/**
 * Set the resume preferences to automatically resume the session,
 * open a course, log out, log in and check if the course is resumed.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
public void resumeCourseAutomatically(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    // deploy a course
    CourseVO course = new RepositoryRestClient(deploymentUrl).deployDemoCourse();
    // login
    loginPage.assertOnLoginPage().loginAs(user.getLogin(), user.getPassword());
    // set the preferences to resume automatically
    UserToolsPage userTools = new UserToolsPage(browser);
    userTools.openUserToolsMenu().openMySettings().assertOnUserSettings().openPreferences().assertOnUserPreferences().setResume(ResumeOption.auto);
    // open a course via REST url
    CoursePageFragment coursePage = CoursePageFragment.getCourse(browser, deploymentUrl, course);
    coursePage.assertOnCoursePage().clickTree();
    // logout
    userTools.logout();
    // login again
    loginPage.assertOnLoginPage().loginAs(user.getLogin(), user.getPassword());
    // check the title of the course if any
    WebElement courseTitle = browser.findElement(By.tagName("h2"));
    Assert.assertNotNull(courseTitle);
    Assert.assertTrue(courseTitle.isDisplayed());
    Assert.assertTrue(courseTitle.getText().contains(course.getTitle()));
}
Also used : RepositoryRestClient(org.olat.test.rest.RepositoryRestClient) CourseVO(org.olat.restapi.support.vo.CourseVO) UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) WebElement(org.openqa.selenium.WebElement) UserRestClient(org.olat.test.rest.UserRestClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)64 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)64 UserVO (org.olat.user.restapi.UserVO)64 UserRestClient (org.olat.test.rest.UserRestClient)62 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)60 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)30 LoginPage (org.olat.selenium.page.LoginPage)24 NavigationPage (org.olat.selenium.page.NavigationPage)18 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)16 File (java.io.File)14 URL (java.net.URL)14 WebElement (org.openqa.selenium.WebElement)14 PortfolioV2HomePage (org.olat.selenium.page.portfolio.PortfolioV2HomePage)12 AuthoringEnvPage (org.olat.selenium.page.repository.AuthoringEnvPage)12 MembersPage (org.olat.selenium.page.course.MembersPage)10 BinderPage (org.olat.selenium.page.portfolio.BinderPage)10 Calendar (java.util.Calendar)8 MediaCenterPage (org.olat.selenium.page.portfolio.MediaCenterPage)8 AssessmentCEConfigurationPage (org.olat.selenium.page.course.AssessmentCEConfigurationPage)6 AssessmentToolPage (org.olat.selenium.page.course.AssessmentToolPage)6