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