Search in sources :

Example 11 with Section

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

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)

Example 12 with Section

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

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 13 with Section

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

the class PortfolioServiceImpl method appendNewPage.

private Page appendNewPage(Identity owner, String title, String summary, String imagePath, boolean editable, PageImageAlign align, SectionRef section) {
    Section reloadedSection = section == null ? null : binderDao.loadSectionByKey(section.getKey());
    if (reloadedSection != null && reloadedSection.getSectionStatus() == SectionStatus.notStarted) {
        ((SectionImpl) reloadedSection).setSectionStatus(SectionStatus.inProgress);
    }
    Page page = pageDao.createAndPersist(title, summary, imagePath, align, editable, reloadedSection, null);
    groupDao.addMembershipTwoWay(page.getBaseGroup(), owner, PortfolioRoles.owner.name());
    return page;
}
Also used : 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) SectionImpl(org.olat.modules.portfolio.model.SectionImpl) AssessmentSectionImpl(org.olat.modules.portfolio.model.AssessmentSectionImpl)

Example 14 with Section

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

the class PortfolioServiceImpl method deleteSection.

@Override
public Binder deleteSection(Binder binder, Section section) {
    Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
    Binder reloadedBinder = reloadedSection.getBinder();
    return binderDao.deleteSection(reloadedBinder, reloadedSection);
}
Also used : Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section)

Example 15 with Section

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

the class BinderPageListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (tableEl == source) {
        if (event instanceof FlexiTableRenderEvent) {
            FlexiTableRenderEvent re = (FlexiTableRenderEvent) event;
            if (re.getRendererType() == FlexiTableRendererType.custom) {
                tableEl.sort(new SortKey(null, false));
            }
        } else if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("select-page".equals(cmd)) {
                PortfolioElementRow row = model.getObject(se.getIndex());
                if (row.isPendingAssignment()) {
                    doStartAssignment(ureq, row);
                } else {
                    doOpenRow(ureq, row, false);
                }
            }
        }
    } else if (previousSectionLink == source) {
        Section previousSection = (Section) previousSectionLink.getUserObject();
        doFilterSection(previousSection);
    } else if (nextSectionLink == source) {
        Section nextSection = (Section) nextSectionLink.getUserObject();
        doFilterSection(nextSection);
    } else if (showAllSectionsLink == source) {
        doShowAll();
    } else if (newSectionButton == source) {
        doCreateNewSection(ureq);
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("new.entry".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doCreateNewPage(ureq, row.getSection());
        } else if ("new.assignment".equals(cmd)) {
            PortfolioElementRow row = (PortfolioElementRow) link.getUserObject();
            doCreateNewAssignment(ureq, row.getSection());
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) SortKey(org.olat.core.commons.persistence.SortKey) FlexiTableRenderEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableRenderEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) 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