Search in sources :

Example 11 with EPStructuredMap

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

the class EPStructureManagerTest method testUseStructureMapTemplate.

@Test
public void testUseStructureMapTemplate() {
    // save parent and 20 children
    PortfolioStructureMap template = epStructureManager.createPortfolioMapTemplate(ident1, "paged-parent-structure-el", "parent-structure-element");
    epStructureManager.savePortfolioStructure(template);
    dbInstance.commitAndCloseSession();
    PortfolioStructureMap map = epFrontendManager.createAndPersistPortfolioStructuredMap(template, ident1, "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("3894580");
    targetResource.setBusinessPath("[RepositoryEntry:23647598][CourseNode:934598]");
    epStructureManager.savePortfolioStructure(map);
    dbInstance.commitAndCloseSession();
    // test
    PortfolioStructureMap retrievedMap = (PortfolioStructureMap) epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    assertNotNull(retrievedMap);
    assertNotNull(((EPStructuredMap) retrievedMap).getReturnDate());
    assertNotNull(((EPStructuredMap) retrievedMap).getStructuredMapSource());
    assertNotNull(((EPStructuredMap) retrievedMap).getTargetResource());
    EPTargetResource retriviedTargetResource = ((EPStructuredMap) retrievedMap).getTargetResource();
    assertEquals("CourseModule", retriviedTargetResource.getResourceableTypeName());
    assertEquals(new Long(234l), retriviedTargetResource.getResourceableId());
    assertEquals("3894580", retriviedTargetResource.getSubPath());
    assertEquals("[RepositoryEntry:23647598][CourseNode:934598]", retriviedTargetResource.getBusinessPath());
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) Date(java.util.Date) Test(org.junit.Test)

Example 12 with EPStructuredMap

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

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 13 with EPStructuredMap

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

the class EPMapViewController method preCheckMapSubmit.

private boolean preCheckMapSubmit() {
    EPStructuredMap submittedMap = (EPStructuredMap) map;
    try {
        EPTargetResource resource = submittedMap.getTargetResource();
        OLATResourceable courseOres = resource.getOLATResourceable();
        ICourse course = CourseFactory.loadCourse(courseOres);
        CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
        if (courseNode == null)
            return false;
    } catch (Exception e) {
        return false;
    }
    return true;
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) OLATResourceable(org.olat.core.id.OLATResourceable) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode)

Example 14 with EPStructuredMap

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

the class EPMapViewController method initForm.

protected void initForm(UserRequest ureq) {
    Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
    if (ownerIdentity != null) {
        DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
        mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
    }
    mainVc.contextPut("map", map);
    mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
    mainVc.remove(mainVc.getComponent("map.editButton"));
    if (secCallback.canEditStructure()) {
        editButton = LinkFactory.createButton("map.editButton", mainVc, this);
        editButton.setElementCssClass("o_sel_ep_edit_map");
        editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
        if (editMode == EditMode.view) {
            editButton.setCustomDisplayText(translate("map.editButton.on"));
        } else {
            editButton.setCustomDisplayText(translate("map.editButton.off"));
        }
    }
    if (back) {
        backLink = LinkFactory.createLinkBack(mainVc, this);
    }
    mainVc.remove(mainVc.getComponent("map.submit.assess"));
    if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
    }
    if (map instanceof EPStructuredMap) {
        EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
        RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
        if (repoEntry != null) {
            mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
            String url = Settings.getServerContextPathURI();
            url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
            mainVc.contextPut("courseLink", url);
        }
    }
    mainVc.remove(mainVc.getComponent("addButton"));
    if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
        EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
        if (secCallback.canAddPage()) {
            addButton.setShowLink(EPAddElementsController.ADD_PAGE);
        }
        mainVc.put("addButton", addButton.getInitialComponent());
        listenTo(addButton);
    }
    mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
    List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
    if (pageList != null && pageList.size() != 0) {
        // prepare to paint pages also
        removeAsListenerAndDispose(pageCtrl);
        pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
        mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
        listenTo(pageCtrl);
    } else if (mainVc.getComponent("pagesCtrl") != null) {
        mainVc.remove(mainVc.getComponent("pagesCtrl"));
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 15 with EPStructuredMap

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

the class EPStructureManager method copyStructureRecursively.

protected void copyStructureRecursively(PortfolioStructure source, PortfolioStructure target, boolean withArtefacts) {
    // all changes are overwritten
    EPStructureElement targetEl = (EPStructureElement) target;
    if (targetEl instanceof EPStructuredMap) {
        ((EPStructuredMap) targetEl).setCopyDate(new Date());
    }
    // update the source
    dbInstance.updateObject(source);
    // reconnect to the session
    EPStructureElement sourceEl = (EPStructureElement) source;
    targetEl.setStyle(sourceEl.getStyle());
    copyEPStructureElementRecursively(sourceEl, targetEl, withArtefacts, true);
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) Date(java.util.Date)

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