Search in sources :

Example 11 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource in project OpenOLAT by OpenOLAT.

the class EPStructureManagerTest method testLoadPortfolioStructuredMap.

@Test
public void testLoadPortfolioStructuredMap() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
    // create a template
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    // clone the template
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
    ((EPStructuredMap) map).setReturnDate(new Date());
    EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
    targetResource.setResourceableTypeName("CourseModule");
    targetResource.setResourceableId(234l);
    targetResource.setSubPath(UUID.randomUUID().toString());
    targetResource.setBusinessPath("[RepositoryEntry:23647599][CourseNode:934599]");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // load the cloned map another map
    PortfolioStructureMap myClonedMap = epStructureManager.loadPortfolioStructuredMap(user, template, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
    Assert.assertNotNull(myClonedMap);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 12 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.

the class EPStructureManager method createPortfolioStructuredMap.

protected PortfolioStructureMap createPortfolioStructuredMap(PortfolioStructureMap template, Identity identity, String title, String description, OLATResourceable targetOres, String targetSubPath, String targetBusinessPath) {
    EPStructuredMap el = new EPStructuredMap();
    el.setStructuredMapSource((EPStructuredMapTemplate) template);
    el.setStructureElSource(template.getKey());
    if (template != null) {
        copyOrUpdateCollectRestriction(template, el, false);
    }
    EPTargetResource targetResource = el.getTargetResource();
    if (targetOres != null) {
        targetResource.setResourceableId(targetOres.getResourceableId());
        targetResource.setResourceableTypeName(targetOres.getResourceableTypeName());
    }
    if (StringHelper.containsNonWhitespace(targetSubPath)) {
        targetResource.setSubPath(targetSubPath);
    }
    if (StringHelper.containsNonWhitespace(targetBusinessPath)) {
        targetResource.setBusinessPath(targetBusinessPath);
    }
    fillStructureElement(el, title, description);
    // create security group
    EPStructureElementToGroupRelation ownerGroup = createBaseGroup(el, identity);
    Set<EPStructureElementToGroupRelation> relations = new HashSet<>();
    relations.add(ownerGroup);
    el.setGroups(relations);
    return el;
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) EPStructureElementToGroupRelation(org.olat.portfolio.model.structel.EPStructureElementToGroupRelation) HashSet(java.util.HashSet)

Example 13 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.

the class EPFrontendManager method submitMap.

private void submitMap(PortfolioStructureMap map, boolean logActivity, Role by) {
    // add an exception
    if (!(map instanceof EPStructuredMap))
        return;
    EPStructuredMap submittedMap = (EPStructuredMap) map;
    structureManager.submitMap(submittedMap);
    EPTargetResource resource = submittedMap.getTargetResource();
    OLATResourceable courseOres = resource.getOLATResourceable();
    ICourse course = CourseFactory.loadCourse(courseOres);
    AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
    CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
    List<Identity> owners = policyManager.getOwners(submittedMap);
    for (Identity owner : owners) {
        if (courseNode != null) {
            // courseNode might have been deleted meanwhile
            IdentityEnvironment ienv = new IdentityEnvironment();
            ienv.setIdentity(owner);
            UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
            if (logActivity) {
                am.incrementNodeAttempts(courseNode, owner, uce, by);
            } else {
                am.incrementNodeAttemptsInBackground(courseNode, owner, uce);
            }
            RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            assessmentService.updateAssessmentEntry(owner, courseEntry, courseNode.getIdent(), referenceEntry, AssessmentEntryStatus.inReview);
        }
        assessmentNotificationsHandler.markPublisherNews(owner, course.getResourceableId());
        log.audit("Map " + map + " from " + owner.getName() + " has been submitted.");
    }
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) OLATResourceable(org.olat.core.id.OLATResourceable) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 14 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.

the class EPStructureManagerTest method testLoadPortfolioStructuredMaps.

@Test
public void testLoadPortfolioStructuredMaps() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
    // a template
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    // clone the template
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
    ((EPStructuredMap) map).setReturnDate(new Date());
    EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
    targetResource.setResourceableTypeName("CourseModule");
    targetResource.setResourceableId(234l);
    targetResource.setSubPath(UUID.randomUUID().toString());
    targetResource.setBusinessPath("[RepositoryEntry:23647600][CourseNode:934600]");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // load the cloned map another map
    List<PortfolioStructureMap> myCloneAlt = epStructureManager.loadPortfolioStructuredMaps(user, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
    Assert.assertNotNull(myCloneAlt);
    Assert.assertEquals(1, myCloneAlt.size());
    Assert.assertEquals(map, myCloneAlt.get(0));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 15 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource in project openolat by klemens.

the class EPStructureManagerTest method testLoadPortfolioStructuredMap.

@Test
public void testLoadPortfolioStructuredMap() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("EP-tmp-");
    // create a template
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(user, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    // clone the template
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, user, "cloned-map", "cloned-map-from-template", null, null, null);
    ((EPStructuredMap) map).setReturnDate(new Date());
    EPTargetResource targetResource = ((EPStructuredMap) map).getTargetResource();
    targetResource.setResourceableTypeName("CourseModule");
    targetResource.setResourceableId(234l);
    targetResource.setSubPath(UUID.randomUUID().toString());
    targetResource.setBusinessPath("[RepositoryEntry:23647599][CourseNode:934599]");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // load the cloned map another map
    PortfolioStructureMap myClonedMap = epStructureManager.loadPortfolioStructuredMap(user, template, targetResource.getOLATResourceable(), targetResource.getSubPath(), targetResource.getBusinessPath());
    Assert.assertNotNull(myClonedMap);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Aggregations

EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)16 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)16 Date (java.util.Date)8 Identity (org.olat.core.id.Identity)8 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)8 Test (org.junit.Test)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 OLATResourceable (org.olat.core.id.OLATResourceable)4 ICourse (org.olat.course.ICourse)4 CourseNode (org.olat.course.nodes.CourseNode)4 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Component (org.olat.core.gui.components.Component)2 Link (org.olat.core.gui.components.link.Link)2 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)2 AssessmentManager (org.olat.course.assessment.AssessmentManager)2 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)2 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)2 EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)2