use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class MediaDAOTest method usedInBinders.
@Test
public void usedInBinders() {
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-2");
Binder binder = portfolioService.createNewBinder("Binder p2", "A binder with 2 page", null, author);
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);
Media media = mediaDao.createMedia("Media", "Binder", "Une citation sur les classeurs", TextHandler.TEXT_MEDIA, "[Media:0]", null, 10, author);
dbInstance.commitAndCloseSession();
MediaPart mediaPart = new MediaPart();
mediaPart.setMedia(media);
PageBody reloadedBody = pageDao.loadPageBodyByKey(page.getBody().getKey());
pageDao.persistPart(reloadedBody, mediaPart);
dbInstance.commitAndCloseSession();
// reload
List<BinderPageUsage> binders = mediaDao.usedInBinders(media);
Assert.assertNotNull(binders);
Assert.assertEquals(1, binders.size());
Assert.assertTrue(binders.get(0).getBinderKey().equals(binder.getKey()));
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class AbstractPageListController method forgePageRow.
protected PortfolioElementRow forgePageRow(UserRequest ureq, Page page, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap, Map<Long, Long> numberOfCommentsMap, boolean selectElement) {
Section section = page.getSection();
PortfolioElementRow row = new PortfolioElementRow(page, assessmentSection, config.isAssessable());
String openLinkId = "open_" + (++counter);
FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
openLink.setIconRightCSS("o_icon o_icon_start");
openLink.setEnabled(selectElement);
openLink.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null) {
for (Assignment assignment : assignments) {
if (page.equals(assignment.getPage())) {
row.setAssignment(assignment);
}
}
}
decorateImage(ureq, row, page);
if (numberOfCommentsMap != null) {
Long numOfComments = numberOfCommentsMap.get(page.getKey());
if (numOfComments != null) {
row.setNumOfComments(numOfComments.longValue());
} else {
row.setNumOfComments(0);
}
} else {
row.setNumOfComments(0);
}
if (secCallback.canCloseSection(section)) {
if (SectionStatus.isClosed(section)) {
FormLink reopenLink = uifactory.addFormLink("ropens_" + (++counter), "reopen.section", "reopen.section", null, flc, Link.BUTTON_SMALL);
reopenLink.setUserObject(row);
row.setReopenSectionLink(reopenLink);
} else {
FormLink closeLink = uifactory.addFormLink("closes_" + (++counter), "close.section", "close.section", null, flc, Link.BUTTON_SMALL);
closeLink.setUserObject(row);
row.setCloseSectionLink(closeLink);
}
}
if (portfolioV2Module.isEntriesCommentsEnabled() && secCallback.canComment(page)) {
String title;
String cssClass = "o_icon o_icon-fw o_icon_comments";
if (row.getNumOfComments() == 1) {
title = translate("comment.one");
} else if (row.getNumOfComments() > 1) {
title = translate("comment.several", new String[] { Long.toString(row.getNumOfComments()) });
} else {
title = translate("comment.zero");
cssClass += "_none";
}
FormLink commentLink = uifactory.addFormLink("com_" + (++counter), "comment", title, null, flc, Link.LINK | Link.NONTRANSLATED);
commentLink.setIconLeftCSS(cssClass);
commentLink.setUserObject(row);
row.setCommentFormLink(commentLink);
}
return row;
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class AbstractPageListController method doMoveDownAssignment.
private void doMoveDownAssignment(UserRequest ureq, PortfolioElementRow row) {
Assignment assigment = row.getAssignment();
Section section = row.getSection();
section = portfolioService.moveDownAssignment(section, assigment);
loadModel(ureq, null);
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class AbstractPageListController method doMoveUpAssignment.
private void doMoveUpAssignment(UserRequest ureq, PortfolioElementRow row) {
Assignment assigment = row.getAssignment();
Section section = assigment.getSection();
section = portfolioService.moveUpAssignment(section, assigment);
loadModel(ureq, null);
}
use of org.olat.modules.portfolio.Section in project openolat by klemens.
the class AbstractPageListController method doReopen.
private void doReopen(UserRequest ureq, PortfolioElementRow row) {
Section section = row.getSection();
section = portfolioService.changeSectionStatus(section, SectionStatus.inProgress, getIdentity());
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_SECTION_REOPEN, getClass(), LoggingResourceable.wrap(section));
loadModel(ureq, null);
fireEvent(ureq, Event.CHANGED_EVENT);
}
Aggregations