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);
}
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;
}
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;
}
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());
}
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);
}
Aggregations