use of org.olat.ims.qti.process.elements.ExpressionBuilder in project openolat by klemens.
the class QTI_and_selection method buildXPathExpression.
/**
* <!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();
// dtd: > 0
int size = elems.size();
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 ");
}
}
}
use of org.olat.ims.qti.process.elements.ExpressionBuilder in project openolat by klemens.
the class QTI_not_selection method buildXPathExpression.
/**
* <!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) {
// 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);
}
use of org.olat.ims.qti.process.elements.ExpressionBuilder in project openolat by klemens.
the class QTI_or_selection method buildXPathExpression.
/**
* @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();
// dtd: >0
int size = elems.size();
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(")");
}
}
use of org.olat.ims.qti.process.elements.ExpressionBuilder in project OpenOLAT by OpenOLAT.
the class QTI_not_selection method buildXPathExpression.
/**
* <!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) {
// 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);
}
use of org.olat.ims.qti.process.elements.ExpressionBuilder in project OpenOLAT by OpenOLAT.
the class QTI_or_selection method buildXPathExpression.
/**
* @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();
// dtd: >0
int size = elems.size();
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(")");
}
}
Aggregations