Search in sources :

Example 21 with Section

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

the class BinderDAO method moveUpSection.

/*public List<Section> getSections(BinderRef binder) {
		BinderImpl refBinder = dbInstance.getCurrentEntityManager()
				.getReference(BinderImpl.class, binder.getKey());
		return refBinder.getSections();
	}*/
public Binder moveUpSection(BinderImpl binder, Section section) {
    binder.getSections().size();
    int index = binder.getSections().indexOf(section);
    if (index > 0) {
        Section reloadedPart = binder.getSections().remove(index);
        binder.getSections().add(index - 1, reloadedPart);
    } else if (index < 0) {
        binder.getSections().add(0, section);
    }
    return dbInstance.getCurrentEntityManager().merge(binder);
}
Also used : Section(org.olat.modules.portfolio.Section)

Example 22 with Section

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

the class BinderDAO method moveDownSection.

public Binder moveDownSection(BinderImpl binder, Section section) {
    binder.getSections().size();
    int index = binder.getSections().indexOf(section);
    if (index >= 0 && index + 1 < binder.getSections().size()) {
        Section reloadedSection = binder.getSections().remove(index);
        binder.getSections().add(index + 1, reloadedSection);
        binder = dbInstance.getCurrentEntityManager().merge(binder);
    }
    return binder;
}
Also used : Section(org.olat.modules.portfolio.Section)

Example 23 with Section

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

the class BinderDAO method createCopy.

public BinderImpl createCopy(BinderImpl template, RepositoryEntry entry, String subIdent) {
    BinderImpl binder = new BinderImpl();
    binder.setCreationDate(new Date());
    binder.setLastModified(binder.getCreationDate());
    binder.setTitle(template.getTitle());
    binder.setSummary(template.getSummary());
    binder.setImagePath(template.getImagePath());
    binder.setStatus(BinderStatus.open.name());
    binder.setBaseGroup(groupDao.createGroup());
    binder.setTemplate(template);
    binder.setCopyDate(binder.getCreationDate());
    if (entry != null) {
        binder.setEntry(entry);
    }
    if (StringHelper.containsNonWhitespace(subIdent)) {
        binder.setSubIdent(subIdent);
    }
    dbInstance.getCurrentEntityManager().persist(binder);
    binder.getSections().size();
    for (Section templateSection : template.getSections()) {
        Section section = createInternalSection(binder, templateSection);
        binder.getSections().add(section);
        dbInstance.getCurrentEntityManager().persist(section);
    }
    binder = dbInstance.getCurrentEntityManager().merge(binder);
    return binder;
}
Also used : BinderImpl(org.olat.modules.portfolio.model.BinderImpl) Section(org.olat.modules.portfolio.Section) Date(java.util.Date)

Example 24 with Section

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

the class AssignmentMoveController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_edit_assignment_form");
    List<Section> sections = portfolioService.getSections(binder);
    String selectedKey = null;
    int numOfSections = sections.size();
    String[] theKeys = new String[numOfSections];
    String[] theValues = new String[numOfSections];
    for (int i = 0; i < numOfSections; i++) {
        Long sectionKey = sections.get(i).getKey();
        theKeys[i] = sectionKey.toString();
        theValues[i] = (i + 1) + ". " + sections.get(i).getTitle();
        if (section != null && section.getKey().equals(sectionKey)) {
            selectedKey = theKeys[i];
        }
    }
    sectionsEl = uifactory.addDropdownSingleselect("sections", "page.sections", formLayout, theKeys, theValues, null);
    if (selectedKey != null) {
        sectionsEl.select(selectedKey, true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsCont.setRootForm(mainForm);
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("move", buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Section(org.olat.modules.portfolio.Section)

Example 25 with Section

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

the class PortfolioServiceTest method binderAndSectionAndPageAccessRights.

@Test
public void binderAndSectionAndPageAccessRights() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-3");
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-4");
    Identity reviewer = JunitTestHelper.createAndPersistIdentityAsRndUser("port-u-5");
    String title = "My published binder";
    String summary = "My live";
    Binder binder = portfolioService.createNewBinder(title, summary, null, owner);
    dbInstance.commit();
    portfolioService.appendNewSection("Section", "Coached section", null, null, binder);
    dbInstance.commit();
    List<Section> sections = portfolioService.getSections(binder);
    Section section = sections.get(0);
    portfolioService.appendNewPage(owner, "Reviewed page", "", null, null, section);
    portfolioService.addAccessRights(section, coach, PortfolioRoles.coach);
    dbInstance.commit();
    List<Page> pages = portfolioService.getPages(section);
    Page page = pages.get(0);
    portfolioService.addAccessRights(page, reviewer, PortfolioRoles.reviewer);
    // load right
    List<AccessRights> rights = portfolioService.getAccessRights(binder);
    Assert.assertNotNull(rights);
    Assert.assertEquals(4, rights.size());
    boolean foundOwner = false;
    boolean foundCoach = false;
    boolean foundReviewer = false;
    for (AccessRights right : rights) {
        if (PortfolioRoles.owner.equals(right.getRole()) && owner.equals(right.getIdentity())) {
            foundOwner = true;
        } else if (PortfolioRoles.coach.equals(right.getRole()) && coach.equals(right.getIdentity())) {
            foundCoach = true;
        } else if (PortfolioRoles.reviewer.equals(right.getRole()) && reviewer.equals(right.getIdentity())) {
            foundReviewer = true;
        }
    }
    Assert.assertTrue(foundOwner);
    Assert.assertTrue(foundCoach);
    Assert.assertTrue(foundReviewer);
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Page(org.olat.modules.portfolio.Page) Identity(org.olat.core.id.Identity) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

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