use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class PortfolioServiceImpl method deleteAssignment.
@Override
public boolean deleteAssignment(Assignment assignment) {
Assignment reloadedAssignment = assignmentDao.loadAssignmentByKey(assignment.getKey());
Section reloadedSection = reloadedAssignment.getSection();
boolean removed = false;
if (reloadedSection != null) {
removed = ((SectionImpl) reloadedSection).getAssignments().remove(reloadedAssignment);
}
assignmentDao.deleteAssignment(reloadedAssignment);
if (removed) {
binderDao.updateSection(reloadedSection);
}
return true;
}
use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
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.Assignment 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.Assignment in project OpenOLAT by OpenOLAT.
the class AssignmentDAO method moveDownAssignment.
public Section moveDownAssignment(SectionImpl section, Assignment assignment) {
section.getAssignments().size();
int index = section.getAssignments().indexOf(assignment);
if (index >= 0 && index + 1 < section.getAssignments().size()) {
Assignment reloadedAssignment = section.getAssignments().remove(index);
section.getAssignments().add(index + 1, reloadedAssignment);
section = dbInstance.getCurrentEntityManager().merge(section);
}
return section;
}
use of org.olat.modules.portfolio.Assignment in project OpenOLAT by OpenOLAT.
the class AssignmentDAO method moveUpAssignment.
public Section moveUpAssignment(SectionImpl section, Assignment assignment) {
section.getAssignments().size();
int index = section.getAssignments().indexOf(assignment);
if (index > 0) {
Assignment reloadedAssigment = section.getAssignments().remove(index);
section.getAssignments().add(index - 1, reloadedAssigment);
} else if (index < 0) {
section.getAssignments().add(0, assignment);
}
section = dbInstance.getCurrentEntityManager().merge(section);
return section;
}
Aggregations