Search in sources :

Example 31 with ConditionExpression

use of org.olat.course.condition.interpreter.ConditionExpression in project openolat by klemens.

the class AbstractAccessableCourseNode method getConditionExpressions.

/**
 * @see org.olat.course.nodes.GenericCourseNode#getConditionExpression()
 */
@Override
public List<ConditionExpression> getConditionExpressions() {
    ArrayList<ConditionExpression> retVal;
    List<ConditionExpression> parentsConditions = super.getConditionExpressions();
    if (parentsConditions.size() > 0) {
        retVal = new ArrayList<>(parentsConditions);
    } else {
        retVal = new ArrayList<>();
    }
    // 
    String coS = getPreConditionAccess().getConditionExpression();
    if (coS != null && !coS.equals("")) {
        // an active condition is defined
        ConditionExpression ce = new ConditionExpression(getPreConditionAccess().getConditionId());
        ce.setExpressionString(getPreConditionAccess().getConditionExpression());
        retVal.add(ce);
    }
    // 
    return retVal;
}
Also used : ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression)

Example 32 with ConditionExpression

use of org.olat.course.condition.interpreter.ConditionExpression in project openolat by klemens.

the class GenericCourseNode method isConfigValidWithTranslator.

/**
 * @param userCourseEnv
 * @param translatorStr
 * @return
 */
// for StatusDescription.WARNING
protected List<StatusDescription> isConfigValidWithTranslator(CourseEditorEnv cev, String translatorStr, List<ConditionExpression> condExprs) {
    List<StatusDescription> condExprsStatusDescs = new ArrayList<>();
    // check valid configuration without course environment
    StatusDescription first = isConfigValid();
    // check valid configuration within the course environment
    if (cev == null) {
        // course environment not configured!??
        condExprsStatusDescs.add(first);
        return condExprsStatusDescs;
    }
    /*
		 * there is course editor environment, we can check further. Iterate over
		 * all conditions of this course node, validate the condition expression and
		 * transform the condition error message into a status description
		 */
    for (int i = 0; i < condExprs.size(); i++) {
        ConditionExpression ce = condExprs.get(i);
        ConditionErrorMessage[] cems = cev.validateConditionExpression(ce);
        if (cems != null && cems.length > 0) {
            for (int j = 0; j < cems.length; j++) {
                StatusDescription sd = new StatusDescription(StatusDescription.WARNING, cems[j].errorKey, cems[j].solutionMsgKey, cems[j].errorKeyParams, translatorStr);
                sd.setDescriptionForUnit(getIdent());
                condExprsStatusDescs.add(sd);
            }
        }
    }
    condExprsStatusDescs.add(first);
    return condExprsStatusDescs;
}
Also used : StatusDescription(org.olat.course.editor.StatusDescription) ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression) ArrayList(java.util.ArrayList) ConditionErrorMessage(org.olat.course.condition.interpreter.ConditionErrorMessage)

Example 33 with ConditionExpression

use of org.olat.course.condition.interpreter.ConditionExpression in project openolat by klemens.

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;
}
Also used : ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression) ArrayList(java.util.ArrayList)

Example 34 with ConditionExpression

use of org.olat.course.condition.interpreter.ConditionExpression in project openolat by klemens.

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;
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression) ConditionErrorMessage(org.olat.course.condition.interpreter.ConditionErrorMessage)

Aggregations

ConditionExpression (org.olat.course.condition.interpreter.ConditionExpression)34 ArrayList (java.util.ArrayList)12 ConditionErrorMessage (org.olat.course.condition.interpreter.ConditionErrorMessage)8 Condition (org.olat.course.condition.Condition)6 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4 HashMap (java.util.HashMap)2 Set (java.util.Set)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 DirectedGraph (org._3pq.jgrapht.DirectedGraph)2 Edge (org._3pq.jgrapht.Edge)2 CycleDetector (org._3pq.jgrapht.alg.CycleDetector)2 DirectedEdgeFactory (org._3pq.jgrapht.edge.EdgeFactories.DirectedEdgeFactory)2 DefaultDirectedGraph (org._3pq.jgrapht.graph.DefaultDirectedGraph)2 TreeVisitor (org.olat.core.util.tree.TreeVisitor)2 Visitor (org.olat.core.util.tree.Visitor)2 ICourse (org.olat.course.ICourse)2 StatusDescription (org.olat.course.editor.StatusDescription)2 AbstractFeedCourseNode (org.olat.course.nodes.AbstractFeedCourseNode)2