use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.
the class OLATUpgrade_11_0_0 method processAssessmentPropertyForPortfolio.
private void processAssessmentPropertyForPortfolio(Identity assessedIdentity, AssessmentEntryImpl entry, PortfolioCourseNode cNode, ICourse course) {
entry.setAssessmentStatus(AssessmentEntryStatus.notStarted);
Long courseResId = course.getCourseEnvironment().getCourseResourceableId();
RepositoryEntry mapEntry = cNode.getReferencedRepositoryEntry();
if (mapEntry != null) {
PortfolioStructureMap template = (PortfolioStructureMap) ePFMgr.loadPortfolioStructure(mapEntry.getOlatResource());
if (template != null) {
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseResId);
PortfolioStructureMap copy = ePFMgr.loadPortfolioStructureMap(assessedIdentity, template, courseOres, cNode.getIdent(), null);
if (copy != null) {
String status = copy.getStatus();
if (StructureStatusEnum.CLOSED.equals(status)) {
entry.setAssessmentStatus(AssessmentEntryStatus.inReview);
} else {
entry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
}
}
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPStructureManager method createPortfolioStructure.
/**
* Create a basic structure element
* @param title
* @param description
* @return The structure element
*/
protected PortfolioStructure createPortfolioStructure(PortfolioStructure root, String title, String description) {
EPStructureElement el = new EPStructureElement();
el.setRoot((EPStructureElement) root);
if (root != null && root.getRootMap() == null && root instanceof PortfolioStructureMap) {
el.setRootMap((PortfolioStructureMap) root);
} else if (root != null) {
el.setRootMap(root.getRootMap());
}
return fillStructureElement(el, title, description);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPStructureManager method loadPortfolioStructuredMap.
public PortfolioStructureMap loadPortfolioStructuredMap(IdentityRef identity, PortfolioStructureMap template, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
if (template == null)
throw new NullPointerException();
if (!(template instanceof EPStructuredMapTemplate))
throw new AssertException("Only template are acceptable");
StringBuilder sb = new StringBuilder();
sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" map").append(" left join fetch map.targetResource as targetResource").append(" inner join map.groups as relGroup on relGroup.defaultGroup=true").append(" inner join relGroup.group as baseGroup").append(" where map.structuredMapSource=:template");
if (targetOres != null) {
sb.append(" and targetResource.resourceableId=:resourceId").append(" and targetResource.resourceableTypeName=:resourceType");
}
if (targetSubPath != null) {
sb.append(" and targetResource.subPath=:subPath");
}
if (targetBusinessPath != null) {
sb.append(" and targetResource.businessPath=:businessPath");
}
sb.append(" and exists (select membership from bgroupmember as membership ").append(" where baseGroup=membership.group and membership.identity.key=:identityKey and membership.role='").append(GroupRoles.owner.name()).append("'").append(" )");
TypedQuery<PortfolioStructureMap> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), PortfolioStructureMap.class).setParameter("template", template).setParameter("identityKey", identity.getKey());
if (targetOres != null) {
query.setParameter("resourceId", targetOres.getResourceableId());
query.setParameter("resourceType", targetOres.getResourceableTypeName());
}
if (targetSubPath != null) {
query.setParameter("subPath", targetSubPath);
}
if (targetBusinessPath != null) {
query.setParameter("businessPath", targetBusinessPath);
}
List<PortfolioStructureMap> maps = query.getResultList();
// if not found, it is an empty list
return maps.isEmpty() ? null : maps.get(0);
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPStructureManager method getOpenStructuredMapAfterDeadline.
protected List<PortfolioStructureMap> getOpenStructuredMapAfterDeadline() {
StringBuilder sb = new StringBuilder();
sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" as map");
sb.append(" where (map.status is null or not(map.status = 'closed'))").append(" and map.deadLine<:currentDate");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setDate("currentDate", new Date());
@SuppressWarnings("unchecked") List<PortfolioStructureMap> maps = query.list();
return maps;
}
use of org.olat.portfolio.model.structel.PortfolioStructureMap in project OpenOLAT by OpenOLAT.
the class EPFrontendManager method assignStructuredMapToUser.
/**
* Assign a structure map to user. In other words, make a copy of the template
* and set the user as an author.
*
* @param identity
* @param portfolioStructureStructuredMapTemplate
*/
public PortfolioStructureMap assignStructuredMapToUser(final Identity identity, final PortfolioStructureMap mapTemplate, final RepositoryEntry courseEntry, String targetSubPath, final String targetBusinessPath, final Date deadline) {
// doInSync is here to check for nested doInSync exception in first place
final OLATResource ores = courseEntry.getOlatResource();
final String subPath = targetSubPath;
PortfolioStructureMap map = coordinator.getSyncer().doInSync(mapTemplate.getOlatResource(), new SyncerCallback<PortfolioStructureMap>() {
@Override
public PortfolioStructureMap execute() {
PortfolioStructureMap template = (PortfolioStructureMap) structureManager.loadPortfolioStructureByKey(mapTemplate.getKey());
String title = template.getTitle();
String description = template.getDescription();
PortfolioStructureMap copy = structureManager.createPortfolioStructuredMap(template, identity, title, description, ores, subPath, targetBusinessPath);
if (copy instanceof EPStructuredMap) {
((EPStructuredMap) copy).setDeadLine(deadline);
}
structureManager.copyStructureRecursively(template, copy, true);
RepositoryEntry referenceEntry = repositoryEntryDao.loadByResourceKey(template.getOlatResource().getKey());
assessmentService.updateAssessmentEntry(identity, courseEntry, targetSubPath, referenceEntry, AssessmentEntryStatus.inProgress);
return copy;
}
});
return map;
}
Aggregations