use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.
the class CPCourseNode 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) {
int CURRENTVERSION = 7;
ModuleConfiguration config = getModuleConfiguration();
if (isNewNode) {
// use defaults for new course building blocks
config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
// how to render files (include jquery etc)
DeliveryOptions nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
nodeDeliveryOptions.setInherit(Boolean.TRUE);
config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
config.setConfigurationVersion(CURRENTVERSION);
} else {
config.remove(NodeEditController.CONFIG_INTEGRATION);
if (config.getConfigurationVersion() < 2) {
// update new configuration options using default values for existing
// nodes
config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
Boolean componentMenu = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
if (componentMenu == null) {
config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
}
config.setConfigurationVersion(2);
}
if (config.getConfigurationVersion() < 3) {
config.set(NodeEditController.CONFIG_CONTENT_ENCODING, NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
config.set(NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
config.setConfigurationVersion(3);
}
// save it as version 6
if (config.getConfigurationVersion() < 7) {
String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
if (contentEncoding != null && contentEncoding.equals("auto")) {
// new style for auto
contentEncoding = null;
}
String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
if (jsEncoding != null && jsEncoding.equals("auto")) {
// new style for auto
jsEncoding = null;
}
CPPackageConfig reConfig = null;
DeliveryOptions nodeDeliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
if (nodeDeliveryOptions == null) {
// Update missing delivery options now, inherit from repo by default
nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
nodeDeliveryOptions.setInherit(Boolean.TRUE);
RepositoryEntry re = getReferencedRepositoryEntry();
// Check if delivery options are set for repo entry, if not create default
if (re != null) {
reConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
if (reConfig == null) {
reConfig = new CPPackageConfig();
}
DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
if (repoDeliveryOptions == null) {
// migrate existing config back to repo entry using the default as a base
repoDeliveryOptions = DeliveryOptions.defaultWithGlossary();
reConfig.setDeliveryOptions(repoDeliveryOptions);
repoDeliveryOptions.setContentEncoding(contentEncoding);
repoDeliveryOptions.setJavascriptEncoding(jsEncoding);
CPManager.getInstance().setCPPackageConfig(re.getOlatResource(), reConfig);
} else {
// see if we have any different settings than the repo. if so, don't use inherit mode
if (contentEncoding != repoDeliveryOptions.getContentEncoding() || jsEncoding != repoDeliveryOptions.getJavascriptEncoding()) {
nodeDeliveryOptions.setInherit(Boolean.FALSE);
nodeDeliveryOptions.setContentEncoding(contentEncoding);
nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
}
}
}
// remove old config parameters
config.remove(NodeEditController.CONFIG_CONTENT_ENCODING);
config.remove(NodeEditController.CONFIG_JS_ENCODING);
// replace with new delivery options
config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
}
config.setConfigurationVersion(7);
}
// else node is up-to-date - nothing to do
}
if (config.getConfigurationVersion() != CURRENTVERSION) {
OLog logger = Tracing.createLoggerFor(CPCourseNode.class);
logger.error("CP course node version not updated to lastest version::" + CURRENTVERSION + ", was::" + config.getConfigurationVersion() + ". Check the code, programming error.");
}
}
use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.
the class CPRuntimeController method doLayout.
private void doLayout(UserRequest ureq) {
RepositoryEntry entry = getRepositoryEntry();
final OLATResource resource = entry.getOlatResource();
CPPackageConfig cpConfig = cpManager.getCPPackageConfig(resource);
DeliveryOptions config = cpConfig == null ? null : cpConfig.getDeliveryOptions();
WindowControl bwControl = getSubWindowControl("Layout");
final DeliveryOptionsConfigurationController deliveryOptionsCtrl = new DeliveryOptionsConfigurationController(ureq, addToHistory(ureq, bwControl), config, "Knowledge Transfer#_cp_layout");
deliveryOptionsCtrl.addControllerListener(new ControllerEventListener() {
@Override
public void dispatchEvent(UserRequest uureq, Controller source, Event event) {
if (source == deliveryOptionsCtrl && (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT)) {
DeliveryOptions newConfig = deliveryOptionsCtrl.getDeliveryOptions();
CPPackageConfig cConfig = cpManager.getCPPackageConfig(resource);
if (cConfig == null) {
cConfig = new CPPackageConfig();
}
cConfig.setDeliveryOptions(newConfig);
cpManager.setCPPackageConfig(resource, cConfig);
}
}
});
pushController(ureq, translate("tab.layout"), deliveryOptionsCtrl);
setActiveTool(deliveryOptionsLink);
}
use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.
the class ScormMainManager method createScormAPIandDisplayController.
/**
* @param ureq
* @param wControl
* @param showMenu if true, the ims cp menu is shown
* @param apiCallback the callback to where lmssetvalue data is mirrored, or null if no callback is desired
* @param cpRoot
* @param resourceId
* @param lesson_mode add null for the default value or "normal", "browse" or
* "review"
* @param credit_mode add null for the default value or "credit", "no-credit"
*/
// fxdiff FXOLAT-116: SCORM improvements
public ScormAPIandDisplayController createScormAPIandDisplayController(UserRequest ureq, WindowControl wControl, boolean showMenu, ScormAPICallback apiCallback, File cpRoot, Long scormResourceId, String courseId, String lesson_mode, String credit_mode, boolean previewMode, String assessableType, boolean activate, boolean fullWindow, boolean attemptsIncremented, DeliveryOptions deliveryOptions) {
ScormAPIandDisplayController ctrl = new ScormAPIandDisplayController(ureq, wControl, showMenu, apiCallback, cpRoot, scormResourceId, courseId, lesson_mode, credit_mode, previewMode, assessableType, activate, fullWindow, attemptsIncremented, deliveryOptions);
DeliveryOptions config = ctrl.getDeliveryOptions();
boolean configAllowRawContent = (config == null || config.rawContent());
ctrl.setRawContent(configAllowRawContent);
return ctrl;
}
use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.
the class CompMenuForm method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == chooseCPButton || source == changeCPButton) {
removeAsListenerAndDispose(searchController);
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, ImsCPFileResource.TYPE_NAME, translate(NLS_COMMAND_CHOOSECP));
listenTo(searchController);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true, translate(NLS_COMMAND_CREATECP));
listenTo(cmc);
cmc.activate();
} else if (source == previewLink) {
// Preview as modal dialogue only if the config is valid
RepositoryEntry re = getCPReference(config, false);
if (re == null) {
// we cannot preview it, because the repository entry
// had been deleted between the time when it was chosen here, and now
showError(NLS_ERROR_CPREPOENTRYMISSING);
} else {
File cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
Boolean showMenuB = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
// pre: showMenuB != null
removeAsListenerAndDispose(previewCtr);
DeliveryOptions previewOptions = deliveryOptionsCtrl.getOptionsForPreview();
previewCtr = CPUIFactory.getInstance().createMainLayoutPreviewController_v2(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), showMenuB.booleanValue(), previewOptions);
stackPanel.pushController(translate("preview.cp"), previewCtr);
}
} else if (source == editLink) {
CourseNodeFactory.getInstance().launchReferencedRepoEntryEditor(ureq, getWindowControl(), cpNode);
}
}
use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project openolat by klemens.
the class STCourseNode method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller cont;
String displayType = getModuleConfiguration().getStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE);
String relPath = STCourseNodeEditController.getFileName(getModuleConfiguration());
if (relPath != null && displayType.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
// we want a user chosen overview, so display the chosen file from the
// material folder, otherwise display the normal overview
// reuse the Run controller from the "Single Page" building block, since
// we need to do exactly the same task
Boolean allowRelativeLinks = getModuleConfiguration().getBooleanEntry(STCourseNodeEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
if (allowRelativeLinks == null) {
allowRelativeLinks = Boolean.FALSE;
}
DeliveryOptions deliveryOptions = (DeliveryOptions) getModuleConfiguration().get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
SinglePageController spCtr = new SinglePageController(ureq, wControl, userCourseEnv.getCourseEnvironment().getCourseFolderContainer(), relPath, allowRelativeLinks.booleanValue(), null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
// check if user is allowed to edit the page in the run view
CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
boolean hasEditRights = (cgm.isIdentityCourseAdministrator(ureq.getIdentity()) || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_COURSEEDITOR)) || (getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_COACH_EDIT, false) && cgm.isIdentityCourseCoach(ureq.getIdentity()));
if (hasEditRights) {
spCtr.allowPageEditing();
// set the link tree model to internal for the HTML editor
CustomLinkTreeModel linkTreeModel = new CourseInternalLinkTreeModel(userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode());
spCtr.setInternalLinkTreeModel(linkTreeModel);
}
spCtr.addLoggingResourceable(LoggingResourceable.wrap(this));
// create clone wrapper layout, allow popping into second window
CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {
@Override
public ControllerCreator createLayoutControllerCreator(final UserRequest uureq, final ControllerCreator contentControllerCreator) {
return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
// wrap in column layout, popup window needs a layout controller
Controller ctr = contentControllerCreator.createController(lureq, lwControl);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), userCourseEnv.getCourseEnvironment()));
Controller wrappedCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, STCourseNode.this, ICON_CSS_CLASS);
layoutCtr.addDisposableChildController(wrappedCtrl);
return layoutCtr;
}
});
}
};
Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, spCtr, this, ICON_CSS_CLASS);
if (wrappedCtrl instanceof CloneableController) {
cont = new CloneController(ureq, wControl, (CloneableController) wrappedCtrl, clccc);
} else {
throw new AssertException("Need to be a cloneable");
}
} else {
// evaluate the score accounting for this node. this uses the score accountings local
// cache hash map to reduce unnecessary calculations
ScoreEvaluation se = userCourseEnv.getScoreAccounting().evalCourseNode(this);
cont = TitledWrapperHelper.getWrapper(ureq, wControl, new STCourseNodeRunController(ureq, wControl, userCourseEnv, this, se, ne), this, ICON_CSS_CLASS);
}
// displayed in the ST-Runcontroller
return new NodeRunConstructionResult(cont);
}
Aggregations