The Kobo ‘rating’ widget is really just a select1 underneath.
These if() statements can be used in any XPath expression; that is, in any relevent, constraint or calculation, irregardless of the question type. The condition of the if() statement can be any valid boolean XPath expression, eg you could compare ${foo}=1, or {foo}=${bar}, or whatever. So yes, you could compare the result of, say, ${roof_damage} to the literal string “4-6”, or you could compare it to the value of some other question, say ${some_damage}. eg
To be clear, in Xpath, if() is a function, not a statement. And, unlike a statement, a function is required to always return a value, so there is no notion of “no action”. So you really need to be explicit as to what you want this function to return if the condition evaluates to true, and what to return when false.
public Object eval (DataInstance model, EvaluationContext evalContext) {
...
if (name.equals("if")) {
assertArgsCount(name, args, 3);
return ifThenElse(model, evalContext, args, argVals);
That is, javaRosa will throw an runtime logic error if you dont provide 3 arguments. Whether your XPath parser throws a syntax error when attempting to parse the expression "if(true(), ,'foo')" is probably somewhat implementation dependent. But either way, you’ll be screwed eventually…