Is it possible to have annotate appearance and max-pixels parameter be dynamic?

General question: Can appearances or parameters be dynamic or are they static?

1. What is the issue? Please be detailed.
I wanted to provide the option to capture an image, preserve the original and annotate a lower resolution version, OR capture an image and allow annotation and skip the lower reslution version.

I had a question at the start to select which option, and used this in the appearance column to return annotate if the answer to 'preserve original' was 'No'
if(${config_preserve_photo_original}='No','annotate','')
This validated on upload ok and loaded in Enketo & Collect ok.

In Enketo, no matter which answer was selected, the image could not be annotated
In Collect, no matter which answer was selected, the image could be annotated.

Then I tried setting the parameters as below, but this does not validate and upload.
if(${config_preserve_photo_original}='No','max-pixels=2400 app=net.sourceforge.opencamera','max-pixels=3000 app=net.sourceforge.opencamera')

Currently the only solution I see to this is to have two image questions, one that is relevant when preserve = 'No' and allows annotation, and another that is relevant when preserve is 'Yes' and doesn't allow annotation. This might be the best answer if dynamic appearances/parameters is non trivial

Note - preserving and annotating another copy is easily done in Collect (not Enketo, doesn't work) by putting ${preserved_image_field} in both calculation and trigger for the annotated image field, but the user can accidentally Take or Choose image and overwrite it. This is a related issue to loading in a default image for required annotation and not being able to hide/disable Take/Choose, as documented here and slated for 'later'

To the best of my knowledge [but I'd have to dig thru a lot of code to irrefutably prove it...] the optional XForm control element appearanceand associated parameters XML element attributes (eg max-pixels) are statically evaluated at XForm parse time, by both Collect and Enketo.

Unlike XForm bind attributes like, say, constraint=... which are actual XPath expressions that are constantly being re-evaluated.

Although technically possible, trying to make appearances and/or parameters also subject to dynamic XPath expression would make the DAG (Directed-Acyclic-Graph) evaluation engine of Collect to resolve them somewhat more complex. But I agree it could lead to some rather interesting form design options... :thinking:

1 Like

I figured you'd know the answer to this one, thanks!

Sounds like for now I split the question into two with different static appearance and parameters and hope that my suggested 'annotate only' appearance arrives soon.

1 Like

Yeah, if you want dynamic appearances and/or parameters, you'll have to 'fake' it with separate questions, and use mutually exclusive relevances to flip between them as needed.

1 Like

As this will create separate variables, you might need to add a third (calculate) variable to get a combined data variable for export and analysis.

1 Like

Hi, there is a similar current discussion in the Kobo forum: https://community.kobotoolbox.org/t/using-if-conditions-in-appearance-column/67760 https://community.kobotoolbox.org/t/using-if-conditions-in-appearance-column/67760

Some more discussion that I initiated on this topic as well:

2 Likes