Search in sources :

Example 56 with Section

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

the class BinderOnePageController method loadMetadataAndComponents.

private void loadMetadataAndComponents(UserRequest ureq, BinderRef binderRef) {
    Binder binder = portfolioService.getBinderByKey(binderRef.getKey());
    // load metadata
    List<Identity> owners = portfolioService.getMembers(binder, PortfolioRoles.owner.name());
    StringBuilder ownerSb = new StringBuilder();
    for (Identity owner : owners) {
        if (ownerSb.length() > 0)
            ownerSb.append(", ");
        ownerSb.append(userManager.getUserDisplayName(owner));
    }
    mainVC.contextPut("owners", ownerSb.toString());
    mainVC.contextPut("binderTitle", binder.getTitle());
    mainVC.contextPut("binderKey", binder.getKey());
    // load pages
    List<Section> sections = portfolioService.getSections(binder);
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Section section : sections) {
        loadSection(section);
        for (Page page : pages) {
            if (section.equals(page.getSection())) {
                loadPage(ureq, page);
            }
        }
    }
}
Also used : Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) AssessmentSection(org.olat.modules.portfolio.AssessmentSection)

Example 57 with Section

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

the class PageDAO method removePage.

public Page removePage(Page page) {
    PageImpl reloadedPage = (PageImpl) loadByKey(page.getKey());
    Section section = reloadedPage.getSection();
    if (section != null) {
        section.getPages().remove(reloadedPage);
    }
    reloadedPage.setLastModified(new Date());
    reloadedPage.setSection(null);
    reloadedPage.setPageStatus(PageStatus.deleted);
    unlinkAssignment(page);
    if (section != null) {
        dbInstance.getCurrentEntityManager().merge(section);
    }
    return dbInstance.getCurrentEntityManager().merge(reloadedPage);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Section(org.olat.modules.portfolio.Section) Date(java.util.Date)

Example 58 with Section

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

the class PortfolioNotificationsHandler method getSectionNotifications.

public List<SubscriptionListItem> getSectionNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
    StringBuilder sb = new StringBuilder();
    sb.append("select section").append(" from pfsection as section").append(" inner join fetch section.binder as binder").append(" where binder.key=:binderKey and section.lastModified>=:compareDate");
    List<Section> sections = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Section.class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
    Set<Long> uniqueSectionKeys = new HashSet<>();
    Set<Long> uniqueCreateSectionKeys = new HashSet<>();
    List<SubscriptionListItem> items = new ArrayList<>(sections.size());
    for (Section section : sections) {
        // section
        Long sectionKey = section.getKey();
        String sectionTitle = section.getTitle();
        Date sectionCreationDate = section.getCreationDate();
        Date sectionLastModified = section.getLastModified();
        if (secCallback.canViewElement(section)) {
            if (isSameDay(sectionCreationDate, sectionLastModified)) {
                if (!uniqueCreateSectionKeys.contains(sectionKey)) {
                    uniqueCreateSectionKeys.add(sectionKey);
                    SubscriptionListItem item = sectionCreateItem(sectionKey, sectionTitle, sectionCreationDate, rootBusinessPath, translator);
                    items.add(item);
                }
            } else if (!uniqueSectionKeys.contains(sectionKey)) {
                uniqueSectionKeys.add(sectionKey);
                SubscriptionListItem item = sectionModifiedItem(sectionKey, sectionTitle, sectionLastModified, rootBusinessPath, translator);
                items.add(item);
            }
        }
    }
    return items;
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) ArrayList(java.util.ArrayList) Section(org.olat.modules.portfolio.Section) Date(java.util.Date) HashSet(java.util.HashSet)

Example 59 with Section

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

the class PortfolioServiceImpl method startAssignment.

@Override
public Assignment startAssignment(Long assignmentKey, Identity author) {
    Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignmentKey);
    if (reloadedAssignment.getPage() == null) {
        Section section = reloadedAssignment.getSection();
        if (reloadedAssignment.getAssignmentType() == AssignmentType.essay || reloadedAssignment.getAssignmentType() == AssignmentType.document) {
            Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, null, section);
            reloadedAssignment = assignmentDao.startEssayAssignment(reloadedAssignment, page, author);
        } else if (reloadedAssignment.getAssignmentType() == AssignmentType.form) {
            RepositoryEntry formEntry = reloadedAssignment.getFormEntry();
            Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, false, null, section);
            reloadedAssignment = assignmentDao.startFormAssignment(reloadedAssignment, page, author);
            // create the session for the assignee
            evaluationFormSessionDao.createSessionForPortfolio(author, page.getBody(), formEntry);
        }
    }
    dbInstance.commit();
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_ASSIGNMENT_STARTED, getClass(), LoggingResourceable.wrap(reloadedAssignment.getSection()), LoggingResourceable.wrap(reloadedAssignment));
    return reloadedAssignment;
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 60 with Section

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

the class PortfolioServiceImpl method updatePage.

@Override
public Page updatePage(Page page, SectionRef newParentSection) {
    Page updatedPage;
    if (newParentSection == null) {
        updatedPage = pageDao.updatePage(page);
    } else {
        Section currentSection = null;
        if (page.getSection() != null) {
            currentSection = binderDao.loadSectionByKey(page.getSection().getKey());
            currentSection.getPages().remove(page);
        }
        Section newParent = binderDao.loadSectionByKey(newParentSection.getKey());
        ((PageImpl) page).setSection(newParent);
        newParent.getPages().add(page);
        updatedPage = pageDao.updatePage(page);
        if (currentSection != null) {
            binderDao.updateSection(currentSection);
        }
        binderDao.updateSection(newParent);
    }
    return updatedPage;
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) 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