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");
}
}
}
}
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);
}
}
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);
}
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;
}
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);
}
}
Aggregations