use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PortfolioNotificationsHandler method getEvaluationNotifications.
public List<SubscriptionListItem> getEvaluationNotifications(Binder binder, BinderSecurityCallback secCallback, Date compareDate, String rootBusinessPath, Translator translator) {
StringBuilder sb = new StringBuilder();
sb.append("select page, evasession").append(" from pfpage as page").append(" inner join fetch page.section as section").append(" inner join fetch section.binder as binder").append(" left join evaluationformsession as evasession on (page.body.key = evasession.pageBody.key)").append(" where binder.key=:binderKey and evasession.status='done' and evasession.submissionDate>=:compareDate");
List<Object[]> objects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("binderKey", binder.getKey()).setParameter("compareDate", compareDate).getResultList();
List<SubscriptionListItem> items = new ArrayList<>(objects.size());
for (Object[] object : objects) {
// page
Page page = (Page) object[0];
Long pageKey = page.getKey();
String pageTitle = page.getTitle();
// session
EvaluationFormSession evaluationSession = (EvaluationFormSession) object[1];
Date submissionDate = evaluationSession.getSubmissionDate();
Date firstSubmissionDate = evaluationSession.getFirstSubmissionDate();
if (submissionDate != null && secCallback.canViewElement(page)) {
if (submissionDate.compareTo(firstSubmissionDate) == 0) {
SubscriptionListItem item = evaluationNewItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
items.add(item);
} else {
SubscriptionListItem item = evaluationModifiedItem(pageKey, pageTitle, submissionDate, rootBusinessPath, translator);
items.add(item);
}
}
}
return items;
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PortfolioServiceImpl method startAssignment.
@Override
public Assignment startAssignment(Long assignmentKey, Identity author) {
Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignmentKey);
if (reloadedAssignment.getPage() == null) {
Section section = reloadedAssignment.getSection();
if (reloadedAssignment.getAssignmentType() == AssignmentType.essay || reloadedAssignment.getAssignmentType() == AssignmentType.document) {
Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, null, section);
reloadedAssignment = assignmentDao.startEssayAssignment(reloadedAssignment, page, author);
} else if (reloadedAssignment.getAssignmentType() == AssignmentType.form) {
RepositoryEntry formEntry = reloadedAssignment.getFormEntry();
Page page = appendNewPage(author, reloadedAssignment.getTitle(), reloadedAssignment.getSummary(), null, false, null, section);
reloadedAssignment = assignmentDao.startFormAssignment(reloadedAssignment, page, author);
// create the session for the assignee
evaluationFormSessionDao.createSessionForPortfolio(author, page.getBody(), formEntry);
}
}
dbInstance.commit();
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_ASSIGNMENT_STARTED, getClass(), LoggingResourceable.wrap(reloadedAssignment.getSection()), LoggingResourceable.wrap(reloadedAssignment));
return reloadedAssignment;
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PortfolioServiceImpl method updatePage.
@Override
public Page updatePage(Page page, SectionRef newParentSection) {
Page updatedPage;
if (newParentSection == null) {
updatedPage = pageDao.updatePage(page);
} else {
Section currentSection = null;
if (page.getSection() != null) {
currentSection = binderDao.loadSectionByKey(page.getSection().getKey());
currentSection.getPages().remove(page);
}
Section newParent = binderDao.loadSectionByKey(newParentSection.getKey());
((PageImpl) page).setSection(newParent);
newParent.getPages().add(page);
updatedPage = pageDao.updatePage(page);
if (currentSection != null) {
binderDao.updateSection(currentSection);
}
binderDao.updateSection(newParent);
}
return updatedPage;
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
the class PortfolioServiceImpl method appendNewPage.
private Page appendNewPage(Identity owner, String title, String summary, String imagePath, boolean editable, PageImageAlign align, SectionRef section) {
Section reloadedSection = section == null ? null : binderDao.loadSectionByKey(section.getKey());
if (reloadedSection != null && reloadedSection.getSectionStatus() == SectionStatus.notStarted) {
((SectionImpl) reloadedSection).setSectionStatus(SectionStatus.inProgress);
}
Page page = pageDao.createAndPersist(title, summary, imagePath, align, editable, reloadedSection, null);
groupDao.addMembershipTwoWay(page.getBaseGroup(), owner, PortfolioRoles.owner.name());
return page;
}
use of org.olat.modules.portfolio.Page in project openolat by klemens.
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