Search in sources :

Example 1 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class CPManagerImpl method createNewCP.

/**
 * @see org.olat.ims.cp.CPManager#createNewCP(org.olat.core.id.OLATResourceable)
 */
public ContentPackage createNewCP(OLATResourceable ores, String initalPageTitle) {
    // copy template cp to new repo-location
    if (copyTemplCP(ores)) {
        File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
        logDebug("createNewCP: cpRoot=" + cpRoot);
        logDebug("createNewCP: cpRoot.getAbsolutePath()=" + cpRoot.getAbsolutePath());
        LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
        ContentPackage cp = load(vfsWrapper, ores);
        // Modify the copy of the template to get a unique identifier
        CPOrganization orga = setUniqueOrgaIdentifier(cp);
        setOrgaTitleToRepoEntryTitle(ores, orga);
        // Also set the translated title of the inital page.
        orga.getItems().get(0).setTitle(initalPageTitle);
        writeToFile(cp);
        // set the default settings for file delivery
        DeliveryOptions defOptions = DeliveryOptions.defaultWithGlossary();
        CPPackageConfig config = new CPPackageConfig();
        config.setDeliveryOptions(defOptions);
        setCPPackageConfig(ores, config);
        return cp;
    } else {
        logError("CP couldn't be created. Error when copying template. Ores: " + ores.getResourceableId(), null);
        throw new OLATRuntimeException("ERROR while creating new empty cp. an error occured while trying to copy template CP", null);
    }
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) CPOrganization(org.olat.ims.cp.objects.CPOrganization) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 2 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

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);
}
Also used : STCourseNodeRunController(org.olat.course.nodes.st.STCourseNodeRunController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) SPPeekviewController(org.olat.course.nodes.sp.SPPeekviewController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) NodeEditController(org.olat.course.editor.NodeEditController) STCourseNodeRunController(org.olat.course.nodes.st.STCourseNodeRunController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) CloneableController(org.olat.core.gui.control.generic.clone.CloneableController) AssessmentCourseNodeController(org.olat.course.assessment.ui.tool.AssessmentCourseNodeController) SPEditController(org.olat.course.nodes.sp.SPEditController) CloneController(org.olat.core.gui.control.generic.clone.CloneController) STCourseNodeEditController(org.olat.course.nodes.st.STCourseNodeEditController) Controller(org.olat.core.gui.control.Controller) STPeekViewController(org.olat.course.nodes.st.STPeekViewController) STIdentityListCourseNodeController(org.olat.course.nodes.st.STIdentityListCourseNodeController) SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) WindowControl(org.olat.core.gui.control.WindowControl) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) CustomLinkTreeModel(org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel) CloneController(org.olat.core.gui.control.generic.clone.CloneController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CloneLayoutControllerCreatorCallback(org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest) CourseInternalLinkTreeModel(org.olat.course.tree.CourseInternalLinkTreeModel)

Example 3 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

the class STCourseNode 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(STCourseNodeEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, Boolean.FALSE.booleanValue());
        // set the default display to peekview in two columns
        config.setStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE, STCourseNodeEditController.CONFIG_VALUE_DISPLAY_PEEKVIEW);
        config.setIntValue(STCourseNodeEditController.CONFIG_KEY_COLUMNS, 2);
        DeliveryOptions defaultOptions = DeliveryOptions.defaultWithGlossary();
        config.set(SPEditController.CONFIG_KEY_DELIVERYOPTIONS, defaultOptions);
        config.setConfigurationVersion(3);
        scoreCalculator = new ScoreCalculator();
        scoreCalculator.setFailedType(FailedEvaluationType.failedAsNotPassedAfterEndDate);
    } else {
        // update to version 2
        if (config.getConfigurationVersion() < 2) {
            // use values accoring to previous functionality
            config.setBooleanEntry(STCourseNodeEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, Boolean.FALSE.booleanValue());
            // calculator, se to expert mode
            if (getScoreCalculator() != null) {
                getScoreCalculator().setExpertMode(true);
            }
            config.setConfigurationVersion(2);
        }
        // update to version 3
        if (config.getConfigurationVersion() < 3) {
            String fileName = (String) config.get(STCourseNodeEditController.CONFIG_KEY_FILE);
            if (fileName != null) {
                // set to custom file display config
                config.setStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE, STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE);
            } else {
                // set the default display to plain vanilla TOC view in one column
                config.setStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE, STCourseNodeEditController.CONFIG_VALUE_DISPLAY_TOC);
                config.setIntValue(STCourseNodeEditController.CONFIG_KEY_COLUMNS, 1);
            }
            config.setConfigurationVersion(3);
        }
        if (config.getConfigurationVersion() < 4) {
            if (config.get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS) == null) {
                DeliveryOptions defaultOptions = DeliveryOptions.defaultWithGlossary();
                config.set(SPEditController.CONFIG_KEY_DELIVERYOPTIONS, defaultOptions);
            }
            config.setConfigurationVersion(4);
        }
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 4 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

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);
        }
    }
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 5 with DeliveryOptions

use of org.olat.core.gui.control.generic.iframe.DeliveryOptions in project OpenOLAT by OpenOLAT.

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;
}
Also used : DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Aggregations

DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)34 RepositoryEntry (org.olat.repository.RepositoryEntry)18 UserRequest (org.olat.core.gui.UserRequest)10 Controller (org.olat.core.gui.control.Controller)10 WindowControl (org.olat.core.gui.control.WindowControl)10 File (java.io.File)8 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)8 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)6 OLATResource (org.olat.resource.OLATResource)6 SinglePageController (org.olat.core.commons.modules.singlepage.SinglePageController)4 ControllerEventListener (org.olat.core.gui.control.ControllerEventListener)4 Event (org.olat.core.gui.control.Event)4 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)4 CloneController (org.olat.core.gui.control.generic.clone.CloneController)4 CloneLayoutControllerCreatorCallback (org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback)4 CloneableController (org.olat.core.gui.control.generic.clone.CloneableController)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 DeliveryOptionsConfigurationController (org.olat.core.gui.control.generic.iframe.DeliveryOptionsConfigurationController)4