Package org.olat.ims.qti.process.elements

Examples of org.olat.ims.qti.process.elements.ExpressionBuilder


   * <!ELEMENT and_selection (selection_metadata | and_selection | or_selection | not_selection)+>
   * @see org.olat.qti.process.elements.ExpressionBuilder#buildXPathExpression(org.dom4j.Element, java.lang.StringBuilder)
   */
  public void buildXPathExpression(Element selectionElement, StringBuilder expr, boolean not_switch, boolean use_switch) {
    if (use_switch && not_switch) { // treat this "and" node as an "or" node (we need to propagate not's down the tree, since xpath only knows !=,< etc. , but not a not
      ExpressionBuilder eb = QTIHelper.getExpressionBuilder("or_selection");
      eb.buildXPathExpression(selectionElement, expr, not_switch, false);
    }
    else {
      List elems = selectionElement.elements();
      int size = elems.size()// dtd: > 0
      for (int i = 0; i < size; i++) {
        Element child = (Element)elems.get(i);
        String name = child.getName();
        ExpressionBuilder eb = QTIHelper.getExpressionBuilder(name);
        eb.buildXPathExpression(child, expr, not_switch, true);
        if (i < size -1) expr.append(" and ");
      }
    }
  }
View Full Code Here


    // assert: use_switch always true
    if (!use_switch) throw new RuntimeException("error in not_selection; use_switch was switched off");
    List elems = selectionElement.elements();
    Element child = (Element)elems.get(0);
    String name = child.getName();
    ExpressionBuilder eb = QTIHelper.getExpressionBuilder(name);
    eb.buildXPathExpression(child, expr, !not_switch, true);
  }
View Full Code Here

  /**
   * @see org.olat.qti.process.elements.ExpressionBuilder#buildXPathExpression(org.dom4j.Element, java.lang.StringBuilder)
   */
  public void buildXPathExpression(Element selectionElement, StringBuilder expr, boolean not_switch, boolean use_switch) {
    if (use_switch && not_switch) { // treat this and node as an "or
      ExpressionBuilder eb = QTIHelper.getExpressionBuilder("and_selection");
      eb.buildXPathExpression(selectionElement, expr, not_switch, false);
    }
    else {
      List elems = selectionElement.elements();
      int size = elems.size(); // dtd: >0
      expr.append("(");
      for (int i = 0; i < size; i++) {
        Element child = (Element)elems.get(i);
        String name = child.getName();
        ExpressionBuilder eb = QTIHelper.getExpressionBuilder(name);
        eb.buildXPathExpression(child, expr, not_switch, true);
        if (i < size -1) expr.append(" or ");
      }
      expr.append(")");
    }
  }
View Full Code Here

          if (andornot_selection != null) {
            // some criteria, extend above xpath to select only the appropriate
            // elements
            select_expr.append("[");
            String elName = andornot_selection.getName();
            ExpressionBuilder eb = QTIHelper.getExpressionBuilder(elName);
            eb.buildXPathExpression(andornot_selection, select_expr, false, true);
            select_expr.append("]");
          }
          selectedItems = objectBank.selectNodes(select_expr.toString());
          el_items.addAll(selectedItems);
        }
View Full Code Here

    if (sbev == null) throw new RuntimeException("no section bev for " + name);
    return sbev;
  }

  public static ExpressionBuilder getExpressionBuilder(String name) {
    ExpressionBuilder eb = (ExpressionBuilder) expressionBuilders.get(name);
    if (eb == null) throw new RuntimeException("no expression builder for " + name);
    return eb;
  }
View Full Code Here

TOP

Related Classes of org.olat.ims.qti.process.elements.ExpressionBuilder

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.