use of org.olat.course.condition.interpreter.ConditionExpression in project OpenOLAT by OpenOLAT.
the class CourseEditorEnvImpl method validateConditionExpression.
/**
* @see org.olat.course.editor.CourseEditorEnv#validateConditionExpression(org.olat.course.condition.interpreter.ConditionExpression)
*/
public ConditionErrorMessage[] validateConditionExpression(ConditionExpression condExpr) {
// first set the active condition expression, which will be accessed from
// the conditions functions inserting soft references
currentConditionExpression = condExpr;
if (condExpr.getExptressionString() == null) {
return null;
}
// evaluate expression
ConditionErrorMessage[] cems = ci.syntaxTestExpression(condExpr);
if (softRefs.containsKey(this.currentCourseNodeId)) {
List<ConditionExpression> condExprs = softRefs.get(this.currentCourseNodeId);
for (Iterator<ConditionExpression> iter = condExprs.iterator(); iter.hasNext(); ) {
ConditionExpression element = iter.next();
if (element.getId().equals(currentConditionExpression.getId())) {
condExprs.remove(element);
break;
}
}
condExprs.add(currentConditionExpression);
} else {
List<ConditionExpression> condExprs = new ArrayList<ConditionExpression>();
condExprs.add(currentConditionExpression);
softRefs.put(currentCourseNodeId, condExprs);
}
return cems;
}
use of org.olat.course.condition.interpreter.ConditionExpression in project OpenOLAT by OpenOLAT.
the class EditScoreCalculationExpertForm method validateFormLogic.
@Override
public boolean validateFormLogic(UserRequest ureq) {
String scoreExp = tscoreexpr.getValue().trim();
if (StringHelper.containsNonWhitespace(scoreExp)) {
CourseEditorEnv cev = euce.getCourseEditorEnv();
ConditionExpression ce = new ConditionExpression("score", scoreExp);
ConditionErrorMessage[] cerrmsgs = cev.validateConditionExpression(ce);
if (cerrmsgs != null && cerrmsgs.length > 0) {
setKeys(ureq, tscoreexpr, cerrmsgs);
return false;
}
testElemWithNoResource = getInvalidNodeDescriptions(ce);
}
String passedExp = tpassedexpr.getValue().trim();
if (StringHelper.containsNonWhitespace(passedExp)) {
CourseEditorEnv cev = euce.getCourseEditorEnv();
ConditionExpression ce = new ConditionExpression("passed", passedExp);
ConditionErrorMessage[] cerrmsgs = cev.validateConditionExpression(ce);
if (cerrmsgs != null && cerrmsgs.length > 0) {
setKeys(ureq, tpassedexpr, cerrmsgs);
return false;
}
}
// reset HINTS
tscoreexpr.setExampleKey("rules.example", EXAMPLE_SCORE);
tpassedexpr.setExampleKey("rules.example", EXAMPLE_PASSED);
return true;
}
use of org.olat.course.condition.interpreter.ConditionExpression in project OpenOLAT by OpenOLAT.
the class ForumNodeForumCallback method getConditionExpressions.
/**
* @see org.olat.course.nodes.GenericCourseNode#getConditionExpressions()
*/
public List<ConditionExpression> getConditionExpressions() {
List<ConditionExpression> retVal;
List<ConditionExpression> parentsConditions = super.getConditionExpressions();
if (parentsConditions.size() > 0) {
retVal = new ArrayList<ConditionExpression>(parentsConditions);
} else {
retVal = new ArrayList<ConditionExpression>();
}
//
String coS = getPreConditionModerator().getConditionExpression();
if (coS != null && !coS.equals("")) {
// an active condition is defined
ConditionExpression ce = new ConditionExpression(getPreConditionModerator().getConditionId());
ce.setExpressionString(getPreConditionModerator().getConditionExpression());
retVal.add(ce);
}
coS = getPreConditionPoster().getConditionExpression();
if (coS != null && !coS.equals("")) {
// an active condition is defined
ConditionExpression ce = new ConditionExpression(getPreConditionPoster().getConditionId());
ce.setExpressionString(getPreConditionPoster().getConditionExpression());
retVal.add(ce);
}
coS = getPreConditionReader().getConditionExpression();
if (coS != null && !coS.equals("")) {
// an active condition is defined
ConditionExpression ce = new ConditionExpression(getPreConditionReader().getConditionId());
ce.setExpressionString(getPreConditionReader().getConditionExpression());
retVal.add(ce);
}
//
return retVal;
}
use of org.olat.course.condition.interpreter.ConditionExpression in project OpenOLAT by OpenOLAT.
the class GenericCourseNode method getConditionExpressions.
/**
* @see org.olat.course.nodes.CourseNode#getConditionExpressions()
*/
public List<ConditionExpression> getConditionExpressions() {
ArrayList<ConditionExpression> retVal = new ArrayList<ConditionExpression>();
String coS = getPreConditionVisibility().getConditionExpression();
if (coS != null && !coS.equals("")) {
// an active condition is defined
ConditionExpression ce = new ConditionExpression(getPreConditionVisibility().getConditionId());
ce.setExpressionString(getPreConditionVisibility().getConditionExpression());
retVal.add(ce);
}
//
return retVal;
}
use of org.olat.course.condition.interpreter.ConditionExpression in project OpenOLAT by OpenOLAT.
the class CalCourseNode method getConditionExpressions.
@Override
public List<ConditionExpression> getConditionExpressions() {
List<ConditionExpression> parentConditions = super.getConditionExpressions();
List<ConditionExpression> conditions = new ArrayList<>();
if (parentConditions != null && parentConditions.size() > 0) {
conditions.addAll(parentConditions);
}
Condition editCondition = getPreConditionEdit();
if (editCondition != null && StringHelper.containsNonWhitespace(editCondition.getConditionExpression())) {
ConditionExpression ce = new ConditionExpression(editCondition.getConditionId());
ce.setExpressionString(editCondition.getConditionExpression());
conditions.add(ce);
}
return conditions;
}
Aggregations