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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations