use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class AbstractPageListController method doMoveAssignment.
private void doMoveAssignment(UserRequest ureq, PortfolioElementRow row) {
if (moveAssignmentCtrl != null)
return;
Assignment assignment = row.getAssignment();
moveAssignmentCtrl = new AssignmentMoveController(ureq, getWindowControl(), assignment, row.getSection());
listenTo(moveAssignmentCtrl);
String title = translate("move.assignment");
cmc = new CloseableModalController(getWindowControl(), null, moveAssignmentCtrl.getInitialComponent(), true, title, true);
listenTo(cmc);
cmc.activate();
}
use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class AbstractPageListController method forgeSectionRow.
protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
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.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
if (!startableAssignments.isEmpty()) {
String[] keys = new String[startableAssignments.size() + 1];
String[] values = new String[startableAssignments.size() + 1];
keys[0] = "start.assignment.hint";
values[0] = translate("start.assignment.hint");
int count = 1;
for (Assignment assignment : startableAssignments) {
keys[count] = Long.toString(assignment.getKey());
values[count] = assignment.getTitle();
count++;
}
SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
startEl.setDomReplacementWrapperRequired(false);
startEl.addActionListener(FormEvent.ONCHANGE);
row.setStartSelection(startEl);
}
}
return row;
}
use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class BinderPageListController method loadModel.
@Override
protected void loadModel(UserRequest ureq, String searchString) {
if (StringHelper.containsNonWhitespace(binder.getSummary())) {
summaryComp.setText(binder.getSummary());
flc.getFormItemComponent().put("summary", summaryCtrl.getInitialComponent());
} else {
flc.getFormItemComponent().remove("summary");
}
List<Section> sections = portfolioService.getSections(binder);
List<CategoryToElement> categorizedElements = portfolioService.getCategorizedSectionsAndPages(binder);
Map<OLATResourceable, List<Category>> categorizedElementMap = new HashMap<>();
Map<Section, Set<String>> sectionAggregatedCategoriesMap = new HashMap<>();
for (CategoryToElement categorizedElement : categorizedElements) {
List<Category> categories = categorizedElementMap.get(categorizedElement.getCategorizedResource());
if (categories == null) {
categories = new ArrayList<>();
categorizedElementMap.put(categorizedElement.getCategorizedResource(), categories);
}
categories.add(categorizedElement.getCategory());
}
// comments
Map<Long, Long> numberOfCommentsMap = portfolioService.getNumberOfComments(binder);
// assessment sections
List<AssessmentSection> assessmentSections = portfolioService.getAssessmentSections(binder, getIdentity());
Map<Section, AssessmentSection> sectionToAssessmentSectionMap = assessmentSections.stream().collect(Collectors.toMap(as -> as.getSection(), as -> as));
List<PortfolioElementRow> rows = new ArrayList<>();
// assignments
List<Assignment> assignments = portfolioService.getAssignments(binder, searchString);
Map<Section, List<Assignment>> sectionToAssignmentMap = new HashMap<>();
for (Assignment assignment : assignments) {
List<Assignment> assignmentList;
Section section = assignment.getSection();
if (sectionToAssignmentMap.containsKey(section)) {
assignmentList = sectionToAssignmentMap.get(section);
} else {
assignmentList = new ArrayList<>();
sectionToAssignmentMap.put(section, assignmentList);
}
assignmentList.add(assignment);
}
for (Assignment assignment : assignments) {
Section section = assignment.getSection();
if (assignment.getPage() == null && secCallback.canViewPendingAssignments(section)) {
List<Assignment> sectionAssignments = sectionToAssignmentMap.get(section);
PortfolioElementRow row = forgePendingAssignmentRow(assignment, section, sectionAssignments);
rows.add(row);
if (secCallback.canAddPage(section)) {
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
newEntryButton.setUserObject(row);
row.setNewEntryLink(newEntryButton);
}
}
}
boolean userInfos = secCallback.canPageUserInfosStatus();
Map<Long, PageUserInformations> userInfosToPage = new HashMap<>();
rowVC.contextPut("userInfos", Boolean.valueOf(userInfos));
if (userInfos) {
rowVC.contextPut("userInfosRenderer", new SharedPageStatusCellRenderer(getTranslator()));
List<PageUserInformations> userInfoList = portfolioService.getPageUserInfos(binder, getIdentity());
for (PageUserInformations userInfo : userInfoList) {
userInfosToPage.put(userInfo.getPage().getKey(), userInfo);
}
}
List<Page> pages = portfolioService.getPages(binder, searchString);
for (Page page : pages) {
boolean viewElement = secCallback.canViewElement(page);
boolean viewTitleElement = viewElement || secCallback.canViewTitleOfElement(page);
if (!viewTitleElement) {
continue;
}
Section section = page.getSection();
PortfolioElementRow pageRow = forgePageRow(ureq, page, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), categorizedElementMap, numberOfCommentsMap, viewElement);
rows.add(pageRow);
if (secCallback.canAddPage(section)) {
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
newEntryButton.setUserObject(pageRow);
pageRow.setNewEntryLink(newEntryButton);
}
if (secCallback.canNewAssignment() && section != null) {
FormLink newAssignmentButton = uifactory.addFormLink("new.assignment." + (++counter), "new.assignment", "create.new.assignment", null, flc, Link.BUTTON);
newAssignmentButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_assignment");
newAssignmentButton.setUserObject(pageRow);
pageRow.setNewAssignmentLink(newAssignmentButton);
}
if (userInfos) {
PageUserInformations infos = userInfosToPage.get(page.getKey());
if (infos != null) {
pageRow.setUserInfosStatus(infos.getStatus());
}
}
if (section != null) {
Set<String> categories = sectionAggregatedCategoriesMap.get(section);
if (categories == null) {
categories = new HashSet<>();
sectionAggregatedCategoriesMap.put(section, categories);
}
if (pageRow.getPageCategories() != null && pageRow.getPageCategories().size() > 0) {
categories.addAll(pageRow.getPageCategories());
}
pageRow.setSectionCategories(categories);
}
}
// sections without pages
if (!StringHelper.containsNonWhitespace(searchString)) {
for (Section section : sections) {
if (!secCallback.canViewElement(section)) {
continue;
}
PortfolioElementRow sectionRow = forgeSectionRow(section, sectionToAssessmentSectionMap.get(section), sectionToAssignmentMap.get(section), categorizedElementMap);
rows.add(sectionRow);
if (secCallback.canAddPage(section)) {
FormLink newEntryButton = uifactory.addFormLink("new.entry." + (++counter), "new.entry", "create.new.page", null, flc, Link.BUTTON);
newEntryButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_entry");
newEntryButton.setUserObject(sectionRow);
sectionRow.setNewEntryLink(newEntryButton);
}
if (secCallback.canNewAssignment() && section != null) {
FormLink newAssignmentButton = uifactory.addFormLink("new.assignment." + (++counter), "new.assignment", "create.new.assignment", null, flc, Link.BUTTON);
newAssignmentButton.setCustomEnabledLinkCSS("btn btn-primary o_sel_pf_new_assignment");
newAssignmentButton.setUserObject(sectionRow);
sectionRow.setNewAssignmentLink(newAssignmentButton);
}
}
}
if (newSectionButton != null && rows.isEmpty()) {
flc.add("create.new.section", newSectionButton);
} else if (newSectionButton != null) {
flc.remove(newSectionButton);
}
if (newEntryLink != null && !newEntryLink.isVisible()) {
newEntryLink.setVisible(rows.size() > 0);
stackPanel.setDirty(true);
}
if (newAssignmentLink != null && !newAssignmentLink.isVisible()) {
newAssignmentLink.setVisible(rows.size() > 0);
stackPanel.setDirty(true);
}
// clean up the posters
disposeRows();
model.setObjects(rows);
if (filteringSection != null) {
doFilterSection(filteringSection);
} else {
tableEl.reloadData();
updateTimeline();
}
}
use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class TableOfContentController method forgeSectionRow.
private SectionRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignemnts, boolean first, boolean last) {
String sectionId = "section" + (++counter);
String title = StringHelper.escapeHtml(section.getTitle());
List<Assignment> notAssignedAssignments = new ArrayList<>();
if (secCallback.canViewPendingAssignments(section)) {
if (assignemnts != null) {
for (Assignment assignemnt : assignemnts) {
if (assignemnt.getPage() == null) {
notAssignedAssignments.add(assignemnt);
}
}
}
}
Link sectionLink = LinkFactory.createCustomLink(sectionId, "open_section", title, Link.LINK | Link.NONTRANSLATED, mainVC, this);
SectionRow sectionRow = new SectionRow(section, sectionLink, assessmentSection, notAssignedAssignments);
sectionLink.setUserObject(sectionRow);
Dropdown editDropdown = new Dropdown(sectionId.concat("_dropdown"), null, false, getTranslator());
editDropdown.setElementCssClass("o_sel_pf_section_tools");
editDropdown.setTranslatedLabel("");
editDropdown.setOrientation(DropdownOrientation.right);
editDropdown.setIconCSS("o_icon o_icon_actions");
if (secCallback.canCloseSection(section)) {
if (SectionStatus.isClosed(section)) {
Link reopenLink = LinkFactory.createLink(sectionId.concat("_ropens"), "reopen.section", "reopen.section", mainVC, this);
reopenLink.setUserObject(sectionRow);
editDropdown.addComponent(reopenLink);
} else {
Link closeLink = LinkFactory.createLink(sectionId.concat("_closes"), "close.section", "close.section", mainVC, this);
closeLink.setUserObject(sectionRow);
editDropdown.addComponent(closeLink);
}
if (section.getEndDate() != null) {
Link overrideDatesLink = LinkFactory.createLink(sectionId.concat("_overd"), "override.dates.section", "override.dates.section", mainVC, this);
overrideDatesLink.setUserObject(sectionRow);
editDropdown.addComponent(overrideDatesLink);
}
}
if (secCallback.canEditSection()) {
Link editSectionLink = LinkFactory.createLink(sectionId.concat("_edit"), "section.edit", "edit_section", mainVC, this);
editSectionLink.setIconLeftCSS("o_icon o_icon_edit");
editSectionLink.setUserObject(sectionRow);
editDropdown.addComponent(editSectionLink);
Link deleteSectionLink = LinkFactory.createLink(sectionId.concat("_delete"), "section.delete", "delete_section", mainVC, this);
deleteSectionLink.setElementCssClass("o_sel_pf_delete_section");
deleteSectionLink.setIconLeftCSS("o_icon o_icon_delete_item");
deleteSectionLink.setUserObject(sectionRow);
editDropdown.addComponent(deleteSectionLink);
Link upSectionLink = LinkFactory.createCustomLink(sectionId.concat("_up"), "up_section", "", Link.LINK | Link.NONTRANSLATED, mainVC, this);
upSectionLink.setIconLeftCSS("o_icon o_icon o_icon-lg o_icon_move_up");
upSectionLink.setUserObject(sectionRow);
upSectionLink.setEnabled(!first);
sectionRow.setUpSectionLink(upSectionLink);
Link downSectionLink = LinkFactory.createCustomLink(sectionId.concat("_down"), "down_section", "", Link.LINK | Link.NONTRANSLATED, mainVC, this);
downSectionLink.setIconLeftCSS("o_icon o_icon o_icon-lg o_icon_move_down");
downSectionLink.setUserObject(sectionRow);
downSectionLink.setEnabled(!last);
sectionRow.setDownSectionLink(downSectionLink);
}
if (editDropdown.getComponents().iterator().hasNext()) {
mainVC.put(editDropdown.getComponentName(), editDropdown);
sectionRow.setEditDropdown(editDropdown);
}
return sectionRow;
}
use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method internalCopyTransientBinder.
private Binder internalCopyTransientBinder(Binder transientBinder, RepositoryEntry entry, String imagePath, boolean copy) {
Binder binder = binderDao.createAndPersist(transientBinder.getTitle(), transientBinder.getSummary(), imagePath, entry);
// copy sections
for (Section transientSection : ((BinderImpl) transientBinder).getSections()) {
SectionImpl section = binderDao.createSection(transientSection.getTitle(), transientSection.getDescription(), transientSection.getBeginDate(), transientSection.getEndDate(), binder);
List<Assignment> transientAssignments = ((SectionImpl) transientSection).getAssignments();
for (Assignment transientAssignment : transientAssignments) {
if (transientAssignment != null) {
File newStorage = portfolioFileStorage.generateAssignmentSubDirectory();
String storage = portfolioFileStorage.getRelativePath(newStorage);
assignmentDao.createAssignment(transientAssignment.getTitle(), transientAssignment.getSummary(), transientAssignment.getContent(), storage, transientAssignment.getAssignmentType(), transientAssignment.getAssignmentStatus(), section, transientAssignment.isOnlyAutoEvaluation(), transientAssignment.isReviewerSeeAutoEvaluation(), transientAssignment.isAnonymousExternalEvaluation(), transientAssignment.getFormEntry());
// copy attachments
File templateDirectory = portfolioFileStorage.getAssignmentDirectory(transientAssignment);
if (copy && templateDirectory != null) {
FileUtils.copyDirContentsToDir(templateDirectory, newStorage, false, "Assignment attachments");
}
}
}
}
return binder;
}
Aggregations