Search in sources :

Example 16 with Section

use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.

the class BinderPageListController method doFilterSection.

protected void doFilterSection(Section section) {
    this.filteringSection = section;
    List<Section> currentSections = model.filter(section);
    tableEl.reloadData();
    updateTimeline();
    int index = currentSections.indexOf(section);
    previousSectionLink.setEnabled(index > 0);
    if (index > 0) {
        String previousTitle = currentSections.get(index - 1).getTitle();
        previousSectionLink.setI18nKey(translate("section.paging.with.title", new String[] { previousTitle }));
        previousSectionLink.setUserObject(currentSections.get(index - 1));
    } else {
        previousSectionLink.setI18nKey(translate("section.paging.previous"));
    }
    if (index >= 0 && index + 1 < currentSections.size()) {
        String nextTitle = currentSections.get(index + 1).getTitle();
        nextSectionLink.setI18nKey(translate("section.paging.with.title", new String[] { nextTitle }));
        nextSectionLink.setEnabled(true);
        nextSectionLink.setUserObject(currentSections.get(index + 1));
    } else {
        nextSectionLink.setI18nKey(translate("section.paging.next"));
        nextSectionLink.setEnabled(false);
    }
    boolean visible = currentSections.size() > 1;
    previousSectionLink.setVisible(visible);
    nextSectionLink.setVisible(visible);
    showAllSectionsLink.setVisible(visible);
    flc.setDirty(true);
}
Also used : AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) TimelinePoint(org.olat.modules.portfolio.ui.component.TimelinePoint)

Example 17 with Section

use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.

the class TableOfContentController method loadModel.

protected void loadModel() {
    mainVC.contextPut("binderTitle", StringHelper.escapeHtml(binder.getTitle()));
    if (StringHelper.containsNonWhitespace(binder.getSummary())) {
        summaryComp.setText(binder.getSummary());
        mainVC.put("summary", summaryCtrl.getInitialComponent());
    } else {
        mainVC.remove("summary");
    }
    List<SectionRow> sectionRows = new ArrayList<>();
    Map<Long, SectionRow> sectionMap = new HashMap<>();
    List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
    Map<Section, AssessmentSection> sectionToAssessmentSectionMap = new HashMap<>();
    for (AssessmentSection assessmentSection : assessmentSections) {
        sectionToAssessmentSectionMap.put(assessmentSection.getSection(), assessmentSection);
    }
    // assignments
    List<Assignment> assignments = portfolioService.getAssignments(binder, null);
    Map<Section, List<Assignment>> sectionToAssignmentMap = new HashMap<>();
    for (Assignment assignment : assignments) {
        List<Assignment> assignmentList;
        if (sectionToAssignmentMap.containsKey(assignment.getSection())) {
            assignmentList = sectionToAssignmentMap.get(assignment.getSection());
        } else {
            assignmentList = new ArrayList<>();
            sectionToAssignmentMap.put(assignment.getSection(), assignmentList);
        }
        assignmentList.add(assignment);
    }
    List<Section> sections = portfolioService.getSections(binder);
    int count = 0;
    for (Section section : sections) {
        boolean first = count == 0;
        boolean last = count == sections.size() - 1;
        count++;
        if (secCallback.canViewElement(section)) {
            SectionRow sectionRow = forgeSectionRow(section, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), first, last);
            sectionRows.add(sectionRow);
            sectionMap.put(section.getKey(), sectionRow);
        }
    }
    loadPagesModel(sectionMap);
    mainVC.contextPut("sections", sectionRows);
    sectionList = sectionRows;
    if (secCallback.canAddSection()) {
        if (newSectionButton == null) {
            newSectionButton = LinkFactory.createButton("create.new.section", mainVC, this);
            newSectionButton.setCustomEnabledLinkCSS("btn btn-primary");
        }
        mainVC.put("create.new.section", newSectionButton);
    }
    boolean hasSection = (sectionList != null && sectionList.size() > 0);
    if (newEntryLink != null && newEntryLink.isVisible() != hasSection) {
        newEntryLink.setVisible(hasSection);
        stackPanel.setDirty(true);
    }
    if (newAssignmentLink != null && newAssignmentLink.isVisible() != hasSection) {
        newAssignmentLink.setVisible(hasSection);
        stackPanel.setDirty(true);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) Assignment(org.olat.modules.portfolio.Assignment) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) List(java.util.List) ArrayList(java.util.ArrayList)

Example 18 with Section

use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.

the class TableOfContentController method doClose.

private void doClose(SectionRow row) {
    Section section = row.getSection();
    section = portfolioService.changeSectionStatus(section, SectionStatus.closed, getIdentity());
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_SECTION_CLOSE, getClass(), LoggingResourceable.wrap(section));
}
Also used : AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 19 with Section

use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.

the class TableOfContentController method loadPagesModel.

private void loadPagesModel(Map<Long, SectionRow> sectionMap) {
    boolean showUserInfos = secCallback.canPageUserInfosStatus();
    mainVC.contextPut("userInfos", Boolean.valueOf(showUserInfos));
    Map<Long, PageUserInformations> userInfosToPages = new HashMap<>();
    if (showUserInfos) {
        List<PageUserInformations> userInfos = portfolioService.getPageUserInfos(binder, getIdentity());
        for (PageUserInformations userInfo : userInfos) {
            userInfosToPages.put(userInfo.getPage().getKey(), userInfo);
        }
        mainVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
    }
    Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        if (section != null && sectionMap.containsKey(section.getKey())) {
            boolean viewElement = secCallback.canViewElement(page);
            boolean viewTitleElement = secCallback.canViewTitleOfElement(page);
            if (viewElement || viewTitleElement) {
                SectionRow sectionRow = sectionMap.get(section.getKey());
                PageRow pageRow = forgePageRow(page, numberOfCommentsMap, viewElement);
                sectionRow.getPages().add(pageRow);
                if (showUserInfos) {
                    PageUserInformations userInfos = userInfosToPages.get(pageRow.getPage().getKey());
                    if (userInfos != null) {
                        pageRow.setUserInfosStatus(userInfos.getStatus());
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Page(org.olat.modules.portfolio.Page) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) SharedPageStatusCellRenderer(org.olat.modules.portfolio.ui.renderer.SharedPageStatusCellRenderer) PageUserInformations(org.olat.modules.portfolio.PageUserInformations)

Example 20 with Section

use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.

the class BinderDAO method deleteBinder.

public int deleteBinder(BinderRef binderRef) {
    int rows = userInformationsDAO.deleteBinderUserInfos(binderRef);
    BinderImpl binder = (BinderImpl) loadByKey(binderRef.getKey());
    List<Section> sections = new ArrayList<>(binder.getSections());
    for (Section section : sections) {
        List<Page> pages = new ArrayList<>(section.getPages());
        section.getPages().clear();
        section = dbInstance.getCurrentEntityManager().merge(section);
        for (Page page : pages) {
            if (page != null) {
                rows += pageDao.deletePage(page);
                rows += pageUserInfosDao.delete(page);
            }
        }
        rows += assessmentSectionDao.deleteAssessmentSections(section);
        Group baseGroup = section.getBaseGroup();
        rows += groupDao.removeMemberships(baseGroup);
        dbInstance.getCurrentEntityManager().remove(section);
        dbInstance.getCurrentEntityManager().remove(baseGroup);
        rows += 2;
    }
    binder.getSections().clear();
    Group baseGroup = binder.getBaseGroup();
    rows += groupDao.removeMemberships(baseGroup);
    dbInstance.getCurrentEntityManager().remove(binder);
    dbInstance.getCurrentEntityManager().remove(baseGroup);
    return rows + 2;
}
Also used : Group(org.olat.basesecurity.Group) ArrayList(java.util.ArrayList) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Page(org.olat.modules.portfolio.Page) 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