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);
}
}
}
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);
}
}
}
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;
}
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);
}
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);
}
Aggregations