Search in sources :

Example 81 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class STCourseNode method createNodeRunConstructionResult.

/**
 * @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.course.run.userview.UserCourseEnvironment,
 *      org.olat.course.run.userview.NodeEvaluation)
 */
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    Controller cont;
    String displayType = getModuleConfiguration().getStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE);
    String relPath = STCourseNodeEditController.getFileName(getModuleConfiguration());
    if (relPath != null && displayType.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
        // we want a user chosen overview, so display the chosen file from the
        // material folder, otherwise display the normal overview
        // reuse the Run controller from the "Single Page" building block, since
        // we need to do exactly the same task
        Boolean allowRelativeLinks = getModuleConfiguration().getBooleanEntry(STCourseNodeEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
        if (allowRelativeLinks == null) {
            allowRelativeLinks = Boolean.FALSE;
        }
        DeliveryOptions deliveryOptions = (DeliveryOptions) getModuleConfiguration().get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
        SinglePageController spCtr = new SinglePageController(ureq, wControl, userCourseEnv.getCourseEnvironment().getCourseFolderContainer(), relPath, allowRelativeLinks.booleanValue(), null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
        // check if user is allowed to edit the page in the run view
        CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
        boolean hasEditRights = (cgm.isIdentityCourseAdministrator(ureq.getIdentity()) || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_COURSEEDITOR)) || (getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_COACH_EDIT, false) && cgm.isIdentityCourseCoach(ureq.getIdentity()));
        if (hasEditRights) {
            spCtr.allowPageEditing();
            // set the link tree model to internal for the HTML editor
            CustomLinkTreeModel linkTreeModel = new CourseInternalLinkTreeModel(userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode());
            spCtr.setInternalLinkTreeModel(linkTreeModel);
        }
        spCtr.addLoggingResourceable(LoggingResourceable.wrap(this));
        // create clone wrapper layout, allow popping into second window
        CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {

            @Override
            public ControllerCreator createLayoutControllerCreator(final UserRequest uureq, final ControllerCreator contentControllerCreator) {
                return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {

                    @Override
                    public Controller createController(UserRequest lureq, WindowControl lwControl) {
                        // wrap in column layout, popup window needs a layout controller
                        Controller ctr = contentControllerCreator.createController(lureq, lwControl);
                        LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
                        layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), userCourseEnv.getCourseEnvironment()));
                        Controller wrappedCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, STCourseNode.this, ICON_CSS_CLASS);
                        layoutCtr.addDisposableChildController(wrappedCtrl);
                        return layoutCtr;
                    }
                });
            }
        };
        Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, spCtr, this, ICON_CSS_CLASS);
        if (wrappedCtrl instanceof CloneableController) {
            cont = new CloneController(ureq, wControl, (CloneableController) wrappedCtrl, clccc);
        } else {
            throw new AssertException("Need to be a cloneable");
        }
    } else {
        // evaluate the score accounting for this node. this uses the score accountings local
        // cache hash map to reduce unnecessary calculations
        ScoreEvaluation se = userCourseEnv.getScoreAccounting().evalCourseNode(this);
        cont = TitledWrapperHelper.getWrapper(ureq, wControl, new STCourseNodeRunController(ureq, wControl, userCourseEnv, this, se, ne), this, ICON_CSS_CLASS);
    }
    // displayed in the ST-Runcontroller
    return new NodeRunConstructionResult(cont);
}
Also used : STCourseNodeRunController(org.olat.course.nodes.st.STCourseNodeRunController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) SPPeekviewController(org.olat.course.nodes.sp.SPPeekviewController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) NodeEditController(org.olat.course.editor.NodeEditController) STCourseNodeRunController(org.olat.course.nodes.st.STCourseNodeRunController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) AssessmentCourseNodeController(org.olat.course.assessment.ui.tool.AssessmentCourseNodeController) SPEditController(org.olat.course.nodes.sp.SPEditController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) STCourseNodeEditController(org.olat.course.nodes.st.STCourseNodeEditController) Controller(org.olat.core.gui.control.Controller) STPeekViewController(org.olat.course.nodes.st.STPeekViewController) STIdentityListCourseNodeController(org.olat.course.nodes.st.STIdentityListCourseNodeController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) WindowControl(org.olat.core.gui.control.WindowControl) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CustomLinkTreeModel(org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel) CloneController(org.olat.core.gui.control.generic.clone.CloneController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CloneLayoutControllerCreatorCallback(org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest) CourseInternalLinkTreeModel(org.olat.course.tree.CourseInternalLinkTreeModel)

Example 82 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class PaypalAdminController method doOpenMasterAccountSettings.

private void doOpenMasterAccountSettings(UserRequest ureq) {
    if (accountController == null) {
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("transactions", 0l);
        WindowControl bwControl = addToHistory(ureq, ores, null);
        accountController = new PaypalMasterAccountController(ureq, bwControl);
        listenTo(accountController);
    } else {
        addToHistory(ureq, accountController);
    }
    mainVC.put("segmentCmp", accountController.getInitialComponent());
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("configuration", 0l);
    addToHistory(ureq, ores, null);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) WindowControl(org.olat.core.gui.control.WindowControl)

Example 83 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class OrdersAdminController method doSelectOrder.

protected void doSelectOrder(UserRequest ureq, OrderTableItem order) {
    removeAsListenerAndDispose(detailController);
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Order.class, order.getOrderKey());
    WindowControl bwControl = addToHistory(ureq, ores, null);
    detailController = new OrderDetailController(ureq, bwControl, order.getOrderKey());
    listenTo(detailController);
    if (stackPanel == null) {
        mainPanel.setContent(detailController.getInitialComponent());
    } else {
        detailController.hideBackLink();
        stackPanel.pushController(order.getOrderNr(), detailController);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) WindowControl(org.olat.core.gui.control.WindowControl)

Example 84 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class RepositoryManagerTest method lookupRepositoryEntryKey.

@Test
public void lookupRepositoryEntryKey() {
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    dbInstance.commitAndCloseSession();
    // check with a return value
    Long repoKey1 = repositoryManager.lookupRepositoryEntryKey(re.getOlatResource(), false);
    Assert.assertNotNull(repoKey1);
    Assert.assertEquals(re.getKey(), repoKey1);
    // check with a return value
    Long repoKey2 = repositoryManager.lookupRepositoryEntryKey(re.getOlatResource(), true);
    Assert.assertNotNull(repoKey2);
    Assert.assertEquals(re.getKey(), repoKey2);
    // check with a return value
    OLATResourceable dummy = OresHelper.createOLATResourceableInstance(UUID.randomUUID().toString(), 0l);
    Long repoKey3 = repositoryManager.lookupRepositoryEntryKey(dummy, false);
    Assert.assertNull(repoKey3);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) Test(org.junit.Test)

Example 85 with OLATResourceable

use of org.olat.core.id.OLATResourceable in project OpenOLAT by OpenOLAT.

the class RepositoryManagerTest method createRepositoryEntry.

private RepositoryEntry createRepositoryEntry(final String type, Identity owner, long i) {
    OLATResourceable resourceable = OresHelper.createOLATResourceableInstance(type, new Long(i));
    OLATResource r = resourceManager.createOLATResourceInstance(resourceable);
    dbInstance.saveObject(r);
    // now make a repository entry for this course
    final RepositoryEntry re = repositoryService.create(owner, null, "Lernen mit OLAT " + i, "JunitTest_RepositoryEntry_" + i, "yo man description bla bla + i", r, RepositoryEntry.ACC_OWNERS_AUTHORS);
    return re;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OLATResource(org.olat.resource.OLATResource)

Aggregations

OLATResourceable (org.olat.core.id.OLATResourceable)924 WindowControl (org.olat.core.gui.control.WindowControl)304 Test (org.junit.Test)158 Identity (org.olat.core.id.Identity)154 RepositoryEntry (org.olat.repository.RepositoryEntry)130 ContextEntry (org.olat.core.id.context.ContextEntry)82 ArrayList (java.util.ArrayList)68 OLATResource (org.olat.resource.OLATResource)60 Controller (org.olat.core.gui.control.Controller)48 Date (java.util.Date)46 AssertException (org.olat.core.logging.AssertException)32 StateSite (org.olat.core.id.context.StateSite)30 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)30 ICourse (org.olat.course.ICourse)30 CourseNode (org.olat.course.nodes.CourseNode)28 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)28 BusinessControl (org.olat.core.id.context.BusinessControl)24 BusinessGroup (org.olat.group.BusinessGroup)24 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)22 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)22