Search in sources :

Example 1 with PageBody

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);
}
Also used : PageBody(org.olat.modules.portfolio.PageBody)

Example 2 with PageBody

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);
}
Also used : PageBody(org.olat.modules.portfolio.PageBody)

Example 3 with PageBody

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);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) PageRunControllerElement(org.olat.modules.portfolio.ui.editor.PageRunControllerElement) EvaluationFormPart(org.olat.modules.portfolio.model.EvaluationFormPart) PortfolioService(org.olat.modules.portfolio.PortfolioService) Translator(org.olat.core.gui.translator.Translator) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) PageBody(org.olat.modules.portfolio.PageBody)

Example 4 with PageBody

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());
}
Also used : Path(java.nio.file.Path) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 5 with PageBody

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()));
}
Also used : Binder(org.olat.modules.portfolio.Binder) MediaPart(org.olat.modules.portfolio.model.MediaPart) BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) Media(org.olat.modules.portfolio.Media) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) PageBody(org.olat.modules.portfolio.PageBody) Test(org.junit.Test)

Aggregations

PageBody (org.olat.modules.portfolio.PageBody)26 Test (org.junit.Test)14 Page (org.olat.modules.portfolio.Page)14 Section (org.olat.modules.portfolio.Section)8 HTMLPart (org.olat.modules.portfolio.model.HTMLPart)8 Identity (org.olat.core.id.Identity)6 PagePart (org.olat.modules.portfolio.PagePart)6 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)6 TitlePart (org.olat.modules.portfolio.model.TitlePart)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 EvaluationFormSession (org.olat.modules.forms.EvaluationFormSession)4 EvaluationFormController (org.olat.modules.forms.ui.EvaluationFormController)4 Assignment (org.olat.modules.portfolio.Assignment)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 EvaluationFormPart (org.olat.modules.portfolio.model.EvaluationFormPart)4 MultiEvaluationFormController (org.olat.modules.portfolio.ui.MultiEvaluationFormController)4 File (java.io.File)2 BigDecimal (java.math.BigDecimal)2 Path (java.nio.file.Path)2 PersistenceHelper.makeFuzzyQueryString (org.olat.core.commons.persistence.PersistenceHelper.makeFuzzyQueryString)2