Search in sources :

Example 46 with Section

use of org.olat.modules.portfolio.Section 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 47 with Section

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

the class AbstractPageListController method forgePageRow.

protected PortfolioElementRow forgePageRow(UserRequest ureq, Page page, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap, Map<Long, Long> numberOfCommentsMap, boolean selectElement) {
    Section section = page.getSection();
    PortfolioElementRow row = new PortfolioElementRow(page, assessmentSection, config.isAssessable());
    String openLinkId = "open_" + (++counter);
    FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
    openLink.setIconRightCSS("o_icon o_icon_start");
    openLink.setEnabled(selectElement);
    openLink.setPrimary(true);
    row.setOpenFormLink(openLink);
    openLink.setUserObject(row);
    addCategoriesToRow(row, categorizedElementMap);
    if (assignments != null) {
        for (Assignment assignment : assignments) {
            if (page.equals(assignment.getPage())) {
                row.setAssignment(assignment);
            }
        }
    }
    decorateImage(ureq, row, page);
    if (numberOfCommentsMap != null) {
        Long numOfComments = numberOfCommentsMap.get(page.getKey());
        if (numOfComments != null) {
            row.setNumOfComments(numOfComments.longValue());
        } else {
            row.setNumOfComments(0);
        }
    } else {
        row.setNumOfComments(0);
    }
    if (secCallback.canCloseSection(section)) {
        if (SectionStatus.isClosed(section)) {
            FormLink reopenLink = uifactory.addFormLink("ropens_" + (++counter), "reopen.section", "reopen.section", null, flc, Link.BUTTON_SMALL);
            reopenLink.setUserObject(row);
            row.setReopenSectionLink(reopenLink);
        } else {
            FormLink closeLink = uifactory.addFormLink("closes_" + (++counter), "close.section", "close.section", null, flc, Link.BUTTON_SMALL);
            closeLink.setUserObject(row);
            row.setCloseSectionLink(closeLink);
        }
    }
    if (portfolioV2Module.isEntriesCommentsEnabled() && secCallback.canComment(page)) {
        String title;
        String cssClass = "o_icon o_icon-fw o_icon_comments";
        if (row.getNumOfComments() == 1) {
            title = translate("comment.one");
        } else if (row.getNumOfComments() > 1) {
            title = translate("comment.several", new String[] { Long.toString(row.getNumOfComments()) });
        } else {
            title = translate("comment.zero");
            cssClass += "_none";
        }
        FormLink commentLink = uifactory.addFormLink("com_" + (++counter), "comment", title, null, flc, Link.LINK | Link.NONTRANSLATED);
        commentLink.setIconLeftCSS(cssClass);
        commentLink.setUserObject(row);
        row.setCommentFormLink(commentLink);
    }
    return row;
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Assignment(org.olat.modules.portfolio.Assignment) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 48 with Section

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

the class AbstractPageListController method doMoveDownAssignment.

private void doMoveDownAssignment(UserRequest ureq, PortfolioElementRow row) {
    Assignment assigment = row.getAssignment();
    Section section = row.getSection();
    section = portfolioService.moveDownAssignment(section, assigment);
    loadModel(ureq, null);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 49 with Section

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

the class AbstractPageListController method doMoveUpAssignment.

private void doMoveUpAssignment(UserRequest ureq, PortfolioElementRow row) {
    Assignment assigment = row.getAssignment();
    Section section = assigment.getSection();
    section = portfolioService.moveUpAssignment(section, assigment);
    loadModel(ureq, null);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 50 with Section

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

the class AbstractPageListController method doReopen.

private void doReopen(UserRequest ureq, PortfolioElementRow row) {
    Section section = row.getSection();
    section = portfolioService.changeSectionStatus(section, SectionStatus.inProgress, getIdentity());
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_SECTION_REOPEN, getClass(), LoggingResourceable.wrap(section));
    loadModel(ureq, null);
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Aggregations

Section (org.olat.modules.portfolio.Section)190 Page (org.olat.modules.portfolio.Page)100 Test (org.junit.Test)86 Identity (org.olat.core.id.Identity)80 Binder (org.olat.modules.portfolio.Binder)72 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)68 Assignment (org.olat.modules.portfolio.Assignment)48 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)40 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)38 ArrayList (java.util.ArrayList)36 RepositoryEntry (org.olat.repository.RepositoryEntry)26 SectionRef (org.olat.modules.portfolio.SectionRef)24 HashMap (java.util.HashMap)22 Date (java.util.Date)16 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)14 BigDecimal (java.math.BigDecimal)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 SectionImpl (org.olat.modules.portfolio.model.SectionImpl)12 PortfolioElementRow (org.olat.modules.portfolio.ui.model.PortfolioElementRow)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10