Search in sources :

Example 36 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21TestFlow_noParts_withFeedbacks.

/**
 * Test the flow of a test with questions feedbacks and test
 * feedback.
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21TestFlow_noParts_withFeedbacks(@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_with_feedbacks.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile).clickToolbarRootCrumb();
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.assertOnAssessmentItem().answerSingleChoiceWithParagraph("Wrong answer").saveAnswer().assertFeedback("Oooops").answerSingleChoiceWithParagraph("Correct answer").saveAnswer().assertFeedback("Well done").nextAnswer().assertOnAssessmentItem("Numerical entry").answerGapText("69", "_RESPONSE_1").saveAnswer().assertFeedback("Not really").answerGapText("42", "_RESPONSE_1").saveAnswer().assertFeedback("Ok").endTest().assertOnAssessmentTestFeedback("All right").closeTest().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 37 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21TestFlow_noParts_feedbacksAndResults.

/**
 * A test with a single part, feedback for questions and
 * tests and the resource options "show results at the end
 * of the test".
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21TestFlow_noParts_feedbacksAndResults(@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_with_feedbacks.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile);
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.clickToolbarBack().options().showResults(Boolean.TRUE, QTI21AssessmentResultsOptions.allOptions()).save();
    qtiPage.clickToolbarBack().assertOnAssessmentItem().answerSingleChoiceWithParagraph("Wrong answer").saveAnswer().assertFeedback("Oooops").nextAnswer().assertOnAssessmentItem("Numerical entry").answerGapText("42", "_RESPONSE_1").saveAnswer().assertFeedback("Ok").endTest().assertOnAssessmentTestFeedback("Not for the best").closeTest().assertOnAssessmentTestMaxScore(2).assertOnAssessmentTestScore(1).assertOnAssessmentTestNotPassed();
}
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 38 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class ImsQTI21Test method qti21TestFlow_parts_noFeedbacksButResults.

/**
 * A test with a single part, feedback for questions and
 * tests and the resource options "show results at the end
 * of the test".
 *
 * @param authorLoginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void qti21TestFlow_parts_noFeedbacksButResults(@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_parts_without_feedbacks.zip");
    File qtiTestFile = new File(qtiTestUrl.toURI());
    navBar.openAuthoringEnvironment().uploadResource(qtiTestTitle, qtiTestFile);
    QTI21Page qtiPage = QTI21Page.getQTI12Page(browser);
    qtiPage.clickToolbarBack().options().showResults(Boolean.TRUE, QTI21AssessmentResultsOptions.allOptions()).save();
    qtiPage.clickToolbarBack().startTestPart().selectItem("First question").assertOnAssessmentItem("First question").answerSingleChoiceWithParagraph("Correct").saveAnswer().assertOnAssessmentItem("Second question").answerMultipleChoice("True").saveAnswer().endTestPart().selectItem("Third question").assertOnAssessmentItem("Third question").answerMultipleChoice("Correct").saveAnswer().answerCorrectKPrim("True", "Right").answerIncorrectKPrim("Wrong", "False").saveAnswer().endTestPart().assertOnAssessmentTestMaxScore(4).assertOnAssessmentTestScore(4).assertOnAssessmentTestPassed();
}
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 39 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class CourseTest method getTutors.

@Test
public void getTutors() throws IOException, URISyntaxException {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("Course-coach");
    RepositoryEntry repositoryEntry = repositoryManager.lookupRepositoryEntry(course1, true);
    repositoryService.addRole(coach, repositoryEntry, GroupRoles.coach.name());
    dbInstance.intermediateCommit();
    // get them
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("/repo/courses/" + course1.getResourceableId() + "/tutors").build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    InputStream body = response.getEntity().getContent();
    Assert.assertNotNull(body);
    List<UserVO> tutorVOs = parseUserArray(body);
    Assert.assertNotNull(tutorVOs);
    boolean found = false;
    for (UserVO tutorVo : tutorVOs) {
        if (tutorVo.getKey().equals(coach.getKey())) {
            found = true;
        }
    }
    Assert.assertTrue(found);
}
Also used : UserVO(org.olat.user.restapi.UserVO) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) URI(java.net.URI) Test(org.junit.Test)

Example 40 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class CourseTest method addParticipants.

@Test
public void addParticipants() throws IOException, URISyntaxException {
    Assert.assertTrue(conn.login("administrator", "openolat"));
    ICourse course = CoursesWebService.createEmptyCourse(admin, "course1", "course1 long name", null);
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("rest-part-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("rest-part-2");
    dbInstance.commitAndCloseSession();
    // add the 2 participants to the course
    UserVO[] newParticipants = new UserVO[2];
    newParticipants[0] = UserVOFactory.get(participant1);
    newParticipants[1] = UserVOFactory.get(participant2);
    URI request = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(course.getResourceableId().toString()).path("participants").build();
    HttpPut method = conn.createPut(request, MediaType.APPLICATION_JSON, true);
    conn.addJsonEntity(method, newParticipants);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    // check that they are course members
    RepositoryEntry repositoryEntry = repositoryManager.lookupRepositoryEntry(course, true);
    boolean isParticipant1 = repositoryService.hasRole(participant1, repositoryEntry, GroupRoles.participant.name());
    boolean isParticipant2 = repositoryService.hasRole(participant2, repositoryEntry, GroupRoles.participant.name());
    dbInstance.commit();
    Assert.assertTrue(isParticipant1);
    Assert.assertTrue(isParticipant2);
}
Also used : UserVO(org.olat.user.restapi.UserVO) HttpResponse(org.apache.http.HttpResponse) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Aggregations

UserVO (org.olat.user.restapi.UserVO)364 Test (org.junit.Test)332 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)260 UserRestClient (org.olat.test.rest.UserRestClient)258 LoginPage (org.olat.selenium.page.LoginPage)114 NavigationPage (org.olat.selenium.page.NavigationPage)110 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)102 QTI21Page (org.olat.selenium.page.qti.QTI21Page)96 URL (java.net.URL)90 File (java.io.File)88 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)84 URI (java.net.URI)72 HttpResponse (org.apache.http.HttpResponse)72 Identity (org.olat.core.id.Identity)72 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)64 WebElement (org.openqa.selenium.WebElement)48 QTI21EditorPage (org.olat.selenium.page.qti.QTI21EditorPage)46 HttpGet (org.apache.http.client.methods.HttpGet)40 MembersPage (org.olat.selenium.page.course.MembersPage)36 AuthoringEnvPage (org.olat.selenium.page.repository.AuthoringEnvPage)34