use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class BinderPageListController method doFilterSection.
protected void doFilterSection(Section section) {
this.filteringSection = section;
List<Section> currentSections = model.filter(section);
tableEl.reloadData();
updateTimeline();
int index = currentSections.indexOf(section);
previousSectionLink.setEnabled(index > 0);
if (index > 0) {
String previousTitle = currentSections.get(index - 1).getTitle();
previousSectionLink.setI18nKey(translate("section.paging.with.title", new String[] { previousTitle }));
previousSectionLink.setUserObject(currentSections.get(index - 1));
} else {
previousSectionLink.setI18nKey(translate("section.paging.previous"));
}
if (index >= 0 && index + 1 < currentSections.size()) {
String nextTitle = currentSections.get(index + 1).getTitle();
nextSectionLink.setI18nKey(translate("section.paging.with.title", new String[] { nextTitle }));
nextSectionLink.setEnabled(true);
nextSectionLink.setUserObject(currentSections.get(index + 1));
} else {
nextSectionLink.setI18nKey(translate("section.paging.next"));
nextSectionLink.setEnabled(false);
}
boolean visible = currentSections.size() > 1;
previousSectionLink.setVisible(visible);
nextSectionLink.setVisible(visible);
showAllSectionsLink.setVisible(visible);
flc.setDirty(true);
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class TableOfContentController method loadModel.
protected void loadModel() {
mainVC.contextPut("binderTitle", StringHelper.escapeHtml(binder.getTitle()));
if (StringHelper.containsNonWhitespace(binder.getSummary())) {
summaryComp.setText(binder.getSummary());
mainVC.put("summary", summaryCtrl.getInitialComponent());
} else {
mainVC.remove("summary");
}
List<SectionRow> sectionRows = new ArrayList<>();
Map<Long, SectionRow> sectionMap = new HashMap<>();
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = new HashMap<>();
for (AssessmentSection assessmentSection : assessmentSections) {
sectionToAssessmentSectionMap.put(assessmentSection.getSection(), assessmentSection);
}
// assignments
List<Assignment> assignments = portfolioService.getAssignments(binder, null);
Map<Section, List<Assignment>> sectionToAssignmentMap = new HashMap<>();
for (Assignment assignment : assignments) {
List<Assignment> assignmentList;
if (sectionToAssignmentMap.containsKey(assignment.getSection())) {
assignmentList = sectionToAssignmentMap.get(assignment.getSection());
} else {
assignmentList = new ArrayList<>();
sectionToAssignmentMap.put(assignment.getSection(), assignmentList);
}
assignmentList.add(assignment);
}
List<Section> sections = portfolioService.getSections(binder);
int count = 0;
for (Section section : sections) {
boolean first = count == 0;
boolean last = count == sections.size() - 1;
count++;
if (secCallback.canViewElement(section)) {
SectionRow sectionRow = forgeSectionRow(section, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), first, last);
sectionRows.add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
}
}
loadPagesModel(sectionMap);
mainVC.contextPut("sections", sectionRows);
sectionList = sectionRows;
if (secCallback.canAddSection()) {
if (newSectionButton == null) {
newSectionButton = LinkFactory.createButton("create.new.section", mainVC, this);
newSectionButton.setCustomEnabledLinkCSS("btn btn-primary");
}
mainVC.put("create.new.section", newSectionButton);
}
boolean hasSection = (sectionList != null && sectionList.size() > 0);
if (newEntryLink != null && newEntryLink.isVisible() != hasSection) {
newEntryLink.setVisible(hasSection);
stackPanel.setDirty(true);
}
if (newAssignmentLink != null && newAssignmentLink.isVisible() != hasSection) {
newAssignmentLink.setVisible(hasSection);
stackPanel.setDirty(true);
}
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class TableOfContentController method doClose.
private void doClose(SectionRow row) {
Section section = row.getSection();
section = portfolioService.changeSectionStatus(section, SectionStatus.closed, getIdentity());
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_SECTION_CLOSE, getClass(), LoggingResourceable.wrap(section));
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class TableOfContentController method loadPagesModel.
private void loadPagesModel(Map<Long, SectionRow> sectionMap) {
boolean showUserInfos = secCallback.canPageUserInfosStatus();
mainVC.contextPut("userInfos", Boolean.valueOf(showUserInfos));
Map<Long, PageUserInformations> userInfosToPages = new HashMap<>();
if (showUserInfos) {
List<PageUserInformations> userInfos = portfolioService.getPageUserInfos(binder, getIdentity());
for (PageUserInformations userInfo : userInfos) {
userInfosToPages.put(userInfo.getPage().getKey(), userInfo);
}
mainVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
}
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
Section section = page.getSection();
if (section != null && sectionMap.containsKey(section.getKey())) {
boolean viewElement = secCallback.canViewElement(page);
boolean viewTitleElement = secCallback.canViewTitleOfElement(page);
if (viewElement || viewTitleElement) {
SectionRow sectionRow = sectionMap.get(section.getKey());
PageRow pageRow = forgePageRow(page, numberOfCommentsMap, viewElement);
sectionRow.getPages().add(pageRow);
if (showUserInfos) {
PageUserInformations userInfos = userInfosToPages.get(pageRow.getPage().getKey());
if (userInfos != null) {
pageRow.setUserInfosStatus(userInfos.getStatus());
}
}
}
}
}
}
use of org.olat.modules.portfolio.Section in project OpenOLAT by OpenOLAT.
the class BinderDAO method deleteBinder.
public int deleteBinder(BinderRef binderRef) {
int rows = userInformationsDAO.deleteBinderUserInfos(binderRef);
BinderImpl binder = (BinderImpl) loadByKey(binderRef.getKey());
List<Section> sections = new ArrayList<>(binder.getSections());
for (Section section : sections) {
List<Page> pages = new ArrayList<>(section.getPages());
section.getPages().clear();
section = dbInstance.getCurrentEntityManager().merge(section);
for (Page page : pages) {
if (page != null) {
rows += pageDao.deletePage(page);
rows += pageUserInfosDao.delete(page);
}
}
rows += assessmentSectionDao.deleteAssessmentSections(section);
Group baseGroup = section.getBaseGroup();
rows += groupDao.removeMemberships(baseGroup);
dbInstance.getCurrentEntityManager().remove(section);
dbInstance.getCurrentEntityManager().remove(baseGroup);
rows += 2;
}
binder.getSections().clear();
Group baseGroup = binder.getBaseGroup();
rows += groupDao.removeMemberships(baseGroup);
dbInstance.getCurrentEntityManager().remove(binder);
dbInstance.getCurrentEntityManager().remove(baseGroup);
return rows + 2;
}
Aggregations