Search in sources :

Example 16 with EPStructuredMap

use of org.olat.portfolio.model.structel.EPStructuredMap 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)

Example 17 with EPStructuredMap

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

the class EPFrontendManager method synchronizeStructuredMapToUserCopy.

/**
 * sync map with its former source (template)
 */
public boolean synchronizeStructuredMapToUserCopy(PortfolioStructureMap map) {
    if (map == null)
        return false;
    final EPStructuredMap userMap = (EPStructuredMap) map;
    Boolean synched = coordinator.getSyncer().doInSync(map.getOlatResource(), new SyncerCallback<Boolean>() {

        public Boolean execute() {
            if (userMap.getStructuredMapSource() == null) {
                return Boolean.FALSE;
            }
            // need to reload it, I don't know why
            Long templateKey = userMap.getStructuredMapSource().getKey();
            userMap.setLastSynchedDate(new Date());
            PortfolioStructure template = structureManager.loadPortfolioStructureByKey(templateKey);
            structureManager.syncStructureRecursively(template, userMap, true);
            return Boolean.TRUE;
        }
    });
    return synched.booleanValue();
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Date(java.util.Date)

Example 18 with EPStructuredMap

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

the class EPFrontendManagerTest method testAssignMapTemplateToUser.

@Test
public void testAssignMapTemplateToUser() {
    // create a template
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    // create a repository entry
    RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "template-1", "map-template-1", resource, RepositoryEntry.ACC_OWNERS);
    dbInstance.commitAndCloseSession();
    // create the template owned by ident1
    PortfolioStructureMap templateEl = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
    // first page
    PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(templateEl, "template-page-1", "template-page-1");
    // structure element 1 from page 1
    PortfolioStructure struct11 = epFrontendManager.createAndPersistPortfolioStructureElement(page1, "template-structure-1.1", "template-structure-1.1");
    epStructureManager.addCollectRestriction(struct11, "Forum", "minimum", 2);
    epStructureManager.savePortfolioStructure(struct11);
    // structure element 2 from page 1
    PortfolioStructure struct12 = epFrontendManager.createAndPersistPortfolioStructureElement(page1, "template-structure-1.2", "template-structure-1.2");
    assertNotNull(struct12);
    // first page
    PortfolioStructure page2 = epFrontendManager.createAndPersistPortfolioPage(templateEl, "template-page-2", "template-page-2");
    // structure element 1 from page 2
    PortfolioStructure struct21 = epFrontendManager.createAndPersistPortfolioStructureElement(page2, "template-structure-2.1", "template-structure-2.1");
    epStructureManager.addCollectRestriction(struct21, "bc", "maximum", 4);
    epStructureManager.savePortfolioStructure(struct21);
    // save the template
    dbInstance.commitAndCloseSession();
    // make the copy
    PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, templateEl, addedEntry, null, null, null);
    dbInstance.commitAndCloseSession();
    assertNotNull(map);
    // check the copy
    PortfolioStructure retrievedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    assertNotNull(retrievedMap);
    assertTrue(retrievedMap instanceof EPStructuredMap);
    assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
    assertEquals(templateEl.getKey(), ((EPStructuredMap) retrievedMap).getStructuredMapSource().getKey());
    // check pages of the copied map
    List<PortfolioStructure> pages = epFrontendManager.loadStructureChildren(retrievedMap);
    assertNotNull(pages);
    assertEquals(2, pages.size());
    assertTrue(pages.get(0) instanceof EPPage);
    assertTrue(pages.get(1) instanceof EPPage);
    assertEquals("template-page-1", ((EPStructureElement) pages.get(0)).getTitle());
    assertEquals("template-page-2", ((EPStructureElement) pages.get(1)).getTitle());
    // check root
    assertNotNull(((EPStructureElement) pages.get(0)).getRoot());
    assertEquals(retrievedMap.getKey(), ((EPStructureElement) pages.get(0)).getRoot().getKey());
    // check children of the pages
    List<PortfolioStructure> structs1 = epFrontendManager.loadStructureChildren(pages.get(0));
    assertNotNull(structs1);
    assertEquals(2, structs1.size());
    assertTrue(structs1.get(0) instanceof EPStructureElement);
    assertTrue(structs1.get(1) instanceof EPStructureElement);
    EPStructureElement struct11El = (EPStructureElement) structs1.get(0);
    assertEquals("template-structure-1.1", struct11El.getTitle());
    assertEquals("template-structure-1.2", ((EPStructureElement) structs1.get(1)).getTitle());
    // check root
    assertNotNull(((EPStructureElement) structs1.get(0)).getRoot());
    assertEquals(retrievedMap.getKey(), ((EPStructureElement) structs1.get(0)).getRoot().getKey());
    assertNotNull(((EPStructureElement) structs1.get(1)).getRoot());
    assertEquals(retrievedMap.getKey(), ((EPStructureElement) structs1.get(1)).getRoot().getKey());
    // check collect restriction
    assertNotNull(struct11El.getCollectRestrictions());
    assertEquals("Forum", struct11El.getCollectRestrictions().get(0).getArtefactType());
    assertEquals("minimum", struct11El.getCollectRestrictions().get(0).getRestriction());
    assertEquals(2, struct11El.getCollectRestrictions().get(0).getAmount());
    List<PortfolioStructure> structs2 = epFrontendManager.loadStructureChildren(pages.get(1));
    assertNotNull(structs2);
    assertEquals(1, structs2.size());
    assertTrue(structs2.get(0) instanceof EPStructureElement);
    EPStructureElement struct21El = (EPStructureElement) structs2.get(0);
    assertEquals("template-structure-2.1", struct21El.getTitle());
    // check root
    assertNotNull(struct21El.getRoot());
    assertEquals(retrievedMap.getKey(), struct21El.getRoot().getKey());
    // check collect restriction
    assertNotNull(struct21El.getCollectRestrictions());
    assertEquals("bc", struct21El.getCollectRestrictions().get(0).getArtefactType());
    assertEquals("maximum", struct21El.getCollectRestrictions().get(0).getRestriction());
    assertEquals(4, struct21El.getCollectRestrictions().get(0).getAmount());
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPPage(org.olat.portfolio.model.structel.EPPage) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 19 with EPStructuredMap

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

the class EPChangelogController method updateChangelogDisplay.

/**
 * update the changelog-list according to selected date. this method is
 * invoked on initForm and again when user changes date in dateChooser
 */
private void updateChangelogDisplay() {
    // init the helper;
    String path = getWindowControl().getBusinessControl().getAsString();
    EPNotificationsHelper helper = new EPNotificationsHelper(path, getLocale());
    // get the date from the dateChooser component
    Date compareDate = dateChooser.getDate();
    EPMapShort mapShort = ePFMgr.loadMapShortByResourceId(map.getOlatResource().getResourceableId());
    List<SubscriptionListItem> allItems = new ArrayList<SubscriptionListItem>(0);
    // get subscriptionListItems according to map type
    if (map instanceof EPDefaultMap || map instanceof EPStructuredMapTemplate) {
        allItems = helper.getAllSubscrItemsDefault(compareDate, mapShort);
    } else if (map instanceof EPStructuredMap) {
        allItems = helper.getAllSubscrItemsStructured(compareDate, mapShort);
    }
    List<SubscriptionItemBundle> bundles = getItemBundlesForSubscriptionItems(allItems);
    flc.contextPut("subscriptionItems", bundles);
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) EPNotificationsHelper(org.olat.portfolio.manager.EPNotificationsHelper) ArrayList(java.util.ArrayList) EPDefaultMap(org.olat.portfolio.model.structel.EPDefaultMap) EPMapShort(org.olat.portfolio.model.structel.EPMapShort) Date(java.util.Date)

Example 20 with EPStructuredMap

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

the class PortfolioCourseNodeRunController method updateSelectedMapUI.

private void updateSelectedMapUI(UserRequest ureq) {
    String copyTitle = StringHelper.escapeHtml(copyMap.getTitle());
    selectMapLink.getComponent().setCustomDisplayText(copyTitle);
    // show results, when already handed in
    EPStructuredMap structuredMap = (EPStructuredMap) copyMap;
    updateCopyDate(structuredMap.getCopyDate());
    updateAssessmentInfos(ureq, structuredMap.getReturnDate());
    updateDeadlineText(structuredMap.getDeadLine());
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap)

Aggregations

EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)34 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)18 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)16 Date (java.util.Date)14 RepositoryEntry (org.olat.repository.RepositoryEntry)12 Test (org.junit.Test)10 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)10 Identity (org.olat.core.id.Identity)8 ArrayList (java.util.ArrayList)6 OLATResource (org.olat.resource.OLATResource)6 OLATResourceable (org.olat.core.id.OLATResourceable)4 ICourse (org.olat.course.ICourse)4 CourseNode (org.olat.course.nodes.CourseNode)4 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)4 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)4 HashSet (java.util.HashSet)2 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)2 Component (org.olat.core.gui.components.Component)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2