use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class MSCourseNode method getMaxScoreConfiguration.
/**
* @see org.olat.course.nodes.AssessableCourseNode#getMaxScoreConfiguration()
*/
@Override
public Float getMaxScoreConfiguration() {
if (!hasScoreConfigured()) {
throw new OLATRuntimeException(MSCourseNode.class, "getMaxScore not defined when hasScore set to false", null);
}
ModuleConfiguration config = getModuleConfiguration();
Float max = (Float) config.get(CONFIG_KEY_SCORE_MAX);
return max;
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class ProjectBrokerCourseNode method updateModuleConfigDefaults.
/**
* Init config parameter with default values for a new course node.
*/
@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
ModuleConfiguration config = getModuleConfiguration();
if (isNewNode) {
// use defaults for new course building blocks
// dropbox defaults
config.set(CONF_DROPBOX_ENABLED, Boolean.TRUE);
config.set(CONF_DROPBOX_ENABLEMAIL, Boolean.FALSE);
config.set(CONF_DROPBOX_CONFIRMATION, "");
// scoring defaults
config.set(CONF_SCORING_ENABLED, Boolean.FALSE);
// returnbox defaults
config.set(CONF_RETURNBOX_ENABLED, Boolean.TRUE);
// New config parameter version 2
config.setBooleanEntry(CONF_TASK_PREVIEW, false);
MSCourseNode.initDefaultConfig(config);
config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
} else {
int version = config.getConfigurationVersion();
if (version < CURRENT_CONFIG_VERSION) {
// Loaded config is older than current config version => migrate
if (version == 1) {
// migrate V1 => V2 (remove all condition
this.setConditionDrop(null);
this.setConditionReturnbox(null);
version = 2;
}
config.setConfigurationVersion(CURRENT_CONFIG_VERSION);
}
}
}
use of org.olat.modules.ModuleConfiguration 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
}
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class STCourseNode method getDisplayOption.
/**
* @see org.olat.course.nodes.GenericCourseNode#getDefaultTitleOption()
*/
@Override
public String getDisplayOption() {
// if nothing other defined, view content only, when a structure node
// contains an html-file.
OLog logger = Tracing.createLoggerFor(this.getClass());
ModuleConfiguration config = getModuleConfiguration();
String thisConf = super.getDisplayOption(false);
if (thisConf == null && config.get(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE).equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
if (logger.isDebug()) {
logger.debug("no displayOption set, use default (content)", thisConf);
}
return CourseNode.DISPLAY_OPTS_CONTENT;
}
if (logger.isDebug()) {
logger.debug("there is a config set, use it: " + thisConf);
}
return super.getDisplayOption();
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class STCourseNode method isConfigValid.
/**
* @see org.olat.course.nodes.CourseNode#isConfigValid()
*/
@Override
public StatusDescription isConfigValid() {
/*
* first check the one click cache
*/
if (oneClickStatusCache != null) {
return oneClickStatusCache[0];
}
ModuleConfiguration config = getModuleConfiguration();
StatusDescription sd = StatusDescription.NOERROR;
if (STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE.equals(config.getStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE))) {
String fileName = (String) config.get(STCourseNodeEditController.CONFIG_KEY_FILE);
if (fileName == null || !StringHelper.containsNonWhitespace(fileName)) {
String shortKey = "error.missingfile.short";
String longKey = "error.missingfile.long";
String[] params = new String[] { this.getShortTitle() };
String translPackage = Util.getPackageName(SPEditController.class);
sd = new StatusDescription(StatusDescription.ERROR, shortKey, longKey, params, translPackage);
sd.setDescriptionForUnit(getIdent());
// set which pane is affected by error
sd.setActivateableViewIdentifier(STCourseNodeEditController.PANE_TAB_ST_CONFIG);
}
}
return sd;
}
Aggregations