Search in sources :

Example 21 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

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 22 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class ScormCourseNode method getCutValueConfiguration.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#getCutValueConfiguration()
 */
@Override
public Float getCutValueConfiguration() {
    ModuleConfiguration config = this.getModuleConfiguration();
    int cutValue = config.getIntegerSafe(ScormEditController.CONFIG_CUTVALUE, 0);
    return new Float(new Integer(cutValue).floatValue());
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 23 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class TUCourseNode 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, Boolean.FALSE.booleanValue());
        config.setConfigurationVersion(2);
    } else {
        // clear old popup configuration
        config.remove(NodeEditController.CONFIG_INTEGRATION);
        config.remove("width");
        config.remove("height");
        if (config.getConfigurationVersion() < 2) {
            // update new configuration options using default values for existing nodes
            config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
            config.setConfigurationVersion(2);
        }
    // else node is up-to-date - nothing to do
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 24 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class WikiCourseNode method updateModuleConfigDefaults.

@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
        // use defaults for new course building blocks
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, false);
        config.setConfigurationVersion(1);
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 25 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class GTAManagerImpl method getDuplicatedMemberships.

@Override
public List<IdentityRef> getDuplicatedMemberships(GTACourseNode cNode) {
    List<IdentityRef> duplicates;
    ModuleConfiguration config = cNode.getModuleConfiguration();
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        List<Long> consolidatedGroupKeys = new ArrayList<>();
        if (groupKeys != null && groupKeys.size() > 0) {
            consolidatedGroupKeys.addAll(groupKeys);
        }
        consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
        List<BusinessGroupRef> businessGroups = BusinessGroupRefImpl.toRefs(consolidatedGroupKeys);
        duplicates = businessGroupRelationDao.getDuplicateMemberships(businessGroups);
    } else {
        duplicates = Collections.emptyList();
    }
    return duplicates;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ModuleConfiguration(org.olat.modules.ModuleConfiguration) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Aggregations

ModuleConfiguration (org.olat.modules.ModuleConfiguration)296 ArrayList (java.util.ArrayList)34 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)28 ICourse (org.olat.course.ICourse)26 CourseNode (org.olat.course.nodes.CourseNode)26 Date (java.util.Date)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 File (java.io.File)20 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)18 List (java.util.List)16 Identity (org.olat.core.id.Identity)16 CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 Translator (org.olat.core.gui.translator.Translator)14 AssessmentManager (org.olat.course.assessment.AssessmentManager)14 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)14 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 VFSItem (org.olat.core.util.vfs.VFSItem)12 BusinessGroup (org.olat.group.BusinessGroup)12 Checkbox (org.olat.course.nodes.cl.model.Checkbox)11