use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class EvaluationFormResponseDAOTest method createResponseforPortfolio.
@Test
public void createResponseforPortfolio() {
// prepare a test case with the binder up to the page body
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("eva-1");
BinderImpl binder = binderDao.createAndPersist("Binder evaluation 1", "A binder with an evaluation", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commit();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with an evalutation.", null, null, true, reloadedSection, null);
dbInstance.commit();
RepositoryEntry formEntry = createFormEntry("Eva. form for responses");
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
dbInstance.commit();
// create a response
String responseIdentifier = UUID.randomUUID().toString();
BigDecimal numericalValue = new BigDecimal("2.2");
String stringuifiedResponse = numericalValue.toPlainString();
Path fileResponse = Paths.get("this", "is", "a", "path");
EvaluationFormResponse response = evaluationFormResponseDao.createResponse(responseIdentifier, numericalValue, stringuifiedResponse, fileResponse, session);
dbInstance.commit();
Assert.assertNotNull(response);
Assert.assertNotNull(response.getKey());
Assert.assertNotNull(response.getCreationDate());
Assert.assertNotNull(response.getLastModified());
Assert.assertEquals(session, response.getSession());
Assert.assertEquals(numericalValue, response.getNumericalResponse());
Assert.assertEquals(stringuifiedResponse, response.getStringuifiedResponse());
Assert.assertEquals(fileResponse, response.getFileResponse());
Assert.assertEquals(responseIdentifier, response.getResponseIdentifier());
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PageDAOTest method createBinderWithSectionAndPageAndPart.
@Test
public void createBinderWithSectionAndPageAndPart() {
BinderImpl binder = binderDao.createAndPersist("Binder p1", "A binder with a page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
HTMLPart htmlPart = new HTMLPart();
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.persistPart(reloadedBody, htmlPart);
dbInstance.commitAndCloseSession();
// reload
Page reloadedPage = pageDao.loadByKey(page.getKey());
Assert.assertNotNull(reloadedPage);
List<PagePart> parts = reloadedPage.getBody().getParts();
Assert.assertNotNull(parts);
Assert.assertEquals(1, parts.size());
Assert.assertEquals(htmlPart, parts.get(0));
// reload only pages
List<PagePart> onlyParts = pageDao.getParts(page.getBody());
Assert.assertNotNull(onlyParts);
Assert.assertEquals(1, onlyParts.size());
Assert.assertEquals(htmlPart, onlyParts.get(0));
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PageDAOTest method getPages_binder.
@Test
public void getPages_binder() {
BinderImpl binder = binderDao.createAndPersist("Binder p2", "A binder with 2 page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page1 = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
Page page2 = pageDao.createAndPersist("Page 2", "A page with content.", null, null, true, reloadedSection, null);
Page page3 = pageDao.createAndPersist("Juno", "Juno is a spacecraft.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
// reload
List<Page> sectionPages = pageDao.getPages(binder, null);
Assert.assertNotNull(sectionPages);
Assert.assertEquals(3, sectionPages.size());
Assert.assertTrue(sectionPages.contains(page1));
Assert.assertTrue(sectionPages.contains(page2));
Assert.assertTrue(sectionPages.contains(page3));
// reload
List<Page> searchedPages = pageDao.getPages(binder, "juno");
Assert.assertNotNull(searchedPages);
Assert.assertEquals(1, searchedPages.size());
Assert.assertFalse(searchedPages.contains(page1));
Assert.assertFalse(searchedPages.contains(page2));
Assert.assertTrue(searchedPages.contains(page3));
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PortfolioServiceTest method deleteBinder.
@Test
public void deleteBinder() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("del-binder-");
Binder binder = portfolioService.createNewBinder("Binder to delete", "Deletion", "", owner);
SectionRef sectionRef1 = portfolioService.appendNewSection("1. section ", "Section 1", null, null, binder);
dbInstance.commit();
SectionRef sectionRef2 = portfolioService.appendNewSection("2. section ", "Section 2", null, null, binder);
dbInstance.commit();
portfolioService.updateBinderUserInformations(binder, owner);
dbInstance.commit();
Section reloadedSection1 = portfolioService.getSection(sectionRef1);
Page page1 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection1);
Section reloadedSection2 = portfolioService.getSection(sectionRef2);
Page page2 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection2);
Assert.assertNotNull(page1);
Assert.assertNotNull(page2);
dbInstance.commitAndCloseSession();
// delete
boolean deleted = portfolioService.deleteBinder(binder);
dbInstance.commit();
Assert.assertTrue(deleted);
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PortfolioServiceTest method binderAndSectionAndPageAccessRights.
@Test
public void binderAndSectionAndPageAccessRights() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-3");
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-4");
Identity reviewer = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
String title = "My published binder";
String summary = "My live";
Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
dbInstance.commit();
portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
dbInstance.commit();
List<Section> sections = portfolioService.getSections(binder);
Section section = sections.get(0);
portfolioService.appendNewPage(owner, "Reviewed page", "", null, null, section);
portfolioService.addAccessRights(section, coach, PortfolioRoles.coach);
dbInstance.commit();
List<Page> pages = portfolioService.getPages(section);
Page page = pages.get(0);
portfolioService.addAccessRights(page, reviewer, PortfolioRoles.reviewer);
// load right
List<AccessRights> rights = portfolioService.getAccessRights(binder);
Assert.assertNotNull(rights);
Assert.assertEquals(4, rights.size());
boolean foundOwner = false;
boolean foundCoach = false;
boolean foundReviewer = false;
for (AccessRights right : rights) {
if (PortfolioRoles.owner.equals(right.getRole()) && owner.equals(right.getIdentity())) {
foundOwner = true;
} else if (PortfolioRoles.coach.equals(right.getRole()) && coach.equals(right.getIdentity())) {
foundCoach = true;
} else if (PortfolioRoles.reviewer.equals(right.getRole()) && reviewer.equals(right.getIdentity())) {
foundReviewer = true;
}
}
Assert.assertTrue(foundOwner);
Assert.assertTrue(foundCoach);
Assert.assertTrue(foundReviewer);
}
Aggregations