use of org.olat.modules.portfolio.model.AssignmentImpl in project openolat by klemens.
the class BinderDAO method syncAssignments.
private void syncAssignments(SectionImpl templateSection, SectionImpl currentSection) {
List<Assignment> templateAssignments = new ArrayList<>(templateSection.getAssignments());
List<Assignment> currentAssignments = new ArrayList<>(currentSection.getAssignments());
for (Assignment currentAssignment : currentAssignments) {
if (currentAssignment == null) {
log.error("Missing assignment: " + currentSection.getKey());
continue;
}
Assignment refAssignment = currentAssignment.getTemplateReference();
if (refAssignment == null) {
if (currentAssignment.getAssignmentStatus() != AssignmentStatus.deleted) {
currentAssignment.setAssignmentStatus(AssignmentStatus.deleted);
currentAssignment = dbInstance.getCurrentEntityManager().merge(currentAssignment);
}
} else if (!templateAssignments.contains(refAssignment)) {
// this case is normally not possible
// if it happens, don't do anything, let the data safe
} else {
templateAssignments.remove(refAssignment);
AssignmentImpl currentImpl = (AssignmentImpl) currentAssignment;
currentAssignment = syncAssignment(refAssignment, currentImpl);
}
}
for (Assignment templateAssignment : templateAssignments) {
if (templateAssignment != null) {
assignmentDao.createAssignment(templateAssignment, AssignmentStatus.notStarted, currentSection);
}
}
}
use of org.olat.modules.portfolio.model.AssignmentImpl in project OpenOLAT by OpenOLAT.
the class BinderDAO method syncAssignments.
private void syncAssignments(SectionImpl templateSection, SectionImpl currentSection) {
List<Assignment> templateAssignments = new ArrayList<>(templateSection.getAssignments());
List<Assignment> currentAssignments = new ArrayList<>(currentSection.getAssignments());
for (Assignment currentAssignment : currentAssignments) {
if (currentAssignment == null) {
log.error("Missing assignment: " + currentSection.getKey());
continue;
}
Assignment refAssignment = currentAssignment.getTemplateReference();
if (refAssignment == null) {
if (currentAssignment.getAssignmentStatus() != AssignmentStatus.deleted) {
currentAssignment.setAssignmentStatus(AssignmentStatus.deleted);
currentAssignment = dbInstance.getCurrentEntityManager().merge(currentAssignment);
}
} else if (!templateAssignments.contains(refAssignment)) {
// this case is normally not possible
// if it happens, don't do anything, let the data safe
} else {
templateAssignments.remove(refAssignment);
AssignmentImpl currentImpl = (AssignmentImpl) currentAssignment;
currentAssignment = syncAssignment(refAssignment, currentImpl);
}
}
for (Assignment templateAssignment : templateAssignments) {
if (templateAssignment != null) {
assignmentDao.createAssignment(templateAssignment, AssignmentStatus.notStarted, currentSection);
}
}
}
use of org.olat.modules.portfolio.model.AssignmentImpl in project OpenOLAT by OpenOLAT.
the class AssignmentDAO method createAssignment.
public Assignment createAssignment(String title, String summary, String content, String storage, AssignmentType type, AssignmentStatus status, Section section, boolean onlyAutoEvaluation, boolean reviewerSeeAutoEvaluation, boolean anonymousExternEvaluation, RepositoryEntry formEntry) {
AssignmentImpl assignment = new AssignmentImpl();
assignment.setCreationDate(new Date());
assignment.setLastModified(assignment.getCreationDate());
assignment.setTitle(title);
assignment.setSummary(summary);
assignment.setContent(content);
assignment.setStorage(storage);
assignment.setSection(section);
assignment.setType(type.name());
assignment.setStatus(status.name());
assignment.setOnlyAutoEvaluation(onlyAutoEvaluation);
assignment.setReviewerSeeAutoEvaluation(reviewerSeeAutoEvaluation);
assignment.setAnonymousExternalEvaluation(anonymousExternEvaluation);
assignment.setFormEntry(formEntry);
((SectionImpl) section).getAssignments().size();
((SectionImpl) section).getAssignments().add(assignment);
dbInstance.getCurrentEntityManager().persist(assignment);
dbInstance.getCurrentEntityManager().merge(section);
return assignment;
}
use of org.olat.modules.portfolio.model.AssignmentImpl in project OpenOLAT by OpenOLAT.
the class AssignmentDAO method moveAssignment.
public void moveAssignment(SectionImpl currentSection, Assignment assignment, SectionImpl newParentSection) {
// load the assignments
currentSection.getAssignments().size();
newParentSection.getAssignments().size();
int index = currentSection.getAssignments().indexOf(assignment);
if (index >= 0) {
Assignment reloadedAssignment = currentSection.getAssignments().remove(index);
((AssignmentImpl) reloadedAssignment).setSection(newParentSection);
dbInstance.getCurrentEntityManager().merge(currentSection);
newParentSection.getAssignments().add(reloadedAssignment);
reloadedAssignment = dbInstance.getCurrentEntityManager().merge(reloadedAssignment);
dbInstance.getCurrentEntityManager().merge(newParentSection);
}
}
use of org.olat.modules.portfolio.model.AssignmentImpl in project OpenOLAT by OpenOLAT.
the class AssignmentDAO method startFormAssignment.
public Assignment startFormAssignment(Assignment assignment, Page page, Identity assignee) {
((AssignmentImpl) assignment).setPage(page);
((AssignmentImpl) assignment).setAssignee(assignee);
((AssignmentImpl) assignment).setLastModified(new Date());
assignment.setAssignmentStatus(AssignmentStatus.inProgress);
RepositoryEntry formEntry = assignment.getFormEntry();
if (formEntry.getOlatResource().getResourceableTypeName().equals(formHandler.getSupportedType())) {
File formFile = formHandler.getFormFile(formEntry);
String formXml = FileUtils.load(formFile, "UTF-8");
EvaluationFormPart formPart = new EvaluationFormPart();
formPart.setContent(formXml);
formPart.setFormEntry(formEntry);
pageDao.persistPart(page.getBody(), formPart);
}
return dbInstance.getCurrentEntityManager().merge(assignment);
}
Aggregations