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

big-image without image does not throw error on choice option #760

Open
tiritea opened this issue Feb 27, 2025 · 1 comment
Open

big-image without image does not throw error on choice option #760

tiritea opened this issue Feb 27, 2025 · 1 comment

Comments

@tiritea
Copy link

tiritea commented Feb 27, 2025

Software and hardware versions

pyxform 3.0.0 (and earlier)

Problem description

Specifying a big-image for a choice option without a corresponding image does not result in an (expected) error, and will consequently generate an (invalid?) XForm where the choice option only has a big-image

Steps to reproduce the problem

Run pyxform on the BigImage_error2.xlsx form (below), and/or run it under current XLSForm Online

You will observe no error is reported, and a resulting XForm is generated.

Expected behavior

Expect an error, like "To use big-image, you must also specify an image for the choice option...", and no resulting XForm generated.

Background

Specifying a big-image media type in the main survey form without a corresponding image will (correctly) result in a fatal error:

"To use big-image, you must also specify an image for the survey element named {self.name}."

You can use this form to confirm this exsiting correct behavior when it is against a survey element:
BigImage_error1.xlsx

However, no such check appears to be being made when you specify a big-image without an image for a choice option; no error is reported and pyxform will happily create a form with a big-image media type but no image for these options. This form will reproduce the problem:
BigImage_error2.xlsx

which generates a XML XForm with:

<?xml version="1.0"?>
<h:html
	xmlns="http://www.w3.org/2002/xforms"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:ev="http://www.w3.org/2001/xml-events"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:jr="http://openrosa.org/javarosa"
	xmlns:orx="http://openrosa.org/xforms"
	xmlns:odk="http://www.opendatakit.org/xforms">
	<h:head>
		<h:title>Big Image (missing choices image)</h:title>
		<model odk:xforms-version="1.0.0">
			<itext>
				<translation lang="default" default="true()">
					<text id="animals-0">
						<value>whale</value>
						<value form="big-image">jr://images/a.jpg</value>
					</text>
					<text id="animals-1">
						<value>frog</value>
						<value form="big-image">jr://images/b.jpg</value>
					</text>
					<text id="animals-2">
						<value>crocodile</value>
						<value form="big-image">jr://images/c.jpg</value>
					</text>
					<text id="animals-3">
						<value>eagle</value>
						<value form="big-image">jr://images/d.jpg</value>
					</text>
...

@tiritea
Copy link
Author

tiritea commented Feb 27, 2025

Please note, this may be fixed with PR for #759, which has to include an almost identical check on choice options for the proposed new image-description form type, which also prerequisites having an image.

I expect to submit this PR shortly. But if you want to get a fix for this immediately then I am happy to share the associated code. I have test the PR against the above BigImage_error2.xlsx form and confirmed it fixes this issue too.

@tiritea tiritea changed the title BUG: big-image without image does not throw error on choice option big-image without image does not throw error on choice option Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant