Package org.olat.course.condition.interpreter

Examples of org.olat.course.condition.interpreter.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;
  }
View Full Code Here


    // evaluate expression
    ConditionErrorMessage[] cems = ci.syntaxTestExpression(condExpr);
    if (softRefs.containsKey(this.currentCourseNodeId)) {
      List condExprs = (ArrayList) softRefs.get(this.currentCourseNodeId);
      for (Iterator iter = condExprs.iterator(); iter.hasNext();) {
        ConditionExpression element = (ConditionExpression) iter.next();
        if (element.getId().equals(currentConditionExpression.getId())) {
          condExprs.remove(element);
          break;
        }
      }
      condExprs.add(currentConditionExpression);
View Full Code Here

    (new TreeVisitor(v, cetm.getRootNode(), true)).visitAll();
    for (Iterator iter = softRefs.keySet().iterator(); iter.hasNext();) {
      String nodeId = (String) iter.next();
      List conditionExprs = (List) softRefs.get(nodeId);
      for (int i = 0; i < conditionExprs.size(); i++) {
        ConditionExpression ce = (ConditionExpression) conditionExprs.get(i);
        // DO NOT validateConditionExpression(ce) as this is already done in the
        // CollectConditionExpressionsVisitor
        Set<String> refs = new HashSet<String>(ce.getSoftReferencesOf("courseNodeId"));
        if (refs != null && refs.size() > 0) {
          Set<String> oldOnes = nodeRefs.put(nodeId, null);
          if (oldOnes != null) {
            refs.addAll(oldOnes);
          }
View Full Code Here

    for (Iterator iter = keys.iterator(); iter.hasNext();) {
      String nodId = (String) iter.next();
      retVal += "nodeId:" + nodId + "\n";
      List conditionExprs = (List) softRefs.get(nodId);
      for (Iterator iterator = conditionExprs.iterator(); iterator.hasNext();) {
        ConditionExpression ce = (ConditionExpression) iterator.next();
        retVal += "\t" + ce.toString() + "\n";
      }
      retVal += "\n";
    }
    return retVal;
  }
View Full Code Here

      String key = cn.getIdent();
      List condExprs = cn.getConditionExpressions();
      if (condExprs.size() > 0 && !tmp.isDeleted()) {
        // evaluate each expression
        for (Iterator iter = condExprs.iterator(); iter.hasNext();) {
          ConditionExpression ce = (ConditionExpression) iter.next();
          currentCourseNodeId = key;
          currentConditionExpression = ce;
          ci.syntaxTestExpression(ce);
        }
        // add it to the cache.
View Full Code Here

    //
    passedExpression.setExpertMode(true);
    String coS = passedExpression.getConditionExpression();
    if (coS != null && !coS.equals("")) {
      // an active condition is defined
      ConditionExpression ce = new ConditionExpression(passedExpression.getConditionId());
      ce.setExpressionString(passedExpression.getConditionExpression());
      retVal.add(ce);
    }
    scoreExpression.setExpertMode(true);
    coS = scoreExpression.getConditionExpression();
    if (coS != null && !coS.equals("")) {
      // an active condition is defined
      ConditionExpression ce = new ConditionExpression(scoreExpression.getConditionId());
      ce.setExpressionString(scoreExpression.getConditionExpression());
      retVal.add(ce);
    }
    //
    return retVal;
  }
View Full Code Here

    }
    /*
     *  not empty, now test precondition syntax and for existing soft references
     */
    CourseEditorEnv cev = euce.getCourseEditorEnv();
    ConditionExpression ce = new ConditionExpression(conditionId,tprecond.getValue());
    ConditionErrorMessage[] cerrmsg = cev.validateConditionExpression(ce);
    /*
     * display any error detected in the condition expression testing.
     */
    if (cerrmsg != null && cerrmsg.length >0) {
View Full Code Here

    OnlyGroupConditionInterpreter ci = new OnlyGroupConditionInterpreter(uce);
    List listOfConditionExpressions = courseNode.getConditionExpressions();
    boolean allConditionAreValid = true;
    // loop over all conditions, all must be true
    for (Iterator iter = listOfConditionExpressions.iterator(); iter.hasNext();) {
      ConditionExpression conditionExpression = (ConditionExpression) iter.next();
      Tracing.logDebug("conditionExpression=" + conditionExpression, this.getClass());
      Tracing.logDebug("conditionExpression.getId()=" + conditionExpression.getId(), this.getClass());
      Condition condition = new Condition();
      condition.setConditionId(conditionExpression.getId());
      condition.setConditionExpression(conditionExpression.getExptressionString());
      if ( !ci.evaluateCondition(condition) ) {
        allConditionAreValid = false;
      }
    }
    return allConditionAreValid;
View Full Code Here

    }
    //
    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;
  }
View Full Code Here

    if (StringHelper.containsNonWhitespace(scoreExp)) {   
      /*
       *  not empty, now test precondition syntax and for existing soft references
       */
      CourseEditorEnv cev = euce.getCourseEditorEnv();
      ConditionExpression ce = new ConditionExpression("score",scoreExp);
      ConditionErrorMessage[] cerrmsgs = cev.validateConditionExpression(ce);
      /*
       * display any error detected in the condition expression testing.
       */
      if (cerrmsgs != null && cerrmsgs.length>0) {
        //the error message
        tscoreexpr.setErrorKeyWithParams(cerrmsgs[0].errorKey, cerrmsgs[0].errorKeyParams);
        if (cerrmsgs[0].solutionMsgKey != null && !"".equals(cerrmsgs[0].solutionMsgKey)) {
          //and a hint or example to clarify the error message
          tscoreexpr.setExample(translate(cerrmsgs[0].solutionMsgKey, cerrmsgs[0].errorKeyParams));
        }
        return false;
      }     
      testElemWithNoResource = getInvalidNodeDescriptions(ce);           
    }
    if (StringHelper.containsNonWhitespace(passedExp)) {
      /*
       *  not empty, now test precondition syntax and for existing soft references
       */
      CourseEditorEnv cev = euce.getCourseEditorEnv();
      ConditionExpression ce = new ConditionExpression("passed",passedExp);
      ConditionErrorMessage[] cerrmsgs = cev.validateConditionExpression(ce);
      /*
       * display any error detected in the condition expression testing.
       */
      if (cerrmsgs != null && cerrmsgs.length>0) {
View Full Code Here

TOP

Related Classes of org.olat.course.condition.interpreter.ConditionExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.