Search in sources :

Example 16 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.

the class SPCourseNode method updateModuleConfigDefaults.

/**
 * Update the module configuration to have all mandatory configuration flags
 * set to usefull default values
 *
 * @param isNewNode true: an initial configuration is set; false: upgrading
 *          from previous node configuration version, set default to maintain
 *          previous behaviour
 */
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        // use defaults for new course building blocks
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, false);
        config.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, false);
        DeliveryOptions defaultOptions = DeliveryOptions.defaultWithGlossary();
        config.set(SPEditController.CONFIG_KEY_DELIVERYOPTIONS, defaultOptions);
        // new since config version 3
        config.setConfigurationVersion(4);
    } else {
        config.remove(NodeEditController.CONFIG_INTEGRATION);
        int version = config.getConfigurationVersion();
        if (version < 2) {
            // use values accoring to previous functionality
            config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
            config.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, Boolean.FALSE.booleanValue());
            config.setConfigurationVersion(2);
        }
        if (version < 4) {
            if (config.get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS) == null) {
                DeliveryOptions defaultOptions = DeliveryOptions.defaultWithGlossary();
                config.set(SPEditController.CONFIG_KEY_DELIVERYOPTIONS, defaultOptions);
            }
            config.setConfigurationVersion(4);
        }
    // there was a version 3 but all keys new in this version have been removed
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 17 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.

the class ScormCourseNode method updateModuleConfigDefaults.

/**
 * Update the module configuration to have all mandatory configuration flags
 * set to usefull default values
 *
 * @param isNewNode true: an initial configuration is set; false: upgrading
 *          from previous node configuration version, set default to maintain
 *          previous behaviour
 */
@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        // use defaults for new course building blocks
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
        config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
        config.setBooleanEntry(ScormEditController.CONFIG_SHOWNAVBUTTONS, Boolean.TRUE.booleanValue());
        config.set(CONFIG_HEIGHT, "680");
        config.set(NodeEditController.CONFIG_CONTENT_ENCODING, NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
        config.set(NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
        // fxdiff FXOLAT-116: SCORM improvements
        config.setBooleanEntry(ScormEditController.CONFIG_FULLWINDOW, true);
        config.setBooleanEntry(ScormEditController.CONFIG_CLOSE_ON_FINISH, false);
        config.setBooleanEntry(ScormEditController.CONFIG_ADVANCESCORE, true);
        config.setBooleanEntry(ScormEditController.CONFIG_ATTEMPTSDEPENDONSCORE, false);
        config.setIntValue(ScormEditController.CONFIG_MAXATTEMPTS, 0);
        config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
        DeliveryOptions deliveryOptions = new DeliveryOptions();
        deliveryOptions.setInherit(Boolean.TRUE);
        config.set(ScormEditController.CONFIG_DELIVERY_OPTIONS, deliveryOptions);
    } else {
        int version = config.getConfigurationVersion();
        if (version < CURRENT_CONFIG_VERSION) {
            // Loaded config is older than current config version => migrate
            if (version == 1) {
                version = 2;
                // remove old config from previous versions
                config.remove(NodeEditController.CONFIG_INTEGRATION);
                // add new parameter 'shownavbuttons' and 'height'
                config.setBooleanEntry(ScormEditController.CONFIG_SHOWNAVBUTTONS, Boolean.TRUE.booleanValue());
                config.set(CONFIG_HEIGHT, CONFIG_HEIGHT_AUTO);
            }
            if (version == 2) {
                version = 3;
                config.set(NodeEditController.CONFIG_CONTENT_ENCODING, NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
                config.set(NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
            }
            if (version == 3) {
                version = 4;
                // fxdiff FXOLAT-116: SCORM improvements
                config.setBooleanEntry(ScormEditController.CONFIG_FULLWINDOW, false);
                config.setBooleanEntry(ScormEditController.CONFIG_CLOSE_ON_FINISH, false);
                config.setBooleanEntry(ScormEditController.CONFIG_ADVANCESCORE, false);
                config.setBooleanEntry(ScormEditController.CONFIG_ATTEMPTSDEPENDONSCORE, false);
                config.setIntValue(ScormEditController.CONFIG_MAXATTEMPTS, 0);
            }
            if (version == 4) {
                boolean rawContent = config.getBooleanSafe(CONFIG_RAW_CONTENT, true);
                String height = (String) config.get(CONFIG_HEIGHT);
                String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
                String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
                ScormPackageConfig reConfig = null;
                DeliveryOptions nodeDeliveryOptions = new DeliveryOptions();
                RepositoryEntry re = getReferencedRepositoryEntry();
                if (re != null) {
                    reConfig = ScormMainManager.getInstance().getScormPackageConfig(re.getOlatResource());
                    // move the settings from the node to the repo
                    if (reConfig == null || reConfig.getDeliveryOptions() == null) {
                        if (reConfig == null) {
                            reConfig = new ScormPackageConfig();
                        }
                        reConfig.setDeliveryOptions(new DeliveryOptions());
                        nodeDeliveryOptions.setInherit(Boolean.TRUE);
                        if (rawContent) {
                            nodeDeliveryOptions.setStandardMode(Boolean.TRUE);
                        } else {
                            nodeDeliveryOptions.setStandardMode(Boolean.FALSE);
                            reConfig.getDeliveryOptions().setOpenolatCss(Boolean.TRUE);
                            reConfig.getDeliveryOptions().setPrototypeEnabled(Boolean.TRUE);
                            reConfig.getDeliveryOptions().setHeight(height);
                        }
                        reConfig.getDeliveryOptions().setContentEncoding(contentEncoding);
                        reConfig.getDeliveryOptions().setJavascriptEncoding(jsEncoding);
                        ScormMainManager.getInstance().setScormPackageConfig(re.getOlatResource(), reConfig);
                    } else {
                        DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
                        boolean reRawContent = repoDeliveryOptions.getStandardMode() == null ? true : repoDeliveryOptions.getStandardMode().booleanValue();
                        if (((height == null && repoDeliveryOptions.getHeight() == null) || (height != null && height.equals(repoDeliveryOptions.getHeight()))) && ((contentEncoding == null && repoDeliveryOptions.getContentEncoding() == null) || (contentEncoding != null && contentEncoding.equals(repoDeliveryOptions.getContentEncoding()))) && ((jsEncoding == null && repoDeliveryOptions.getJavascriptEncoding() == null) || (jsEncoding != null && jsEncoding.equals(repoDeliveryOptions.getJavascriptEncoding()))) && rawContent == reRawContent) {
                            nodeDeliveryOptions.setInherit(Boolean.TRUE);
                        } else {
                            nodeDeliveryOptions.setInherit(Boolean.FALSE);
                            nodeDeliveryOptions.setContentEncoding(contentEncoding);
                            nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
                            nodeDeliveryOptions.setHeight(height);
                            if (rawContent) {
                                nodeDeliveryOptions.setStandardMode(Boolean.TRUE);
                            } else {
                                nodeDeliveryOptions.setStandardMode(Boolean.FALSE);
                                nodeDeliveryOptions.setOpenolatCss(Boolean.TRUE);
                                nodeDeliveryOptions.setPrototypeEnabled(Boolean.TRUE);
                                nodeDeliveryOptions.setHeight(height);
                            }
                        }
                    }
                }
                config.set(ScormEditController.CONFIG_DELIVERY_OPTIONS, nodeDeliveryOptions);
                version = 5;
            }
            // version is now set to current version
            config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
        }
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 18 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.

the class CPCourseNode method updateModuleConfigDefaults.

/**
 * Update the module configuration to have all mandatory configuration flags
 * set to usefull default values
 *
 * @param isNewNode true: an initial configuration is set; false: upgrading
 *          from previous node configuration version, set default to maintain
 *          previous behaviour
 */
@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    int CURRENTVERSION = 7;
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        // use defaults for new course building blocks
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
        config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
        // how to render files (include jquery etc)
        DeliveryOptions nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
        nodeDeliveryOptions.setInherit(Boolean.TRUE);
        config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
        config.setConfigurationVersion(CURRENTVERSION);
    } else {
        config.remove(NodeEditController.CONFIG_INTEGRATION);
        if (config.getConfigurationVersion() < 2) {
            // update new configuration options using default values for existing
            // nodes
            config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
            Boolean componentMenu = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
            if (componentMenu == null) {
                config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
            }
            config.setConfigurationVersion(2);
        }
        if (config.getConfigurationVersion() < 3) {
            config.set(NodeEditController.CONFIG_CONTENT_ENCODING, NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
            config.set(NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
            config.setConfigurationVersion(3);
        }
        // save it as version 6
        if (config.getConfigurationVersion() < 7) {
            String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
            if (contentEncoding != null && contentEncoding.equals("auto")) {
                // new style for auto
                contentEncoding = null;
            }
            String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
            if (jsEncoding != null && jsEncoding.equals("auto")) {
                // new style for auto
                jsEncoding = null;
            }
            CPPackageConfig reConfig = null;
            DeliveryOptions nodeDeliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
            if (nodeDeliveryOptions == null) {
                // Update missing delivery options now, inherit from repo by default
                nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
                nodeDeliveryOptions.setInherit(Boolean.TRUE);
                RepositoryEntry re = getReferencedRepositoryEntry();
                // Check if delivery options are set for repo entry, if not create default
                if (re != null) {
                    reConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
                    if (reConfig == null) {
                        reConfig = new CPPackageConfig();
                    }
                    DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
                    if (repoDeliveryOptions == null) {
                        // migrate existing config back to repo entry using the default as a base
                        repoDeliveryOptions = DeliveryOptions.defaultWithGlossary();
                        reConfig.setDeliveryOptions(repoDeliveryOptions);
                        repoDeliveryOptions.setContentEncoding(contentEncoding);
                        repoDeliveryOptions.setJavascriptEncoding(jsEncoding);
                        CPManager.getInstance().setCPPackageConfig(re.getOlatResource(), reConfig);
                    } else {
                        // see if we have any different settings than the repo. if so, don't use inherit mode
                        if (contentEncoding != repoDeliveryOptions.getContentEncoding() || jsEncoding != repoDeliveryOptions.getJavascriptEncoding()) {
                            nodeDeliveryOptions.setInherit(Boolean.FALSE);
                            nodeDeliveryOptions.setContentEncoding(contentEncoding);
                            nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
                        }
                    }
                }
                // remove old config parameters
                config.remove(NodeEditController.CONFIG_CONTENT_ENCODING);
                config.remove(NodeEditController.CONFIG_JS_ENCODING);
                // replace with new delivery options
                config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
            }
            config.setConfigurationVersion(7);
        }
    // else node is up-to-date - nothing to do
    }
    if (config.getConfigurationVersion() != CURRENTVERSION) {
        OLog logger = Tracing.createLoggerFor(CPCourseNode.class);
        logger.error("CP course node version not updated to lastest version::" + CURRENTVERSION + ", was::" + config.getConfigurationVersion() + ". Check the code, programming error.");
    }
}
Also used : OLog(org.olat.core.logging.OLog) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 19 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class ScormRuntimeController method doLayout.

private void doLayout(UserRequest ureq) {
    RepositoryEntry entry = getRepositoryEntry();
    ScormPackageConfig scormConfig = ScormMainManager.getInstance().getScormPackageConfig(entry.getOlatResource());
    DeliveryOptions config = scormConfig == null ? null : scormConfig.getDeliveryOptions();
    final OLATResource resource = entry.getOlatResource();
    WindowControl bwControl = getSubWindowControl("Layout");
    final DeliveryOptionsConfigurationController deliveryOptionsCtrl = new DeliveryOptionsConfigurationController(ureq, addToHistory(ureq, bwControl), config, "Knowledge Transfer#_scorm_layout");
    deliveryOptionsCtrl.addControllerListener(new ControllerEventListener() {

        @Override
        public void dispatchEvent(UserRequest uureq, Controller source, Event event) {
            if (source == deliveryOptionsCtrl && (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT)) {
                DeliveryOptions newConfig = deliveryOptionsCtrl.getDeliveryOptions();
                ScormPackageConfig sConfig = ScormMainManager.getInstance().getScormPackageConfig(resource);
                if (sConfig == null) {
                    sConfig = new ScormPackageConfig();
                }
                sConfig.setDeliveryOptions(newConfig);
                ScormMainManager.getInstance().setScormPackageConfig(resource, sConfig);
            }
        }
    });
    pushController(ureq, translate("tab.layout"), deliveryOptionsCtrl);
    setActiveTool(deliveryOptionsLink);
}
Also used : ControllerEventListener(org.olat.core.gui.control.ControllerEventListener) OLATResource(org.olat.resource.OLATResource) Event(org.olat.core.gui.control.Event) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) RepositoryEntryRuntimeController(org.olat.repository.ui.RepositoryEntryRuntimeController) DeliveryOptionsConfigurationController(org.olat.core.gui.control.generic.iframe.DeliveryOptionsConfigurationController) Controller(org.olat.core.gui.control.Controller) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) DeliveryOptionsConfigurationController(org.olat.core.gui.control.generic.iframe.DeliveryOptionsConfigurationController) UserRequest(org.olat.core.gui.UserRequest)

Example 20 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class ImsCPHandler method createLaunchController.

@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
    OLATResource res = re.getOlatResource();
    File cpRoot = FileResourceManager.getInstance().unzipFileResource(res);
    final LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
    CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(res);
    final DeliveryOptions deliveryOptions = (packageConfig == null ? null : packageConfig.getDeliveryOptions());
    return new CPRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {

        @Override
        public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
            boolean activateFirstPage = true;
            String initialUri = null;
            CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
            CPDisplayController cpCtr = new CPDisplayController(uureq, wwControl, vfsWrapper, true, true, activateFirstPage, true, deliveryOptions, initialUri, entry.getOlatResource(), "", false);
            MainLayout3ColumnsController ctr = new LayoutMain3ColsController(uureq, wwControl, cpCtr.getMenuComponent(), cpCtr.getInitialComponent(), vfsWrapper.getName());
            ctr.addDisposableChildController(cpCtr);
            return ctr;
        }
    });
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) MainLayout3ColumnsController(org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController) CPDisplayController(org.olat.modules.cp.CPDisplayController) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayout3ColumnsController(org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController) CPContentController(org.olat.ims.cp.ui.CPContentController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CPDisplayController(org.olat.modules.cp.CPDisplayController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) CPRuntimeController(org.olat.ims.cp.ui.CPRuntimeController) CPEditMainController(org.olat.ims.cp.ui.CPEditMainController) Controller(org.olat.core.gui.control.Controller) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) CPRuntimeController(org.olat.ims.cp.ui.CPRuntimeController) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)34 RepositoryEntry (org.olat.repository.RepositoryEntry)18 UserRequest (org.olat.core.gui.UserRequest)10 Controller (org.olat.core.gui.control.Controller)10 WindowControl (org.olat.core.gui.control.WindowControl)10 File (java.io.File)8 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)8 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)6 OLATResource (org.olat.resource.OLATResource)6 SinglePageController (org.olat.core.commons.modules.singlepage.SinglePageController)4 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)4 Event (org.olat.core.gui.control.Event)4 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)4 CloneController (org.olat.core.gui.control.generic.clone.CloneController)4 CloneLayoutControllerCreatorCallback (org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback)4 CloneableController (org.olat.core.gui.control.generic.clone.CloneableController)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 DeliveryOptionsConfigurationController (org.olat.core.gui.control.generic.iframe.DeliveryOptionsConfigurationController)4