use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class InvitationEditRightsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_pf_invitation_form");
FormLayoutContainer inviteeCont = FormLayoutContainer.createDefaultFormLayout("inviteeInfos", getTranslator());
inviteeCont.setRootForm(mainForm);
formLayout.add("inviteeInfos", inviteeCont);
firstNameEl = uifactory.addTextElement("firstName", "firstName", 64, invitation.getFirstName(), inviteeCont);
firstNameEl.setElementCssClass("o_sel_pf_invitation_firstname");
firstNameEl.setMandatory(true);
lastNameEl = uifactory.addTextElement("lastName", "lastName", 64, invitation.getLastName(), inviteeCont);
lastNameEl.setElementCssClass("o_sel_pf_invitation_lastname");
lastNameEl.setMandatory(true);
String invitationEmail = email != null ? email : invitation.getMail();
mailEl = uifactory.addTextElement("mail", "mail", 128, invitationEmail, inviteeCont);
mailEl.setElementCssClass("o_sel_pf_invitation_mail");
mailEl.setMandatory(true);
mailEl.setNotEmptyCheck("map.share.empty.warn");
mailEl.setEnabled(invitation.getKey() == null);
if (StringHelper.containsNonWhitespace(invitation.getMail()) && MailHelper.isValidEmailAddress(invitation.getMail())) {
SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(invitation.getMail()));
if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
mailEl.setErrorKey("map.share.with.mail.error.olatUser", new String[] { invitation.getMail() });
}
}
String link = getInvitationLink();
StaticTextElement linkEl = uifactory.addStaticTextElement("invitation.link", link, inviteeCont);
linkEl.setElementCssClass("o_sel_pf_invitation_url");
linkEl.setLabel("invitation.link", null);
if (mailTemplate != null) {
subjectEl = uifactory.addTextElement("subjectElem", "mail.subject", 128, mailTemplate.getSubjectTemplate(), inviteeCont);
subjectEl.setDisplaySize(60);
subjectEl.setMandatory(true);
bodyEl = uifactory.addTextAreaElement("bodyElem", "mail.body", -1, 15, 60, true, mailTemplate.getBodyTemplate(), inviteeCont);
bodyEl.setHelpUrlForManualPage("E-Mail");
bodyEl.setMandatory(true);
}
// binder
MultipleSelectionElement accessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
accessEl.addActionListener(FormEvent.ONCHANGE);
binderRow = new BinderAccessRightsRow(accessEl, binder);
// sections
List<Section> sections = portfolioService.getSections(binder);
Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
for (Section section : sections) {
MultipleSelectionElement sectionAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
sectionAccessEl.addActionListener(FormEvent.ONCHANGE);
SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionAccessEl, section, binderRow);
binderRow.getSections().add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
}
// pages
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
Section section = page.getSection();
SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
MultipleSelectionElement pageAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
pageAccessEl.addActionListener(FormEvent.ONCHANGE);
PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageAccessEl, page, sectionRow);
sectionRow.getPages().add(pageRow);
}
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("binderRow", binderRow);
}
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");
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
buttonsCont.setRootForm(mainForm);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
if (invitation.getKey() != null) {
removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
}
uifactory.addFormSubmitButton("save", buttonsCont);
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class EvaluationFormResponseDAOTest method createResponseforPortfolio.
@Test
public void createResponseforPortfolio() {
// prepare a test case with the binder up to the page body
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("eva-1");
BinderImpl binder = binderDao.createAndPersist("Binder evaluation 1", "A binder with an evaluation", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commit();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with an evalutation.", null, null, true, reloadedSection, null);
dbInstance.commit();
RepositoryEntry formEntry = createFormEntry("Eva. form for responses");
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
EvaluationFormSession session = evaluationFormSessionDao.createSessionForPortfolio(id, reloadedBody, formEntry);
dbInstance.commit();
// create a response
String responseIdentifier = UUID.randomUUID().toString();
BigDecimal numericalValue = new BigDecimal("2.2");
String stringuifiedResponse = numericalValue.toPlainString();
Path fileResponse = Paths.get("this", "is", "a", "path");
EvaluationFormResponse response = evaluationFormResponseDao.createResponse(responseIdentifier, numericalValue, stringuifiedResponse, fileResponse, session);
dbInstance.commit();
Assert.assertNotNull(response);
Assert.assertNotNull(response.getKey());
Assert.assertNotNull(response.getCreationDate());
Assert.assertNotNull(response.getLastModified());
Assert.assertEquals(session, response.getSession());
Assert.assertEquals(numericalValue, response.getNumericalResponse());
Assert.assertEquals(stringuifiedResponse, response.getStringuifiedResponse());
Assert.assertEquals(fileResponse, response.getFileResponse());
Assert.assertEquals(responseIdentifier, response.getResponseIdentifier());
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class PageDAOTest method createBinderWithSectionAndPageAndPart.
@Test
public void createBinderWithSectionAndPageAndPart() {
BinderImpl binder = binderDao.createAndPersist("Binder p1", "A binder with a page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
HTMLPart htmlPart = new HTMLPart();
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.persistPart(reloadedBody, htmlPart);
dbInstance.commitAndCloseSession();
// reload
Page reloadedPage = pageDao.loadByKey(page.getKey());
Assert.assertNotNull(reloadedPage);
List<PagePart> parts = reloadedPage.getBody().getParts();
Assert.assertNotNull(parts);
Assert.assertEquals(1, parts.size());
Assert.assertEquals(htmlPart, parts.get(0));
// reload only pages
List<PagePart> onlyParts = pageDao.getParts(page.getBody());
Assert.assertNotNull(onlyParts);
Assert.assertEquals(1, onlyParts.size());
Assert.assertEquals(htmlPart, onlyParts.get(0));
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class PageDAOTest method getPages_binder.
@Test
public void getPages_binder() {
BinderImpl binder = binderDao.createAndPersist("Binder p2", "A binder with 2 page", null, null);
Section section = binderDao.createSection("Section", "First section", null, null, binder);
dbInstance.commitAndCloseSession();
Section reloadedSection = binderDao.loadSectionByKey(section.getKey());
Page page1 = pageDao.createAndPersist("Page 1", "A page with content.", null, null, true, reloadedSection, null);
Page page2 = pageDao.createAndPersist("Page 2", "A page with content.", null, null, true, reloadedSection, null);
Page page3 = pageDao.createAndPersist("Juno", "Juno is a spacecraft.", null, null, true, reloadedSection, null);
dbInstance.commitAndCloseSession();
// reload
List<Page> sectionPages = pageDao.getPages(binder, null);
Assert.assertNotNull(sectionPages);
Assert.assertEquals(3, sectionPages.size());
Assert.assertTrue(sectionPages.contains(page1));
Assert.assertTrue(sectionPages.contains(page2));
Assert.assertTrue(sectionPages.contains(page3));
// reload
List<Page> searchedPages = pageDao.getPages(binder, "juno");
Assert.assertNotNull(searchedPages);
Assert.assertEquals(1, searchedPages.size());
Assert.assertFalse(searchedPages.contains(page1));
Assert.assertFalse(searchedPages.contains(page2));
Assert.assertTrue(searchedPages.contains(page3));
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class PortfolioServiceTest method deleteBinder.
@Test
public void deleteBinder() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("del-binder-");
Binder binder = portfolioService.createNewBinder("Binder to delete", "Deletion", "", owner);
SectionRef sectionRef1 = portfolioService.appendNewSection("1. section ", "Section 1", null, null, binder);
dbInstance.commit();
SectionRef sectionRef2 = portfolioService.appendNewSection("2. section ", "Section 2", null, null, binder);
dbInstance.commit();
portfolioService.updateBinderUserInformations(binder, owner);
dbInstance.commit();
Section reloadedSection1 = portfolioService.getSection(sectionRef1);
Page page1 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection1);
Section reloadedSection2 = portfolioService.getSection(sectionRef2);
Page page2 = portfolioService.appendNewPage(owner, "New page", "A brand new page.", null, null, reloadedSection2);
Assert.assertNotNull(page1);
Assert.assertNotNull(page2);
dbInstance.commitAndCloseSession();
// delete
boolean deleted = portfolioService.deleteBinder(binder);
dbInstance.commit();
Assert.assertTrue(deleted);
}
Aggregations