use of org.olat.modules.portfolio.PageBody in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method moveUpPagePart.
@Override
public void moveUpPagePart(Page page, PagePart part) {
PageBody body = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.moveUpPart(body, part);
}
use of org.olat.modules.portfolio.PageBody in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method moveDownPagePart.
@Override
public void moveDownPagePart(Page page, PagePart part) {
PageBody body = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.moveDownPart(body, part);
}
use of org.olat.modules.portfolio.PageBody in project OpenOLAT by OpenOLAT.
the class EvaluationFormHandler method getContent.
@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints hints) {
Controller ctrl = null;
if (element instanceof EvaluationFormPart) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
// find assignment
EvaluationFormPart eva = (EvaluationFormPart) element;
PageBody body = eva.getBody();
Assignment assignment = portfolioService.getAssignment(body);
if (assignment == null) {
ctrl = getController(ureq, wControl, body, eva);
} else {
ctrl = getControllerForAssignment(ureq, wControl, body, assignment, hints.isOnePage());
}
}
if (ctrl == null) {
Translator translator = Util.createPackageTranslator(PortfolioHomeController.class, ureq.getLocale());
String title = translator.translate("warning.evaluation.not.visible.title");
String text = translator.translate("warning.evaluation.not.visible.text");
ctrl = MessageUIFactory.createWarnMessage(ureq, wControl, title, text);
}
return new PageRunControllerElement(ctrl);
}
use of org.olat.modules.portfolio.PageBody in project OpenOLAT by OpenOLAT.
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.PageBody in project OpenOLAT by OpenOLAT.
the class MediaDAOTest method usedInBinders.
@Test
public void usedInBinders() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-2");
Binder binder = portfolioService.createNewBinder("Binder p2", "A binder with 2 page", null, author);
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);
Media media = mediaDao.createMedia("Media", "Binder", "Une citation sur les classeurs", TextHandler.TEXT_MEDIA, "[Media:0]", null, 10, author);
dbInstance.commitAndCloseSession();
MediaPart mediaPart = new MediaPart();
mediaPart.setMedia(media);
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.persistPart(reloadedBody, mediaPart);
dbInstance.commitAndCloseSession();
// reload
List<BinderPageUsage> binders = mediaDao.usedInBinders(media);
Assert.assertNotNull(binders);
Assert.assertEquals(1, binders.size());
Assert.assertTrue(binders.get(0).getBinderKey().equals(binder.getKey()));
}
Aggregations