Search in sources :

Example 96 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration 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 97 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class PFCourseNode method isGreaterOrEqualToLimit.

public boolean isGreaterOrEqualToLimit(int count) {
    ModuleConfiguration config = getModuleConfiguration();
    int limit = config.getBooleanEntry(CONFIG_KEY_FILECOUNT) != null ? (int) config.get(CONFIG_KEY_FILECOUNT) : 0;
    return count >= limit;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 98 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class PortfolioCourseNode method hasPassedConfigured.

@Override
public boolean hasPassedConfigured() {
    ModuleConfiguration config = getModuleConfiguration();
    Boolean passed = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD);
    return (passed == null) ? false : passed.booleanValue();
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 99 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class PortfolioCourseNode method getCutValueConfiguration.

@Override
public Float getCutValueConfiguration() {
    if (!hasPassedConfigured()) {
        throw new OLATRuntimeException(PortfolioCourseNode.class, "getCutValue not defined when hasPassed set to false", null);
    }
    ModuleConfiguration config = getModuleConfiguration();
    Float cut = (Float) config.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
    return cut;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 100 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project openolat by klemens.

the class PortfolioCourseNode method getDeadline.

public Date getDeadline() {
    ModuleConfiguration config = getModuleConfiguration();
    String type = (String) config.get(PortfolioCourseNodeConfiguration.DEADLINE_TYPE);
    if (StringHelper.containsNonWhitespace(type)) {
        switch(DeadlineType.valueOf(type)) {
            case none:
                return null;
            case absolut:
                Date date = (Date) config.get(PortfolioCourseNodeConfiguration.DEADLINE_DATE);
                return date;
            case relative:
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date());
                boolean applied = applyRelativeToDate(cal, PortfolioCourseNodeConfiguration.DEADLINE_MONTH, Calendar.MONTH, 1);
                applied |= applyRelativeToDate(cal, PortfolioCourseNodeConfiguration.DEADLINE_WEEK, Calendar.DATE, 7);
                applied |= applyRelativeToDate(cal, PortfolioCourseNodeConfiguration.DEADLINE_DAY, Calendar.DATE, 1);
                if (applied) {
                    return cal.getTime();
                }
                return null;
            default:
                return null;
        }
    }
    return null;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) Calendar(java.util.Calendar) Date(java.util.Date)

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