use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.
the class PortfolioServiceTest method searchOwnedBinders.
@Test
public void searchOwnedBinders() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("binder-owner-");
Binder binder = portfolioService.createNewBinder("Binder 2", "Binder with one section.", null, owner);
dbInstance.commitAndCloseSession();
portfolioService.appendNewSection("First section", "My first section.", null, null, binder);
dbInstance.commitAndCloseSession();
portfolioService.appendNewSection("Second section", "My second section.", null, null, binder);
dbInstance.commitAndCloseSession();
List<Section> sections = portfolioService.getSections(binder);
for (int i = 0; i < 2; i++) {
Section section = sections.get(1);
portfolioService.appendNewPage(owner, "Page-1-" + i, "", null, null, section);
portfolioService.appendNewPage(owner, "Page-2-" + i, "", null, null, section);
}
List<BinderStatistics> rows = portfolioService.searchOwnedBinders(owner);
Assert.assertNotNull(rows);
Assert.assertEquals(1, rows.size());
BinderStatistics myBinder = rows.get(0);
Assert.assertEquals(2, myBinder.getNumOfSections());
Assert.assertEquals(4, myBinder.getNumOfPages());
}
use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.
the class BinderListController method loadModel.
protected void loadModel() {
List<BinderStatistics> binderRows = portfolioService.searchOwnedBinders(getIdentity());
List<BinderRow> rows = new ArrayList<>(binderRows.size());
for (BinderStatistics binderRow : binderRows) {
rows.add(forgePortfolioRow(binderRow));
}
if (portfolioModule.isLearnerCanCreateBinders() || portfolioModule.isCanCreateBindersFromTemplate() || portfolioModule.isCanCreateBindersFromCourse()) {
rows.add(new BinderRow());
}
model.setObjects(rows);
tableEl.reset();
tableEl.reloadData();
}
use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.
the class BinderDAO method getBinderStatistics.
/**
* The same type of query is user for the categories
* @param owner
* @return
*/
public BinderStatistics getBinderStatistics(BinderRef binder) {
StringBuilder sb = new StringBuilder();
sb.append("select binder.key, binder.title, binder.imagePath, binder.lastModified, binder.status,").append(" binderEntry.displayname,").append(" (select count(section.key) from pfsection as section").append(" where section.binder.key=binder.key").append(" ) as numOfSections,").append(" (select count(page.key) from pfpage as page, pfsection as pageSection").append(" where pageSection.binder.key=binder.key and page.section.key=pageSection.key").append(" ) as numOfPages,").append(" (select count(comment.key) from usercomment as comment, pfpage as page, pfsection as pageSection").append(" where pageSection.binder.key=binder.key and page.section.key=pageSection.key and comment.resId=page.key and comment.resName='Page'").append(" ) as numOfComments").append(" from pfbinder as binder").append(" left join binder.entry binderEntry").append(" where binder.key=:binderKey");
List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).getResultList();
if (objects.size() >= 1) {
int pos = 0;
Object[] object = objects.get(0);
Long key = (Long) object[pos++];
String title = (String) object[pos++];
String imagePath = (String) object[pos++];
Date lastModified = (Date) object[pos++];
String status = (String) object[pos++];
String repoEntryName = (String) object[pos++];
int numOfSections = ((Number) object[pos++]).intValue();
int numOfPages = ((Number) object[pos++]).intValue();
int numOfComments = ((Number) object[pos++]).intValue();
return new BinderStatistics(key, title, imagePath, lastModified, numOfSections, numOfPages, status, repoEntryName, numOfComments);
}
return null;
}
use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.
the class ConfirmDeleteBinderController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
StringBuilder names = new StringBuilder();
int numOfPages = 0;
int numOfSections = 0;
int numOfComments = 0;
for (BinderStatistics stat : stats) {
if (names.length() > 0)
names.append(", ");
names.append(StringHelper.escapeHtml(stat.getTitle()));
numOfPages += stat.getNumOfPages();
numOfSections += stat.getNumOfSections();
numOfComments += stat.getNumOfComments();
}
String[] args = new String[] { names.toString(), Integer.toString(numOfSections), Integer.toString(numOfPages), Integer.toString(numOfComments) };
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("msg", translate("delete.binder.warning", args));
layoutCont.contextPut("dangerCssClass", "o_error");
}
String[] onValues = new String[] { translate("delete.binder.acknowledge") };
acknowledgeEl = uifactory.addCheckboxesHorizontal("acknowledge", "confirmation", formLayout, onKeys, onValues);
String[] on2Values = new String[] { translate("delete.binder.acknowledge.2") };
acknowledge2El = uifactory.addCheckboxesHorizontal("acknowledge2", "confirmation", formLayout, onKeys, on2Values);
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
uifactory.addFormSubmitButton("delete", "delete.binder", formLayout);
}
use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.
the class DeletedBinderController method doConfirmDelete.
private void doConfirmDelete(UserRequest ureq) {
if (deleteBinderCtrl != null)
return;
List<BinderRow> rows = getSelectedRows();
if (rows.isEmpty()) {
showWarning("binder.atleastone");
} else {
List<BinderStatistics> stats = new ArrayList<>(rows.size());
for (BinderRow row : rows) {
stats.add(row.getStatistics());
}
deleteBinderCtrl = new ConfirmDeleteBinderController(ureq, getWindowControl(), stats);
listenTo(deleteBinderCtrl);
String title = translate("delete.binder");
cmc = new CloseableModalController(getWindowControl(), null, deleteBinderCtrl.getInitialComponent(), true, title, true);
listenTo(cmc);
cmc.activate();
}
}
Aggregations