Search in sources :

Example 1 with ScoreCalculator

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

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)

Example 2 with ScoreCalculator

use of org.olat.course.run.scoring.ScoreCalculator 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 3 with ScoreCalculator

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

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 4 with ScoreCalculator

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

the class CheckListStepRunnerCallback method setScoreCalculation.

private void setScoreCalculation(GeneratorData data, STCourseNode stNode, List<String> checklistNodes) {
    if (!data.isPassed() && !data.isPoints())
        return;
    ScoreCalculator sc = stNode.getScoreCalculator();
    if (data.isPoints()) {
        sc.setSumOfScoreNodes(new ArrayList<String>(checklistNodes));
    } else {
        sc.setSumOfScoreNodes(null);
    }
    sc.setExpertMode(false);
    if (data.isPassed()) {
        Float cutValue = data.getCutValue();
        if (cutValue == null) {
            sc.setPassedType(ScoreCalculator.PASSED_TYPE_INHERIT);
            sc.setPassedNodes(new ArrayList<String>(checklistNodes));
        } else {
            sc.setPassedType(ScoreCalculator.PASSED_TYPE_CUTVALUE);
            sc.setPassedCutValue(cutValue.intValue());
        }
    } else {
        sc.setPassedType(ScoreCalculator.PASSED_TYPE_NONE);
    }
    sc.setScoreExpression(sc.getScoreExpressionFromEasyModeConfiguration());
    sc.setPassedExpression(sc.getPassedExpressionFromEasyModeConfiguration());
    stNode.setScoreCalculator(sc);
}
Also used : ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator)

Example 5 with ScoreCalculator

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

the class CheckListStepRunnerCallback method setScoreCalculation.

private void setScoreCalculation(GeneratorData data, STCourseNode stNode, List<String> checklistNodes) {
    if (!data.isPassed() && !data.isPoints())
        return;
    ScoreCalculator sc = stNode.getScoreCalculator();
    if (data.isPoints()) {
        sc.setSumOfScoreNodes(new ArrayList<String>(checklistNodes));
    } else {
        sc.setSumOfScoreNodes(null);
    }
    sc.setExpertMode(false);
    if (data.isPassed()) {
        Float cutValue = data.getCutValue();
        if (cutValue == null) {
            sc.setPassedType(ScoreCalculator.PASSED_TYPE_INHERIT);
            sc.setPassedNodes(new ArrayList<String>(checklistNodes));
        } else {
            sc.setPassedType(ScoreCalculator.PASSED_TYPE_CUTVALUE);
            sc.setPassedCutValue(cutValue.intValue());
        }
    } else {
        sc.setPassedType(ScoreCalculator.PASSED_TYPE_NONE);
    }
    sc.setScoreExpression(sc.getScoreExpressionFromEasyModeConfiguration());
    sc.setPassedExpression(sc.getPassedExpressionFromEasyModeConfiguration());
    stNode.setScoreCalculator(sc);
}
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