Search in sources :

Example 6 with ScoreCalculator

use of org.olat.course.run.scoring.ScoreCalculator in project OpenOLAT by OpenOLAT.

the class STCourseNodeEditController 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 ureq, Controller source, Event event) {
    if (source instanceof NodeEditController) {
        if (combiLinkCtr != null && combiLinkCtr.isDoProposal()) {
            combiLinkCtr.setRelFilePath(CourseEditorHelper.createUniqueRelFilePathFromShortTitle(stNode, courseFolderContainer));
        }
    } else if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            stNode.setPreConditionAccess(cond);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == deliveryOptionsCtrl) {
        deliveryOptions = deliveryOptionsCtrl.getDeliveryOptions();
        stNode.getModuleConfiguration().set(CONFIG_KEY_DELIVERYOPTIONS, deliveryOptions);
        fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
    } else if (source == combiLinkCtr) {
        if (event == Event.DONE_EVENT) {
            chosenFile = VFSManager.getRelativeItemPath(combiLinkCtr.getFile(), courseFolderContainer, null);
            stNode.getModuleConfiguration().set(CONFIG_KEY_FILE, chosenFile);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
            if (!myTabbedPane.containsTab(deliveryOptionsCtrl.getInitialComponent())) {
                myTabbedPane.addTab(translate(PANE_TAB_DELIVERYOPTIONS), deliveryOptionsCtrl.getInitialComponent());
            }
            configvc.contextPut("editorEnabled", combiLinkCtr.isEditorEnabled());
        }
    } else if (source == securitySettingForm) {
        if (event == Event.DONE_EVENT) {
            boolean allowRelativeLinks = securitySettingForm.getAllowRelativeLinksConfig();
            stNode.getModuleConfiguration().set(CONFIG_KEY_ALLOW_RELATIVE_LINKS, allowRelativeLinks);
            stNode.getModuleConfiguration().set(CONFIG_KEY_ALLOW_COACH_EDIT, securitySettingForm.getAllowCoachEditConfig());
            combiLinkCtr.setAllowEditorRelativeLinks(allowRelativeLinks);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == nodeDisplayConfigFormController) {
        if (event == Event.DONE_EVENT) {
            // update the module configuration
            ModuleConfiguration moduleConfig = stNode.getModuleConfiguration();
            nodeDisplayConfigFormController.updateModuleConfiguration(moduleConfig);
            allowRelativeLinks = moduleConfig.getBooleanSafe(CONFIG_KEY_ALLOW_RELATIVE_LINKS);
            // update some class vars
            if (CONFIG_VALUE_DISPLAY_FILE.equals(moduleConfig.getStringValue(CONFIG_KEY_DISPLAY_TYPE))) {
                editorEnabled = true;
                addCustomFileConfigToView(ureq);
            } else {
                // user generated overview
                editorEnabled = false;
                removeCustomFileConfigFromView();
            }
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scoreEasyForm) {
        if (event == Event.DONE_EVENT) {
            // show warning if the score might be wrong because of the invalid nodes used for calculation
            List<String> testElemWithNoResource = scoreEasyForm.getInvalidNodeDescriptions();
            String msg = getWarningMessage(testElemWithNoResource);
            if (msg != null) {
                showWarning(msg);
            }
            ScoreCalculator sc = scoreEasyForm.getScoreCalulator();
            /*
				 * OLAT-1144 bug fix if Calculation Score -> NO and Calculate passing
				 * score -> NO we get a ScoreCalculator == NULL !
				 */
            if (sc != null) {
                sc.setPassedExpression(sc.getPassedExpressionFromEasyModeConfiguration());
                sc.setScoreExpression(sc.getScoreExpressionFromEasyModeConfiguration());
            }
            // ..setScoreCalculator(sc) can handle NULL values!
            stNode.setScoreCalculator(sc);
            // reload form, remove deleted nodes
            initScoreEasyForm(ureq);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
            updateHighscoreTab();
        } else if (event == Event.CANCELLED_EVENT) {
            // reload form
            initScoreEasyForm(ureq);
        }
    } else if (source == scoreExpertForm) {
        if (event == Event.DONE_EVENT) {
            // show warning if the score might be wrong because of the invalid nodes used for calculation
            List<String> testElemWithNoResource = scoreExpertForm.getInvalidNodeDescriptions();
            String msg = getWarningMessage(testElemWithNoResource);
            if (msg != null) {
                getWindowControl().setWarning(msg);
            }
            ScoreCalculator sc = scoreExpertForm.getScoreCalulator();
            /*
				 * OLAT-1144 bug fix if a ScoreCalculator == NULL !
				 */
            if (sc != null) {
                sc.clearEasyMode();
            }
            // ..setScoreCalculator(sc) can handle NULL values!
            stNode.setScoreCalculator(sc);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
            updateHighscoreTab();
        } else if (event == Event.CANCELLED_EVENT) {
            // reload form
            initScoreExpertForm(ureq);
        }
    } else if (source == highScoreNodeConfigController) {
        if (event == Event.DONE_EVENT) {
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition) NodeEditController(org.olat.course.editor.NodeEditController) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator) List(java.util.List)

Example 7 with ScoreCalculator

use of org.olat.course.run.scoring.ScoreCalculator in project OpenOLAT by OpenOLAT.

the class STCourseNode method getScoreCalculator.

/**
 * @return Returns the scoreCalculator.
 */
@Override
public ScoreCalculator getScoreCalculator() {
    if (scoreCalculator == null) {
        scoreCalculator = new ScoreCalculator();
        scoreCalculator.setFailedType(FailedEvaluationType.failedAsNotPassedAfterEndDate);
    }
    passedExpression = new Condition();
    passedExpression.setConditionId("passed");
    if (scoreCalculator.getPassedExpression() != null) {
        passedExpression.setConditionExpression(scoreCalculator.getPassedExpression());
        passedExpression.setExpertMode(true);
    }
    scoreExpression = new Condition();
    scoreExpression.setConditionId("score");
    if (scoreCalculator.getScoreExpression() != null) {
        scoreExpression.setConditionExpression(scoreCalculator.getScoreExpression());
        scoreExpression.setExpertMode(true);
    }
    failedExpression = new Condition();
    failedExpression.setConditionId("failed");
    if (scoreCalculator.getFailedExpression() != null) {
        failedExpression.setConditionExpression(scoreCalculator.getFailedExpression());
        failedExpression.setExpertMode(true);
    }
    return scoreCalculator;
}
Also used : Condition(org.olat.course.condition.Condition) ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator)

Example 8 with ScoreCalculator

use of org.olat.course.run.scoring.ScoreCalculator in project OpenOLAT by OpenOLAT.

the class STCourseNode method postImportCopy.

private void postImportCopy(CourseEnvironmentMapper envMapper) {
    ScoreCalculator calculator = getScoreCalculator();
    boolean changed = false;
    if (StringHelper.containsNonWhitespace(calculator.getScoreExpression())) {
        String score = calculator.getScoreExpression();
        String processedExpression = KeyAndNameConverter.convertExpressionNameToKey(score, envMapper);
        processedExpression = KeyAndNameConverter.convertExpressionKeyToKey(score, envMapper);
        if (!processedExpression.equals(score)) {
            calculator.setScoreExpression(processedExpression);
            changed = true;
        }
    }
    if (StringHelper.containsNonWhitespace(calculator.getPassedExpression())) {
        String passed = calculator.getPassedExpression();
        String processedExpression = KeyAndNameConverter.convertExpressionNameToKey(passed, envMapper);
        processedExpression = KeyAndNameConverter.convertExpressionKeyToKey(passed, envMapper);
        if (!processedExpression.equals(passed)) {
            calculator.setScoreExpression(processedExpression);
            changed = true;
        }
    }
    if (changed) {
        setScoreCalculator(calculator);
    }
}
Also used : ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator)

Example 9 with ScoreCalculator

use of org.olat.course.run.scoring.ScoreCalculator in project openolat by klemens.

the class OLATUpgrade_11_0_0 method hasAssessableSTCourseNode.

private List<STCourseNode> hasAssessableSTCourseNode(ICourse course) {
    List<STCourseNode> assessableSTNodes = new ArrayList<>();
    CourseNode rootNode = course.getRunStructure().getRootNode();
    new TreeVisitor(new Visitor() {

        @Override
        public void visit(INode node) {
            if (node instanceof STCourseNode) {
                STCourseNode stNode = (STCourseNode) node;
                ScoreCalculator calculator = stNode.getScoreCalculator();
                if (StringHelper.containsNonWhitespace(calculator.getPassedExpression())) {
                    assessableSTNodes.add(stNode);
                } else if (StringHelper.containsNonWhitespace(calculator.getScoreExpression())) {
                    assessableSTNodes.add(stNode);
                }
            }
        }
    }, rootNode, true).visitAll();
    return assessableSTNodes;
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) STCourseNode(org.olat.course.nodes.STCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator) ArrayList(java.util.ArrayList) STCourseNode(org.olat.course.nodes.STCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode)

Example 10 with ScoreCalculator

use of org.olat.course.run.scoring.ScoreCalculator in project openolat by klemens.

the class STCourseNode method postExport.

@Override
public void postExport(CourseEnvironmentMapper envMapper, boolean backwardsCompatible) {
    super.postExport(envMapper, backwardsCompatible);
    // if backwards compatible, convert expression to use names
    if (backwardsCompatible) {
        ScoreCalculator calculator = getScoreCalculator();
        boolean changed = false;
        if (StringHelper.containsNonWhitespace(calculator.getScoreExpression())) {
            String score = calculator.getScoreExpression();
            String processedExpression = KeyAndNameConverter.convertExpressionKeyToName(score, envMapper);
            if (!processedExpression.equals(score)) {
                calculator.setScoreExpression(processedExpression);
                changed = true;
            }
        }
        if (StringHelper.containsNonWhitespace(calculator.getPassedExpression())) {
            String passed = calculator.getPassedExpression();
            String processedExpression = KeyAndNameConverter.convertExpressionKeyToName(passed, envMapper);
            if (!processedExpression.equals(passed)) {
                calculator.setScoreExpression(processedExpression);
                changed = true;
            }
        }
        if (changed) {
            setScoreCalculator(calculator);
        }
    }
}
Also used : ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator)

Aggregations

ScoreCalculator (org.olat.course.run.scoring.ScoreCalculator)14 Condition (org.olat.course.condition.Condition)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)2 INode (org.olat.core.util.nodes.INode)2 TreeVisitor (org.olat.core.util.tree.TreeVisitor)2 Visitor (org.olat.core.util.tree.Visitor)2 NodeEditController (org.olat.course.editor.NodeEditController)2 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)2 BasicLTICourseNode (org.olat.course.nodes.BasicLTICourseNode)2 CourseNode (org.olat.course.nodes.CourseNode)2 GTACourseNode (org.olat.course.nodes.GTACourseNode)2 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)2 MSCourseNode (org.olat.course.nodes.MSCourseNode)2 PortfolioCourseNode (org.olat.course.nodes.PortfolioCourseNode)2 STCourseNode (org.olat.course.nodes.STCourseNode)2 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)2 TACourseNode (org.olat.course.nodes.TACourseNode)2