Search in sources :

Example 36 with Binder

use of org.olat.modules.portfolio.Binder 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)

Example 37 with Binder

use of org.olat.modules.portfolio.Binder in project openolat by klemens.

the class PortfolioResultDetailsController method initBindersForm.

protected void initBindersForm(FormItemContainer formLayout) {
    Formatter formatter = Formatter.getInstance(getLocale());
    int count = 0;
    for (Binder binder : binders) {
        MapElements mapElements = new MapElements();
        if (binders.size() > 1 || !binder.getTemplate().equals(templateBinder)) {
            String templateTitle = binder.getTemplate().getTitle();
            uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
        }
        String copyDate = "";
        if (binder.getCopyDate() != null) {
            copyDate = formatter.formatDateAndTime(binder.getCopyDate());
        }
        uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
        String returnDate = "";
        if (binder.getReturnDate() != null) {
            returnDate = formatter.formatDateAndTime(binder.getReturnDate());
        }
        uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
        FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
        buttonsCont.setRootForm(mainForm);
        formLayout.add(buttonsCont);
        mapElements.openMapLink = uifactory.addFormLink("open.binder." + count, "open.binder", "open.map", null, buttonsCont, Link.BUTTON);
        mapElements.openMapLink.setUserObject(binder);
        count++;
        if (count != binders.size()) {
            uifactory.addSpacerElement("spacer-" + count, formLayout, false);
        }
        binderToElements.put(binder, mapElements);
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 38 with Binder

use of org.olat.modules.portfolio.Binder in project openolat by klemens.

the class PortfolioResultDetailsController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if (cmd != null && cmd.startsWith("map.deadline.change")) {
            if (deadlineCalloutCtr == null) {
                EPStructuredMap map = (EPStructuredMap) link.getUserObject();
                popupDeadlineBox(ureq, map);
            } else {
                // close on second click
                closeDeadlineBox();
            }
        } else if (link.getName().startsWith("open.map")) {
            PortfolioStructureMap map = (PortfolioStructureMap) link.getUserObject();
            doOpenMap(ureq, map);
        } else if (link.getName().startsWith("open.binder")) {
            Binder map = (Binder) link.getUserObject();
            doOpenMap(ureq, map);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 39 with Binder

use of org.olat.modules.portfolio.Binder in project openolat by klemens.

the class PortfolioTextForm method loadMapOrBinder.

protected void loadMapOrBinder() {
    RepositoryEntry mapEntry = courseNode.getReferencedRepositoryEntry();
    if (mapEntry != null) {
        if (BinderTemplateResource.TYPE_NAME.equals(mapEntry.getOlatResource().getResourceableTypeName())) {
            Binder binder = portfolioService.getBinderByResource(mapEntry.getOlatResource());
            if (binder != null) {
                inUse = portfolioService.isTemplateInUse(binder, courseEntry, courseNode.getIdent());
            }
            withDeadline = false;
        } else {
            PortfolioStructureMap template = (PortfolioStructureMap) ePFMgr.loadPortfolioStructure(mapEntry.getOlatResource());
            Long courseResId = courseEntry.getOlatResource().getResourceableId();
            OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseResId);
            if (template != null) {
                inUse = ePFMgr.isTemplateInUse(template, courseOres, courseNode.getIdent(), null);
            }
            withDeadline = true;
        }
    } else {
        withDeadline = true;
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 40 with Binder

use of org.olat.modules.portfolio.Binder in project openolat by klemens.

the class BinderListController method doCreateBinderFromTemplate.

private void doCreateBinderFromTemplate(UserRequest ureq, RepositoryEntry entry) {
    Binder templateBinder = portfolioService.getBinderByResource(entry.getOlatResource());
    Binder newBinder = portfolioService.assignBinder(getIdentity(), templateBinder, null, null, null);
    DBFactory.getInstance().commit();
    SynchedBinder synchedBinder = portfolioService.loadAndSyncBinder(newBinder);
    newBinder = synchedBinder.getBinder();
    doOpenBinder(ureq, newBinder).activate(ureq, null, null);
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder)

Aggregations

Binder (org.olat.modules.portfolio.Binder)144 Section (org.olat.modules.portfolio.Section)72 Identity (org.olat.core.id.Identity)70 Test (org.junit.Test)68 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)58 Page (org.olat.modules.portfolio.Page)44 RepositoryEntry (org.olat.repository.RepositoryEntry)34 Assignment (org.olat.modules.portfolio.Assignment)30 ArrayList (java.util.ArrayList)22 SectionRef (org.olat.modules.portfolio.SectionRef)22 AssessedBinder (org.olat.modules.portfolio.model.AssessedBinder)20 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)16 OLATResourceable (org.olat.core.id.OLATResourceable)14 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)14 PortfolioService (org.olat.modules.portfolio.PortfolioService)14 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)14 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 Date (java.util.Date)10 WindowControl (org.olat.core.gui.control.WindowControl)10 AssessmentSectionImpl (org.olat.modules.portfolio.model.AssessmentSectionImpl)8