Search in sources :

Example 56 with ModuleConfiguration

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

the class CheckListCourseNode method exportNode.

@Override
public void exportNode(File fExportDirectory, ICourse course) {
    // export the files
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    ModuleConfiguration config = getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null) {
        for (Checkbox checkbox : list.getList()) {
            File dir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
            if (dir.exists()) {
                File fFileExportDir = new File(fExportDirectory, "checklistfiles/" + getIdent() + "/" + checkbox.getCheckboxId());
                fFileExportDir.mkdirs();
                FileUtils.copyDirContentsToDir(dir, fFileExportDir, false, "export files of checkbox");
            }
        }
    }
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Checkbox(org.olat.course.nodes.cl.model.Checkbox) File(java.io.File)

Example 57 with ModuleConfiguration

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

the class ENCourseNode method migrateConfig.

/**
 * Migrate (add new config parameter/values) config parameter for a existing course node.
 */
private void migrateConfig() {
    ModuleConfiguration config = getModuleConfiguration();
    int version = config.getConfigurationVersion();
    if (version < CURRENT_CONFIG_VERSION) {
        // Loaded config is older than current config version => migrate
        if (version == 1) {
            // migrate V1 => V2
            config.set(CONF_CANCEL_ENROLL_ENABLED, Boolean.TRUE);
            version = 2;
        } else if (version <= 2) {
            // migrate V2 -> V3
            config.set(CONFIG_ALLOW_MULTIPLE_ENROLL_COUNT, 1);
            version = 3;
        }
        config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 58 with ModuleConfiguration

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

the class ENCourseNode method initDefaultConfig.

/**
 * Init config parameter with default values for a new course node.
 */
private void initDefaultConfig() {
    ModuleConfiguration config = getModuleConfiguration();
    // defaults
    config.set(CONF_CANCEL_ENROLL_ENABLED, Boolean.TRUE);
    config.set(CONFIG_ALLOW_MULTIPLE_ENROLL_COUNT, 1);
    config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 59 with ModuleConfiguration

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

the class ENCourseNode method isUsedForEnrollment.

public boolean isUsedForEnrollment(List<BusinessGroup> groups, OLATResource courseResource) {
    if (groups == null || groups.isEmpty())
        return false;
    ModuleConfiguration mc = getModuleConfiguration();
    String groupNames = (String) mc.get(CONFIG_GROUPNAME);
    List<Long> groupKeys = mc.getList(ENCourseNode.CONFIG_GROUP_IDS, Long.class);
    if (groupKeys != null && groupKeys.size() > 0) {
        for (BusinessGroup group : groups) {
            if (groupKeys.contains(group.getKey())) {
                return true;
            }
        }
    } else if (StringHelper.containsNonWhitespace(groupNames)) {
        String[] groupNameArr = groupNames.split(",");
        for (BusinessGroup group : groups) {
            for (String groupName : groupNameArr) {
                if (groupName != null && group.getName() != null && groupName.equals(group.getName())) {
                    return true;
                }
            }
        }
    }
    List<Long> areaKeys = mc.getList(ENCourseNode.CONFIG_AREA_IDS, Long.class);
    if (areaKeys == null || areaKeys.isEmpty()) {
        String areaNames = (String) mc.get(CONFIG_AREANAME);
        areaKeys = CoreSpringFactory.getImpl(BGAreaManager.class).toAreaKeys(areaNames, courseResource);
    }
    if (areaKeys != null && areaKeys.size() > 0) {
        List<Long> areaGroupKeys = CoreSpringFactory.getImpl(BGAreaManager.class).findBusinessGroupKeysOfAreaKeys(areaKeys);
        for (BusinessGroup group : groups) {
            if (areaGroupKeys.contains(group.getKey())) {
                return true;
            }
        }
    }
    return false;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroup(org.olat.group.BusinessGroup) BGAreaManager(org.olat.group.area.BGAreaManager)

Example 60 with ModuleConfiguration

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

the class ENCourseNode method postExport.

@Override
public void postExport(CourseEnvironmentMapper envMapper, boolean backwardsCompatible) {
    super.postExport(envMapper, backwardsCompatible);
    ModuleConfiguration mc = getModuleConfiguration();
    List<Long> groupKeys = mc.getList(ENCourseNode.CONFIG_GROUP_IDS, Long.class);
    if (groupKeys != null) {
        String groupNames = envMapper.toGroupNames(groupKeys);
        mc.set(ENCourseNode.CONFIG_GROUPNAME, groupNames);
    }
    List<Long> areaKeys = mc.getList(ENCourseNode.CONFIG_AREA_IDS, Long.class);
    if (areaKeys != null) {
        String areaNames = envMapper.toAreaNames(areaKeys);
        mc.set(ENCourseNode.CONFIG_AREANAME, areaNames);
    }
    if (backwardsCompatible) {
        mc.remove(ENCourseNode.CONFIG_GROUP_IDS);
        mc.remove(ENCourseNode.CONFIG_AREA_IDS);
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

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