use of org.olat.test.rest.UserRestClient in project openolat by klemens.
the class CourseTest method catalogRoundTrip.
/**
* Create a catalog, create a course, while publishing add the
* course to the catalog. Go to the catalog, find the course and
* open it.
*
* @param loginPage
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void catalogRoundTrip(@Drone @Administrator WebDriver adminBrowser, @Drone @User WebDriver userBrowser) throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
// administrator create the categories in the catalog
LoginPage adminLogin = LoginPage.getLoginPage(adminBrowser, deploymentUrl);
adminLogin.loginAs("administrator", "openolat").resume();
NavigationPage adminNavBar = new NavigationPage(adminBrowser);
String node1 = "First level " + UUID.randomUUID();
String node2_1 = "Second level first element " + UUID.randomUUID();
String node2_2 = "Second level second element " + UUID.randomUUID();
adminNavBar.openCatalogAdministration().addCatalogNode(node1, "First level of the catalog").selectNode(node1).addCatalogNode(node2_1, "First element of the second level").addCatalogNode(node2_2, "Second element of the second level");
// An author create a course and publish it under a category
// created above
LoginPage login = LoginPage.getLoginPage(browser, deploymentUrl);
login.loginAs(author.getLogin(), author.getPassword()).resume();
String courseTitle = "Catalog-Course-" + UUID.randomUUID();
navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser).edit();
courseEditor.publish().nextSelectNodes().selectAccess(UserAccess.guest).nextAccess().selectCatalog(true).selectCategory(node1, node2_2).finish();
// User logs in, go to "My courses", navigate the catalog and start
// the course
LoginPage userLogin = LoginPage.getLoginPage(userBrowser, deploymentUrl);
userLogin.loginAs(user.getLogin(), user.getPassword()).resume();
NavigationPage userNavBar = new NavigationPage(userBrowser);
userNavBar.openMyCourses().openCatalog().selectCatalogEntry(node1).selectCatalogEntry(node2_2).select(// go to the details page
courseTitle).start();
By courseTitleBy = By.cssSelector("div.o_course_run h2");
WebElement courseTitleEl = userBrowser.findElement(courseTitleBy);
Assert.assertTrue(courseTitleEl.getText().contains(courseTitle));
}
use of org.olat.test.rest.UserRestClient in project openolat by klemens.
the class CourseTest method confirmMembershipForCourse.
/**
* First, an administrator make in administration part
* the confirmation of group's membership mandatory if
* the group is created by an author.<br>
*
* An author create a course and a group and add two
* participants. The first user jump to the course
* with a rest url, log in, confirm its membership
* and see the course.<br>
* The second participant log-in, confirm its membership,
* go the "My courses" and visit the course.
*
* @param loginPage
* @param authorBrowser
* @param participantBrowser
* @param reiBrowser
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void confirmMembershipForCourse(@InitialPage LoginPage loginPage, @Drone @Author WebDriver authorBrowser, @Drone @Participant WebDriver participantBrowser, @Drone @Student WebDriver reiBrowser) throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei");
UserVO participant = new UserRestClient(deploymentUrl).createRandomUser();
// admin make the confirmation of membership mandatory
// for groups created by standard users.
loginPage.loginAs("administrator", "openolat").resume();
AdministrationPage administration = new NavigationPage(browser).openAdministration().openGroupSettings().setGroupConfirmationForAuthor(true);
// author create a course
String courseTitle = "Membership " + UUID.randomUUID();
LoginPage.getLoginPage(authorBrowser, deploymentUrl).loginAs(author).resume();
NavigationPage authorNavBar = new NavigationPage(authorBrowser);
authorNavBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
String groupName = "Groupship " + UUID.randomUUID();
MembersPage members = CoursePageFragment.getCourse(authorBrowser).members();
// create a group
members.selectBusinessGroups().createBusinessGroup(groupName, "-", 1, false, false);
// return to course
authorNavBar.openCourse(courseTitle);
// add the 2 participants to the group
members.selectMembers().addMember().searchMember(rei, true).nextUsers().nextOverview().selectGroupAsParticipant(groupName).nextPermissions().finish();
members.addMember().searchMember(participant, true).nextUsers().nextOverview().selectGroupAsParticipant(groupName).nextPermissions().finish();
members.clickToolbarBack();
// set the course for members only
CoursePageFragment.getCourse(authorBrowser).accessConfiguration().setUserAccess(UserAccess.registred);
String currentUrl = authorBrowser.getCurrentUrl();
int index = currentUrl.indexOf("/Access");
Assert.assertTrue(index > 0);
String courseUrl = currentUrl.substring(0, index);
// rest url -> login -> accept membership
reiBrowser.get(courseUrl);
new LoginPage(reiBrowser).loginAs(rei.getLogin(), rei.getPassword()).assertOnMembershipConfirmation().confirmMembership();
new CoursePageFragment(reiBrowser).assertOnCoursePage().assertOnTitle(courseTitle);
// participant login -> accept membership -> my courses -> course
LoginPage participantLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl);
participantLoginPage.loginAs(participant.getLogin(), participant.getPassword()).assertOnMembershipConfirmation().confirmMembership();
NavigationPage participantNavBar = new NavigationPage(participantBrowser);
participantNavBar.openMyCourses().select(courseTitle);
new CoursePageFragment(participantBrowser).assertOnCoursePage().assertOnTitle(courseTitle);
// reset the settings
administration.setGroupConfirmationForAuthor(false);
}
use of org.olat.test.rest.UserRestClient in project openolat by klemens.
the class CourseTest method courseAccessRules.
/**
* An author creates a course with 4 course elements. A folder
* which is visible to group, a forum which is visible to coaches,
* an assessment and an info visible to the students which passed
* the assessment above.<br>
* a student come and checks what it can see, the author make it
* pass the assessment and the student sees the info.
*
* @param loginPage
* @param kanuBrowser
* @param reiBrowser
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void courseAccessRules(@InitialPage LoginPage loginPage, @Drone @Student WebDriver reiBrowser) throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("rei");
loginPage.loginAs(author.getLogin(), author.getPassword());
// create a course
String courseTitle = "Course FO " + UUID.randomUUID();
navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
// go the authoring environment to create a forum
String bcTitle = "BC - " + UUID.randomUUID();
String foTitle = "FO - " + UUID.randomUUID();
String msTitle = "MS - " + UUID.randomUUID();
String infoTitle = "Info - " + UUID.randomUUID();
String groupName = "Students";
CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser).edit();
// folder is group protected
courseEditor.createNode("bc").nodeTitle(bcTitle).selectTabVisibility().setGroupCondition().createBusinessGroup(groupName);
// forum is coach exclusive
courseEditor.createNode("fo").nodeTitle(foTitle).selectTabVisibility().setCoachExclusive().save();
// assessment is open
courseEditor.createNode("ms").nodeTitle(msTitle);
// configure assessment
AssessmentCEConfigurationPage assessmentConfig = new AssessmentCEConfigurationPage(browser);
assessmentConfig.selectConfiguration().setScoreAuto(0.0f, 6.0f, 4.0f);
// wiki is assessment dependent
courseEditor.createNode("info").nodeTitle(infoTitle).selectTabVisibility().setAssessmentCondition(1).save();
OOGraphene.scrollTop(browser);
courseEditor.publish().nextSelectNodes().selectAccess(UserAccess.membersOnly).nextAccess().selectCatalog(false).nextCatalog().finish();
courseEditor.clickToolbarBack();
// add a member to the group we create above
MembersPage members = CoursePageFragment.getCourse(browser).members();
members.addMember().searchMember(rei, true).nextUsers().nextOverview().selectGroupAsParticipant(groupName).nextPermissions().finish();
// participant search the course
LoginPage.getLoginPage(reiBrowser, deploymentUrl).loginAs(rei).resume();
NavigationPage reiNavBar = new NavigationPage(reiBrowser);
reiNavBar.openMyCourses().select(courseTitle);
MenuTreePageFragment reiTree = new MenuTreePageFragment(reiBrowser);
reiTree.assertWithTitle(bcTitle.substring(0, 20)).assertWithTitle(msTitle.substring(0, 20)).assertTitleNotExists(foTitle.substring(0, 20)).assertTitleNotExists(infoTitle.substring(0, 20));
// author set assessment to passed
AssessmentToolPage assessmentTool = members.clickToolbarBack().assessmentTool();
assessmentTool.users().assertOnUsers(rei).selectUser(rei).selectCourseNode(msTitle.substring(0, 20)).setAssessmentScore(5.5f).assertUserPassedCourseNode(msTitle.substring(0, 20));
// student can see info
reiTree.selectRoot().assertWithTitle(bcTitle.substring(0, 20)).assertWithTitle(msTitle.substring(0, 20)).assertTitleNotExists(foTitle.substring(0, 20)).assertWithTitle(infoTitle.substring(0, 20));
// author can see all
assessmentTool.clickToolbarRootCrumb().clickTree().assertWithTitle(bcTitle.substring(0, 20)).assertWithTitle(msTitle.substring(0, 20)).assertWithTitle(foTitle.substring(0, 20)).assertWithTitle(infoTitle.substring(0, 20));
}
use of org.olat.test.rest.UserRestClient in project openolat by klemens.
the class CourseTest method courseRename.
/**
* Test that renaming the root node is reflected after
* publishing.
*
* @param loginPage
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void courseRename(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
loginPage.loginAs(author.getLogin(), author.getPassword());
// create a course
String courseTitle = "Course to rename-" + UUID.randomUUID().toString();
navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
// open course editor
CoursePageFragment course = CoursePageFragment.getCourse(browser);
CourseEditorPageFragment editor = course.assertOnCoursePage().assertOnTitle(courseTitle).openToolsMenu().edit();
// create a course element of type info messages
course = editor.assertOnEditor().createNode("info").autoPublish();
// check that the root node has the name of the repository entry
course.assertOnTitle(courseTitle);
// rename the root node
String newCourseName = "Renamed course";
course = course.edit().selectRoot().nodeTitle(newCourseName).autoPublish();
// assert the changed name
course.assertOnTitle(newCourseName);
}
use of org.olat.test.rest.UserRestClient 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);
}
Aggregations