Search in sources :

Example 56 with PortfolioStructureMap

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);
                }
            }
        }
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 57 with PortfolioStructureMap

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);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Example 58 with PortfolioStructureMap

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);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) AssertException(org.olat.core.logging.AssertException) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate)

Example 59 with PortfolioStructureMap

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;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) DBQuery(org.olat.core.commons.persistence.DBQuery) Date(java.util.Date)

Example 60 with PortfolioStructureMap

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;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)118 Test (org.junit.Test)64 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)54 Identity (org.olat.core.id.Identity)34 RepositoryEntry (org.olat.repository.RepositoryEntry)30 OLATResource (org.olat.resource.OLATResource)30 ArrayList (java.util.ArrayList)18 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)18 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)18 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 Date (java.util.Date)10 Invitation (org.olat.basesecurity.Invitation)8 Binder (org.olat.modules.portfolio.Binder)8 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)8 EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 Link (org.olat.core.gui.components.link.Link)4