use of org.olat.modules.scorm.ScormPackageConfig 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.scorm.ScormPackageConfig in project OpenOLAT by OpenOLAT.
the class SCORMCPHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
final ScormMainManager scormManager = ScormMainManager.getInstance();
OLATResource sourceResource = source.getOlatResource();
OLATResource targetResource = target.getOlatResource();
File sourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(sourceResource).getBasefile();
File zipRoot = new File(sourceFileroot, FileResourceManager.ZIPDIR);
File targetFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(targetResource).getBasefile();
FileUtils.copyFileToDir(zipRoot, targetFileroot, "add file resource");
// copy packaging info
ScormPackageConfig scormConfig = scormManager.getScormPackageConfig(sourceResource);
if (scormConfig != null) {
scormManager.setScormPackageConfig(targetResource, scormConfig);
}
return target;
}
use of org.olat.modules.scorm.ScormPackageConfig in project OpenOLAT by OpenOLAT.
the class ScormRunController method doLaunch.
private void doLaunch(UserRequest ureq, boolean doActivate) {
ureq.getUserSession().getSingleUserEventCenter().fireEventToListenersOf(new CloseInstantMessagingEvent(), InstantMessagingService.TOWER_EVENT_ORES);
if (cpRoot == null) {
// it is the first time we start the contentpackaging from this
// instance
// of this controller.
// need to be strict when launching -> "true"
RepositoryEntry re = ScormEditController.getScormCPReference(config, false);
if (re == null) {
doSetMissingResourcesWarning(ureq);
return;
}
cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
addLoggingResourceable(LoggingResourceable.wrapScormRepositoryEntry(re));
// nodes reference them
if (cpRoot == null) {
doSetMissingResourcesWarning(ureq);
logError("File of repository entry " + re.getKey() + " was missing", null);
return;
}
}
// else cpRoot is already set (save some db access if the user opens /
// closes / reopens the cp from the same CPRuncontroller instance)
String courseId;
boolean showMenu = config.getBooleanSafe(ScormEditController.CONFIG_SHOWMENU, true);
final boolean fullWindow = config.getBooleanSafe(ScormEditController.CONFIG_FULLWINDOW, true);
if (isPreview) {
courseId = new Long(CodeHelper.getRAMUniqueID()).toString();
scormDispC = ScormMainManager.getInstance().createScormAPIandDisplayController(ureq, getWindowControl(), showMenu, null, cpRoot, null, courseId, ScormConstants.SCORM_MODE_BROWSE, ScormConstants.SCORM_MODE_NOCREDIT, true, null, doActivate, fullWindow, false, deliveryOptions);
} else {
boolean attemptsIncremented = false;
// increment user attempts only once!
if (!config.getBooleanSafe(ScormEditController.CONFIG_ADVANCESCORE, true) || !config.getBooleanSafe(ScormEditController.CONFIG_ATTEMPTSDEPENDONSCORE, false)) {
scormNode.incrementUserAttempts(userCourseEnv, Role.user);
attemptsIncremented = true;
}
courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().toString();
if (isAssessable) {
// When a SCORE is transfered, the run mode is hardcoded
scormDispC = ScormMainManager.getInstance().createScormAPIandDisplayController(ureq, getWindowControl(), showMenu, this, cpRoot, null, courseId + "-" + scormNode.getIdent(), ScormConstants.SCORM_MODE_NORMAL, ScormConstants.SCORM_MODE_CREDIT, false, assessableType, doActivate, fullWindow, attemptsIncremented, deliveryOptions);
} else if (chooseScormRunMode.getSelectedElement().equals(ScormConstants.SCORM_MODE_NORMAL)) {
// When not assessible users can choose between normal mode where data is stored...
scormDispC = ScormMainManager.getInstance().createScormAPIandDisplayController(ureq, getWindowControl(), showMenu, this, cpRoot, null, courseId + "-" + scormNode.getIdent(), ScormConstants.SCORM_MODE_NORMAL, ScormConstants.SCORM_MODE_CREDIT, false, assessableType, doActivate, fullWindow, attemptsIncremented, deliveryOptions);
} else {
// ... and preview mode where no data is stored
scormDispC = ScormMainManager.getInstance().createScormAPIandDisplayController(ureq, getWindowControl(), showMenu, this, cpRoot, null, courseId, ScormConstants.SCORM_MODE_BROWSE, ScormConstants.SCORM_MODE_NOCREDIT, false, assessableType, doActivate, fullWindow, attemptsIncremented, deliveryOptions);
}
}
// configure some display options
boolean showNavButtons = config.getBooleanSafe(ScormEditController.CONFIG_SHOWNAVBUTTONS, true);
scormDispC.showNavButtons(showNavButtons);
if (deliveryOptions != null && deliveryOptions.getInherit() != null && deliveryOptions.getInherit().booleanValue()) {
ScormPackageConfig pConfig = ScormMainManager.getInstance().getScormPackageConfig(cpRoot);
deliveryOptions = (pConfig == null ? null : pConfig.getDeliveryOptions());
}
if (deliveryOptions == null) {
scormDispC.setHeightPX(680);
} else {
scormDispC.setDeliveryOptions(deliveryOptions);
}
listenTo(scormDispC);
// the scormDispC activates itself
}
Aggregations