Search in sources :

Example 6 with EPTargetResource

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

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 7 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource 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 8 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource 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 9 with EPTargetResource

use of org.olat.portfolio.model.structel.EPTargetResource 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 10 with EPTargetResource

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

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)

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