Search in sources :

Example 6 with EPStructuredMap

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

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

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

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

the class PortfolioResultDetailsController method initMapsForm.

protected void initMapsForm(FormItemContainer formLayout) {
    Formatter formatter = Formatter.getInstance(getLocale());
    int count = 0;
    for (PortfolioStructureMap map : maps) {
        MapElements mapElements = new MapElements();
        if (map instanceof EPStructuredMap) {
            EPStructuredMap structuredMap = (EPStructuredMap) map;
            if (maps.size() > 1 || !structuredMap.getStructuredMapSource().equals(templateMap)) {
                String templateTitle = structuredMap.getStructuredMapSource().getTitle();
                uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
            }
            String copyDate = "";
            if (structuredMap.getCopyDate() != null) {
                copyDate = formatter.formatDateAndTime(structuredMap.getCopyDate());
            }
            uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
            String returnDate = "";
            if (structuredMap.getReturnDate() != null) {
                returnDate = formatter.formatDateAndTime(structuredMap.getReturnDate());
            }
            uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
            String deadLine = "";
            if (structuredMap.getDeadLine() != null) {
                deadLine = formatter.formatDateAndTime(structuredMap.getDeadLine());
            }
            mapElements.deadlineEl = uifactory.addStaticTextElement("map.deadline." + count, "map.deadline", deadLine, formLayout);
        }
        FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
        buttonsCont.setRootForm(mainForm);
        formLayout.add(buttonsCont);
        if (map instanceof EPStructuredMap) {
            mapElements.changeDeadlineLink = uifactory.addFormLink("map.deadline.change." + count, "map.deadline.change", null, buttonsCont, Link.BUTTON);
            mapElements.changeDeadlineLink.setUserObject(map);
        }
        mapElements.openMapLink = uifactory.addFormLink("open.map." + count, "open.map", null, buttonsCont, Link.BUTTON);
        mapElements.openMapLink.setUserObject(map);
        count++;
        if (count != maps.size()) {
            uifactory.addSpacerElement("spacer-" + count, formLayout, false);
        }
        mapToElements.put(map, mapElements);
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 9 with EPStructuredMap

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

the class PortfolioResultDetailsController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if (cmd != null && cmd.startsWith("map.deadline.change")) {
            if (deadlineCalloutCtr == null) {
                EPStructuredMap map = (EPStructuredMap) link.getUserObject();
                popupDeadlineBox(ureq, map);
            } else {
                // close on second click
                closeDeadlineBox();
            }
        } else if (link.getName().startsWith("open.map")) {
            PortfolioStructureMap map = (PortfolioStructureMap) link.getUserObject();
            doOpenMap(ureq, map);
        } else if (link.getName().startsWith("open.binder")) {
            Binder map = (Binder) link.getUserObject();
            doOpenMap(ureq, map);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 10 with EPStructuredMap

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

the class EPFrontendManagerTest method testSyncMapTemplateToUserMap.

@Test
public void testSyncMapTemplateToUserMap() {
    // create a template
    OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
    // create a repository entry
    RepositoryEntry addedEntry = repositoryService.create(ident1, null, "-", "Template in user", "Template in use", resource, RepositoryEntry.ACC_OWNERS);
    // create the template owned by ident1
    PortfolioStructureMap templateEl = epStructureManager.createAndPersistPortfolioMapTemplateFromEntry(ident1, addedEntry);
    // create five pages
    List<PortfolioStructure> pageRefs = new ArrayList<PortfolioStructure>();
    List<PortfolioStructure> elementRefs = new ArrayList<PortfolioStructure>();
    for (int i = 0; i < 5; i++) {
        PortfolioStructure page = epFrontendManager.createAndPersistPortfolioPage(templateEl, "sync-template-page-" + i, "sync-template-page-" + i);
        pageRefs.add(page);
        for (int j = 0; j < 5; j++) {
            PortfolioStructure struct = epFrontendManager.createAndPersistPortfolioStructureElement(page, "template-structure-" + i + "." + j, "template-structure-" + i + "." + j);
            epStructureManager.addCollectRestriction(struct, "Forum", "minimum", 2);
            epStructureManager.savePortfolioStructure(struct);
            elementRefs.add(struct);
        }
    }
    // save the template
    dbInstance.commitAndCloseSession();
    // end create template
    // ////////////////////
    // make the copy
    PortfolioStructureMap map = epFrontendManager.assignStructuredMapToUser(ident2, templateEl, addedEntry, null, null, null);
    dbInstance.commitAndCloseSession();
    assertNotNull(map);
    // ////////////////////////////////
    // shuffle the pages and delete one
    PortfolioStructure retrievedTemplateEl = epFrontendManager.loadPortfolioStructureByKey(templateEl.getKey());
    List<PortfolioStructure> pages = epFrontendManager.loadStructureChildren(retrievedTemplateEl);
    epStructureManager.moveUp(retrievedTemplateEl, pages.get(1));
    epStructureManager.moveDown(retrievedTemplateEl, pages.get(2));
    epStructureManager.removeStructure(retrievedTemplateEl, pages.get(3));
    epStructureManager.savePortfolioStructure(retrievedTemplateEl);
    // shuffle a page
    List<PortfolioStructure> page1Children = epFrontendManager.loadStructureChildren(pages.get(1));
    epStructureManager.moveUp(pages.get(1), page1Children.get(3));
    epStructureManager.moveUp(pages.get(1), page1Children.get(2));
    epStructureManager.moveUp(pages.get(1), page1Children.get(4));
    // and add an element and sub-elements
    PortfolioStructure newStruct = epFrontendManager.createAndPersistPortfolioStructureElement(pages.get(1), "new-template-structure-1.6", "template-structure-1.6");
    epStructureManager.addCollectRestriction(pages.get(1), "Forum", "minimum", 2);
    epStructureManager.savePortfolioStructure(newStruct);
    epStructureManager.savePortfolioStructure(pages.get(1));
    for (int k = 0; k < 5; k++) {
        PortfolioStructure struct = epFrontendManager.createAndPersistPortfolioStructureElement(newStruct, "new-template-structure-2." + k, "template-structure-2." + k);
        epStructureManager.addCollectRestriction(struct, "bc", "minimum", 2);
        epStructureManager.savePortfolioStructure(struct);
        elementRefs.add(struct);
    }
    dbInstance.commitAndCloseSession();
    // end shuffle the pages
    // ////////////////////////////////
    // //////////////////
    // check the template
    PortfolioStructure retrievedTemplate2El = epFrontendManager.loadPortfolioStructureByKey(templateEl.getKey());
    assertNotNull(retrievedTemplate2El);
    assertTrue(retrievedTemplate2El instanceof EPStructuredMapTemplate);
    List<PortfolioStructure> retrievedPages2 = epFrontendManager.loadStructureChildren(retrievedTemplate2El);
    assertEquals(4, retrievedPages2.size());
    assertEquals(4, ((EPStructuredMapTemplate) retrievedTemplate2El).getInternalChildren().size());
    // check the shuffled pages
    assertEquals(pageRefs.get(1).getKey(), retrievedPages2.get(0).getKey());
    assertEquals(pageRefs.get(0).getKey(), retrievedPages2.get(1).getKey());
    assertEquals(pageRefs.get(2).getKey(), retrievedPages2.get(2).getKey());
    assertEquals(pageRefs.get(4).getKey(), retrievedPages2.get(3).getKey());
    // check added element
    List<PortfolioStructure> retrievedChildren2 = epFrontendManager.loadStructureChildren(retrievedPages2.get(0));
    assertEquals(6, retrievedChildren2.size());
    dbInstance.commitAndCloseSession();
    // check the template
    // //////////////////
    // sync the map
    epFrontendManager.synchronizeStructuredMapToUserCopy(map);
    dbInstance.commitAndCloseSession();
    // ///////////////
    // check the sync
    PortfolioStructure synchedMap = epFrontendManager.loadPortfolioStructureByKey(map.getKey());
    assertNotNull(synchedMap);
    assertTrue(synchedMap instanceof EPStructuredMap);
    List<PortfolioStructure> synchedPages = epFrontendManager.loadStructureChildren(synchedMap);
    assertNotNull(synchedPages);
    assertEquals(4, synchedPages.size());
    assertEquals(((EPStructureElement) pageRefs.get(1)).getTitle(), ((EPStructureElement) synchedPages.get(0)).getTitle());
    assertEquals(((EPStructureElement) pageRefs.get(0)).getTitle(), ((EPStructureElement) synchedPages.get(1)).getTitle());
    assertEquals(((EPStructureElement) pageRefs.get(2)).getTitle(), ((EPStructureElement) synchedPages.get(2)).getTitle());
    assertEquals(((EPStructureElement) pageRefs.get(4)).getTitle(), ((EPStructureElement) synchedPages.get(3)).getTitle());
    // check synched key
    assertEquals(((EPStructureElement) pageRefs.get(1)).getKey(), ((EPStructureElement) synchedPages.get(0)).getStructureElSource());
    assertEquals(((EPStructureElement) pageRefs.get(0)).getKey(), ((EPStructureElement) synchedPages.get(1)).getStructureElSource());
    assertEquals(((EPStructureElement) pageRefs.get(2)).getKey(), ((EPStructureElement) synchedPages.get(2)).getStructureElSource());
    assertEquals(((EPStructureElement) pageRefs.get(4)).getKey(), ((EPStructureElement) synchedPages.get(3)).getStructureElSource());
    // check the new elements
    List<PortfolioStructure> retrievedPage1Children = epFrontendManager.loadStructureChildren(synchedPages.get(0));
    assertEquals(6, retrievedPage1Children.size());
    PortfolioStructure retrievedNewStruct = retrievedPage1Children.get(5);
    assertEquals("new-template-structure-1.6", ((EPStructureElement) retrievedNewStruct).getTitle());
    List<PortfolioStructure> retrievedNewStructChildren = epFrontendManager.loadStructureChildren(retrievedNewStruct);
    assertNotNull(retrievedNewStructChildren);
    assertEquals(5, retrievedNewStructChildren.size());
    for (int k = 0; k < 5; k++) {
        assertEquals("new-template-structure-2." + k, ((EPStructureElement) retrievedNewStructChildren.get(k)).getTitle());
    }
// end check the sync
// //////////////////
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

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