Search in sources :

Example 96 with Page

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

the class AccessRightsEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (member != null && formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        Controller portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), member, true, true);
        layoutCont.getFormItemComponent().put("portrait", portraitCtr.getInitialComponent());
        listenTo(portraitCtr);
        Controller userShortDescrCtr = new UserShortDescription(ureq, getWindowControl(), member);
        layoutCont.getFormItemComponent().put("userShortDescription", userShortDescrCtr.getInitialComponent());
        listenTo(userShortDescrCtr);
    }
    selectAll = uifactory.addFormLink("form.checkall", "form.checkall", null, formLayout, Link.LINK);
    selectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_on");
    deselectAll = uifactory.addFormLink("form.uncheckall", "form.uncheckall", null, formLayout, Link.LINK);
    deselectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_off");
    // binder
    MultipleSelectionElement coachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
    coachEl.addActionListener(FormEvent.ONCHANGE);
    coachEl.setVisible(grading);
    MultipleSelectionElement reviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
    reviewerEl.addActionListener(FormEvent.ONCHANGE);
    binderRow = new BinderAccessRightsRow(coachEl, reviewerEl, binder);
    coachEl.setUserObject(binderRow);
    reviewerEl.setUserObject(binderRow);
    // sections
    List<Section> sections = portfolioService.getSections(binder);
    Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
    for (Section section : sections) {
        MultipleSelectionElement sectionCoachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        sectionCoachEl.addActionListener(FormEvent.ONCHANGE);
        sectionCoachEl.setVisible(grading);
        MultipleSelectionElement sectionReviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        sectionReviewerEl.addActionListener(FormEvent.ONCHANGE);
        SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionCoachEl, sectionReviewerEl, section, binderRow);
        binderRow.getSections().add(sectionRow);
        sectionMap.put(section.getKey(), sectionRow);
        sectionCoachEl.setUserObject(sectionRow);
        sectionReviewerEl.setUserObject(sectionRow);
    }
    // pages
    List<Page> pages = portfolioService.getPages(binder, null);
    for (Page page : pages) {
        Section section = page.getSection();
        SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
        MultipleSelectionElement pageCoachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        pageCoachEl.addActionListener(FormEvent.ONCHANGE);
        pageCoachEl.setVisible(grading);
        MultipleSelectionElement pageReviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
        pageReviewerEl.addActionListener(FormEvent.ONCHANGE);
        PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageCoachEl, pageReviewerEl, page, sectionRow);
        sectionRow.getPages().add(pageRow);
        pageCoachEl.setUserObject(pageRow);
        pageReviewerEl.setUserObject(pageRow);
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("binderRow", binderRow);
        layoutCont.contextPut("grading", new Boolean(grading));
    }
    if (hasButtons) {
        FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
        formLayout.add(buttonsCont);
        buttonsCont.setRootForm(mainForm);
        formLayout.add("buttons", buttonsCont);
        uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
        removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
        if (canEdit) {
            uifactory.addFormSubmitButton("save", buttonsCont);
        }
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) UserShortDescription(org.olat.admin.user.UserShortDescription) HashMap(java.util.HashMap) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Page(org.olat.modules.portfolio.Page) DisplayPortraitController(org.olat.user.DisplayPortraitController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) Section(org.olat.modules.portfolio.Section) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)

Example 97 with Page

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

the class PortfolioServiceImpl method changePageStatus.

@Override
public Page changePageStatus(Page page, PageStatus status, Identity identity, Role by) {
    PageStatus currentStatus = page.getPageStatus();
    Page reloadedPage = pageDao.loadByKey(page.getKey());
    ((PageImpl) reloadedPage).setPageStatus(status);
    if (status == PageStatus.published) {
        Date now = new Date();
        if (reloadedPage.getInitialPublicationDate() == null) {
            ((PageImpl) reloadedPage).setInitialPublicationDate(now);
        }
        ((PageImpl) reloadedPage).setLastPublicationDate(now);
        Section section = reloadedPage.getSection();
        // auto update the status of the evaluation form of the authors of the binder
        changeAssignmentStatus(page, section, EvaluationFormSessionStatus.done);
        if (section != null) {
            SectionStatus sectionStatus = section.getSectionStatus();
            if (currentStatus == PageStatus.closed) {
                if (sectionStatus == SectionStatus.closed) {
                    ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                    binderDao.updateSection(section);
                }
            } else if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
                ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                binderDao.updateSection(section);
            }
        }
    } else if (status == PageStatus.inRevision) {
        Section section = reloadedPage.getSection();
        changeAssignmentStatus(page, section, EvaluationFormSessionStatus.inProgress);
        if (section != null) {
            SectionStatus sectionStatus = section.getSectionStatus();
            if (sectionStatus == null || sectionStatus == SectionStatus.notStarted || sectionStatus == SectionStatus.closed) {
                if (sectionStatus == SectionStatus.closed) {
                    ((SectionImpl) section).setSectionStatus(SectionStatus.inProgress);
                    binderDao.updateSection(section);
                }
            }
        }
        pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.inProcess, PageUserStatus.done);
    } else if (status == PageStatus.closed) {
        // set user informations to done
        pageUserInfosDao.updateStatus(reloadedPage, PageUserStatus.done);
    }
    if (reloadedPage.getSection() != null && reloadedPage.getSection().getBinder() != null) {
        Binder binder = reloadedPage.getSection().getBinder();
        updateAssessmentEntryLastModification(binder, identity, by);
    }
    return pageDao.updatePage(reloadedPage);
}
Also used : PageImpl(org.olat.modules.portfolio.model.PageImpl) Binder(org.olat.modules.portfolio.Binder) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) PageStatus(org.olat.modules.portfolio.PageStatus) AssessedPage(org.olat.modules.portfolio.model.AssessedPage) Page(org.olat.modules.portfolio.Page) SectionStatus(org.olat.modules.portfolio.SectionStatus) 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) Date(java.util.Date)

Example 98 with Page

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

the class BinderDAO method deleteSection.

public Binder deleteSection(Binder binder, Section section) {
    List<Page> pages = new ArrayList<>(section.getPages());
    // delete pages
    for (Page page : pages) {
        if (page != null) {
            pageDao.deletePage(page);
            pageUserInfosDao.delete(page);
            section.getPages().remove(page);
        }
    }
    List<Assignment> assignments = assignmentDao.loadAssignments(section, null);
    for (Assignment assignment : assignments) {
        assignmentDao.deleteAssignmentReference(assignment);
    }
    assignmentDao.deleteAssignmentBySection(section);
    assessmentSectionDao.deleteAssessmentSections(section);
    // remove reference via template
    String sb = "update pfsection section set section.templateReference=null where section.templateReference.key=:sectionKey";
    dbInstance.getCurrentEntityManager().createQuery(sb).setParameter("sectionKey", section.getKey()).executeUpdate();
    ((BinderImpl) binder).getSections().remove(section);
    dbInstance.getCurrentEntityManager().remove(section);
    return dbInstance.getCurrentEntityManager().merge(binder);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page)

Example 99 with Page

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

the class MyPageListController method loadModel.

@Override
protected void loadModel(UserRequest ureq, String searchString) {
    Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfCommentsOnOwnedPage(getIdentity());
    List<CategoryToElement> categorizedElements = portfolioService.getCategorizedOwnedPages(getIdentity());
    Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
    for (CategoryToElement categorizedElement : categorizedElements) {
        List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
        if (categories == null) {
            categories = new ArrayList<>();
            categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
        }
        categories.add(categorizedElement.getCategory());
    }
    List<Assignment> assignments = portfolioService.searchOwnedAssignments(getIdentity());
    Map<Page, List<Assignment>> pageToAssignments = new HashMap<>();
    for (Assignment assignment : assignments) {
        Page page = assignment.getPage();
        List<Assignment> assignmentList;
        if (pageToAssignments.containsKey(page)) {
            assignmentList = pageToAssignments.get(page);
        } else {
            assignmentList = new ArrayList<>();
            pageToAssignments.put(page, assignmentList);
        }
        assignmentList.add(assignment);
    }
    FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
    newEntryButton.setCustomEnabledLinkCSS("btn btn-primary");
    List<Page> pages = portfolioService.searchOwnedPages(getIdentity(), searchString);
    List<PortfolioElementRow> rows = new ArrayList<>(pages.size());
    List<TimelinePoint> points = new ArrayList<>(pages.size());
    for (Page page : pages) {
        if (page.getPageStatus() == PageStatus.deleted) {
            continue;
        }
        List<Assignment> assignmentList = pageToAssignments.get(page);
        PortfolioElementRow row = forgePageRow(ureq, page, null, assignmentList, categorizedElementMap, numberOfCommentsMap, true);
        rows.add(row);
        if (page.getSection() != null) {
            Section section = page.getSection();
            row.setMetaSectionTitle(section.getTitle());
            if (section.getBinder() != null) {
                row.setMetaBinderTitle(section.getBinder().getTitle());
            }
        }
        row.setNewFloatingEntryLink(newEntryButton);
        String s = page.getPageStatus() == null ? "draft" : page.getPageStatus().name();
        points.add(new TimelinePoint(page.getKey().toString(), page.getTitle(), page.getCreationDate(), s));
    }
    timelineEl.setPoints(points);
    // clean up the posters
    disposeRows();
    model.setObjects(rows);
    tableEl.reset();
    tableEl.reloadData();
}
Also used : PortfolioElementRow(org.olat.modules.portfolio.ui.model.PortfolioElementRow) Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) HashMap(java.util.HashMap) CategoryToElement(org.olat.modules.portfolio.CategoryToElement) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Section(org.olat.modules.portfolio.Section) Assignment(org.olat.modules.portfolio.Assignment) ArrayList(java.util.ArrayList) List(java.util.List) TimelinePoint(org.olat.modules.portfolio.ui.component.TimelinePoint)

Example 100 with Page

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

the class PortfolioNotificationsHandler method getPageNotifications.

/**
 * Query the changes in the binder from the section to the page part.
 *
 * @param binder
 * @param compareDate
 * @param rootBusinessPath
 * @param translator
 * @return
 */
public List<SubscriptionListItem> getPageNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
    StringBuilder sb = new StringBuilder();
    sb.append("select page,").append("  pagepart.lastModified as pagepartLastModified").append(" from pfpage as page").append(" inner join fetch page.section as section").append(" inner join fetch section.binder as binder").append(" left join pfpagepart as pagepart on (pagepart.body.key = page.body.key)").append(" where binder.key=:binderKey and (pagepart.lastModified>=:compareDate or page.lastModified>=:compareDate)");
    List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
    Map<Long, SubscriptionListItem> uniquePartKeys = new HashMap<>();
    Map<Long, SubscriptionListItem> uniqueCreatePageKeys = new HashMap<>();
    List<SubscriptionListItem> items = new ArrayList<>(objects.size());
    for (Object[] object : objects) {
        // page
        Page page = (Page) object[0];
        Long pageKey = page.getKey();
        String pageTitle = page.getTitle();
        Date pageCreationDate = page.getCreationDate();
        Date pageLastModified = page.getLastModified();
        // page part
        Date partLastModified = (Date) object[1];
        Section section = page.getSection();
        if (secCallback.canViewElement(page) && secCallback.canViewElement(section)) {
            // page created
            if (isSameDay(pageCreationDate, pageLastModified) && pageCreationDate.compareTo(compareDate) >= 0) {
                if (!uniqueCreatePageKeys.containsKey(pageKey)) {
                    SubscriptionListItem item = pageCreateItem(pageKey, pageTitle, pageCreationDate, rootBusinessPath, translator);
                    uniqueCreatePageKeys.put(pageKey, item);
                }
            } else {
                if (uniquePartKeys.containsKey(pageKey)) {
                    SubscriptionListItem item = uniquePartKeys.get(pageKey);
                    SubscriptionListItem potentitalItem = pageModifiedItem(pageKey, pageTitle, pageLastModified, partLastModified, rootBusinessPath, translator);
                    if (item.getDate().before(potentitalItem.getDate())) {
                        uniquePartKeys.put(pageKey, potentitalItem);
                    }
                } else if (pageLastModified.compareTo(compareDate) >= 0 || (partLastModified != null && partLastModified.compareTo(compareDate) >= 0)) {
                    SubscriptionListItem item = pageModifiedItem(pageKey, pageTitle, pageLastModified, partLastModified, rootBusinessPath, translator);
                    boolean overlapCreate = false;
                    if (uniqueCreatePageKeys.containsKey(pageKey)) {
                        SubscriptionListItem createItem = uniqueCreatePageKeys.get(pageKey);
                        overlapCreate = isSameDay(item.getDate(), createItem.getDate());
                    }
                    if (!overlapCreate) {
                        uniquePartKeys.put(pageKey, item);
                    }
                }
            }
        }
    }
    items.addAll(uniquePartKeys.values());
    items.addAll(uniqueCreatePageKeys.values());
    return items;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Page(org.olat.modules.portfolio.Page) Section(org.olat.modules.portfolio.Section) Date(java.util.Date) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem)

Aggregations

Page (org.olat.modules.portfolio.Page)136 Section (org.olat.modules.portfolio.Section)98 Test (org.junit.Test)70 Identity (org.olat.core.id.Identity)64 Binder (org.olat.modules.portfolio.Binder)44 ArrayList (java.util.ArrayList)32 BinderImpl (org.olat.modules.portfolio.model.BinderImpl)32 AssessmentSection (org.olat.modules.portfolio.AssessmentSection)26 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)26 Assignment (org.olat.modules.portfolio.Assignment)24 RepositoryEntry (org.olat.repository.RepositoryEntry)22 HashMap (java.util.HashMap)20 SectionRef (org.olat.modules.portfolio.SectionRef)20 PageUserInformations (org.olat.modules.portfolio.PageUserInformations)18 AssessedPage (org.olat.modules.portfolio.model.AssessedPage)16 PageBody (org.olat.modules.portfolio.PageBody)14 OLATResourceable (org.olat.core.id.OLATResourceable)12 AccessRights (org.olat.modules.portfolio.model.AccessRights)12 CategoryToElement (org.olat.modules.portfolio.CategoryToElement)10 Date (java.util.Date)8