Search in sources :

Example 1 with ScormPackageConfig

use of org.olat.modules.scorm.ScormPackageConfig 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 2 with ScormPackageConfig

use of org.olat.modules.scorm.ScormPackageConfig in project OpenOLAT by OpenOLAT.

the class VarForm method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == searchController) {
        cmc.deactivate();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // search controller done
            RepositoryEntry re = searchController.getSelectedEntry();
            if (re != null) {
                setScormCPReference(re, config);
                cpConfigurationVc.contextPut("showPreviewButton", Boolean.TRUE);
                String displayname = StringHelper.escapeHtml(re.getDisplayname());
                previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, cpConfigurationVc, this);
                previewLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
                previewLink.setCustomEnabledLinkCSS("o_preview");
                previewLink.setTitle(getTranslator().translate("command.preview"));
                // fire event so the updated config is saved by the
                // editormaincontroller
                fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
                ScormPackageConfig scormConfig = ScormMainManager.getInstance().getScormPackageConfig(re.getOlatResource());
                DeliveryOptions parentConfig = scormConfig == null ? null : scormConfig.getDeliveryOptions();
                deliveryOptionsCtrl.setParentDeliveryOptions(parentConfig);
            }
        // else cancelled repo search
        }
    } else if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            scormNode.setPreConditionAccess(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scorevarform) {
        if (event == Event.DONE_EVENT) {
            // save form-values to config
            config.setBooleanEntry(CONFIG_SHOWMENU, scorevarform.isShowMenu());
            config.setBooleanEntry(CONFIG_SKIPLAUNCHPAGE, scorevarform.isSkipLaunchPage());
            config.setBooleanEntry(CONFIG_SHOWNAVBUTTONS, scorevarform.isShowNavButtons());
            config.setBooleanEntry(CONFIG_ISASSESSABLE, scorevarform.isAssessable());
            config.setStringValue(CONFIG_ASSESSABLE_TYPE, scorevarform.getAssessableType());
            config.setIntValue(CONFIG_CUTVALUE, scorevarform.getCutValue());
            config.setBooleanEntry(CONFIG_FULLWINDOW, scorevarform.isFullWindow());
            config.setBooleanEntry(CONFIG_CLOSE_ON_FINISH, scorevarform.isCloseOnFinish());
            // <OLATCE-289>
            config.setIntValue(CONFIG_MAXATTEMPTS, scorevarform.getAttemptsValue());
            config.setBooleanEntry(CONFIG_ADVANCESCORE, scorevarform.isAdvanceScore());
            config.setBooleanEntry(CONFIG_ATTEMPTSDEPENDONSCORE, scorevarform.getAttemptsDependOnScore());
            // </OLATCE-289>
            // fire event so the updated config is saved by the
            // editormaincontroller
            updateHighscoreTab();
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == deliveryOptionsCtrl) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            config.set(CONFIG_DELIVERY_OPTIONS, deliveryOptionsCtrl.getDeliveryOptions());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == highScoreNodeConfigController) {
        if (event == Event.DONE_EVENT) {
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 3 with ScormPackageConfig

use of org.olat.modules.scorm.ScormPackageConfig in project openolat by klemens.

the class VarForm method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == searchController) {
        cmc.deactivate();
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            // search controller done
            RepositoryEntry re = searchController.getSelectedEntry();
            if (re != null) {
                setScormCPReference(re, config);
                cpConfigurationVc.contextPut("showPreviewButton", Boolean.TRUE);
                String displayname = StringHelper.escapeHtml(re.getDisplayname());
                previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, cpConfigurationVc, this);
                previewLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
                previewLink.setCustomEnabledLinkCSS("o_preview");
                previewLink.setTitle(getTranslator().translate("command.preview"));
                // fire event so the updated config is saved by the
                // editormaincontroller
                fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
                ScormPackageConfig scormConfig = ScormMainManager.getInstance().getScormPackageConfig(re.getOlatResource());
                DeliveryOptions parentConfig = scormConfig == null ? null : scormConfig.getDeliveryOptions();
                deliveryOptionsCtrl.setParentDeliveryOptions(parentConfig);
            }
        // else cancelled repo search
        }
    } else if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            scormNode.setPreConditionAccess(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scorevarform) {
        if (event == Event.DONE_EVENT) {
            // save form-values to config
            config.setBooleanEntry(CONFIG_SHOWMENU, scorevarform.isShowMenu());
            config.setBooleanEntry(CONFIG_SKIPLAUNCHPAGE, scorevarform.isSkipLaunchPage());
            config.setBooleanEntry(CONFIG_SHOWNAVBUTTONS, scorevarform.isShowNavButtons());
            config.setBooleanEntry(CONFIG_ISASSESSABLE, scorevarform.isAssessable());
            config.setStringValue(CONFIG_ASSESSABLE_TYPE, scorevarform.getAssessableType());
            config.setIntValue(CONFIG_CUTVALUE, scorevarform.getCutValue());
            config.setBooleanEntry(CONFIG_FULLWINDOW, scorevarform.isFullWindow());
            config.setBooleanEntry(CONFIG_CLOSE_ON_FINISH, scorevarform.isCloseOnFinish());
            // <OLATCE-289>
            config.setIntValue(CONFIG_MAXATTEMPTS, scorevarform.getAttemptsValue());
            config.setBooleanEntry(CONFIG_ADVANCESCORE, scorevarform.isAdvanceScore());
            config.setBooleanEntry(CONFIG_ATTEMPTSDEPENDONSCORE, scorevarform.getAttemptsDependOnScore());
            // </OLATCE-289>
            // fire event so the updated config is saved by the
            // editormaincontroller
            updateHighscoreTab();
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == deliveryOptionsCtrl) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            config.set(CONFIG_DELIVERY_OPTIONS, deliveryOptionsCtrl.getDeliveryOptions());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == highScoreNodeConfigController) {
        if (event == Event.DONE_EVENT) {
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions)

Example 4 with ScormPackageConfig

use of org.olat.modules.scorm.ScormPackageConfig in project openolat by klemens.

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
}
Also used : CloseInstantMessagingEvent(org.olat.instantMessaging.CloseInstantMessagingEvent) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 5 with ScormPackageConfig

use of org.olat.modules.scorm.ScormPackageConfig in project openolat by klemens.

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;
}
Also used : ScormMainManager(org.olat.modules.scorm.ScormMainManager) ScormPackageConfig(org.olat.modules.scorm.ScormPackageConfig) OLATResource(org.olat.resource.OLATResource) File(java.io.File)

Aggregations

ScormPackageConfig (org.olat.modules.scorm.ScormPackageConfig)8 RepositoryEntry (org.olat.repository.RepositoryEntry)6 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)4 File (java.io.File)2 Condition (org.olat.course.condition.Condition)2 CloseInstantMessagingEvent (org.olat.instantMessaging.CloseInstantMessagingEvent)2 ModuleConfiguration (org.olat.modules.ModuleConfiguration)2 ScormMainManager (org.olat.modules.scorm.ScormMainManager)2 OLATResource (org.olat.resource.OLATResource)2