Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default value support for image questions #405

Closed
MartijnR opened this issue Dec 12, 2019 · 9 comments · Fixed by #538
Closed

Add default value support for image questions #405

MartijnR opened this issue Dec 12, 2019 · 9 comments · Fixed by #538

Comments

@MartijnR
Copy link
Contributor

MartijnR commented Dec 12, 2019

If an image question has a default value (a filename), the XForm should prepend this value with jr://images/.

So if the default column for annotate question a contains body.png, the output in the XForm instance should be: <a>jr://images/body.png</a>.

Note that this value transformation is the same as what is used for values in the media::image:: or image column.

(As agreed here. XForms spec PR is here.)

@lognaturel
Copy link
Contributor

The transformation should really happen for defaults for any type that results in a binary bind. If there's no clean/straightforward way to target all those at once, doing it just for annotate seems ok.

@MartijnR MartijnR changed the title Add default value support for annotate question Add default value support for annotation question Dec 12, 2019
@MartijnR MartijnR changed the title Add default value support for annotation question Add default value support for image questions Dec 12, 2019
@MartijnR
Copy link
Contributor Author

MartijnR commented Dec 12, 2019

or just for all "image" questions if too cumbersome to do all binary types

@KeynesYouDigIt
Copy link
Contributor

Taking a shot at this now, sounds like, at least for images, we just need to append the file path properly jr://images/. ? or should I be building default value support from scratch separately for these values?

@KeynesYouDigIt
Copy link
Contributor

KeynesYouDigIt commented May 23, 2021

an image question

Does this mean a multiple choice question with a few images for each choice label? or could a default value actually be needed for some other type of "image question"?

@MartijnR Got an example you can send me to get the rust out of my brain?

@KeynesYouDigIt
Copy link
Contributor

I'm also having trouble figuring out where annotations are in the spec - I think I am looking in the wrong place? I will keep looking but just thought I would ask here first :)

@lognaturel
Copy link
Contributor

Thanks for looking into this, @KeynesYouDigIt!

we just need to append the file path properly jr://images/

Correct. If there is something in the default column for a question of type image, jr://images/ should be prepended. For convenience, I think there should be a check to see if that prefix already exists before adding it. Some users may find it more explicit or intuitive to see the jr://images/ in their XLSForm or they may simply have added it already out of necessity.

Does this mean a multiple choice question with a few images for each choice label?

No, it's unrelated to select questions. We're talking about questions that prompt the user for an image.

figuring out where annotations are in the spec

I think you mean annotate question as @MartijnR described in the initial issue. annotate is an appearance on an image question. He gave that example because it's a case where it makes a lot of sense to have a default -- it lets you do things like attach an image of the human body and ask people to circle pain zones. It's less clear that defaults are useful for other image variants but they should still be supported if that's reasonable to do. My guess is that the easiest is to support it for all image variants. See the docs I liked to above to see all the variants.

@KeynesYouDigIt
Copy link
Contributor

Check it out guys, I love this issue so much I SOLVED IT TWICE

lol, what I really wanted is to grab the low hanging fruit of handling images, then shoot up a draft at handling defautls for all binaries. the later includes some refactoring, but please feel free to shut it down if it's going down a dangerous path (haha get it, cause most of this work involves paths??)

In all serious ness, if we decide that binary default support is really just needed on image questions, lets reject #539 and merge #538.

@KeynesYouDigIt
Copy link
Contributor

KeynesYouDigIt commented Jun 7, 2021

@MartijnR @lognaturel sorry for my unfamiliarity here -

Do either of you know if default value itself must be wrapped like

    <model odk:xforms-version="1.0.0">
      <instance>
        <static_image id="pyxform_autotest_id_string">
          <my_image><a>jr://images/my_default_image.jpg</a></my_image>

? or will this happen on submital?

I am going to try and test this myself but I am kinda still shaking of the rust from my getting married and buying a house phase where I didnt work on this much, If either of you are bored it'd be sweet if you could pull down #538 and see if tags are added to annotations as expected (IF you dont already know off the top of your head that they will/won't be)

@lognaturel
Copy link
Contributor

Will try to look at the PR this week, thanks. The jr:// reference goes directly in the question tag. No a tag should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants