Putting constraints on field

I have a nodeset videos which has a field called ‘seen’ which is either set
to 0 or 1.
I want to display all the videos but put a constraint that the user can
only select it if the ‘seen’ attribute is 1.
If the user selects a video with ‘seen’ = 0, display a message to choose
another.
Can this be achieved using constraint ?
Thanks

Yasheth,

I’m not 100% sure I’m following your use case. Can you elaborate a bit more
about what specific workflow you’re trying to achieve?

It sounds like what you’re trying to do is display a list of videos, play a
video, and then display the list again, but if the user chooses a video
which has been played, prompt them with a message which says to choose
another instead?

There are a few ways to achieve this:

  1. Use a “Display Condition” (as it’s called in the HQ form designer. It’s
    an relevant="" in the xform itself) for each video. This is an expression
    which, if specified, only displays the question if its value is true. So
    you could make two prompts per video. One which displays the video, one
    which says “please choose another”, and set the Display Condition for the
    first to be (/path/to/seen = ‘0’) and the condition for the second to be
    (/path/to/seen = ‘1’).

This is the easiest option and is the best starting point because it is
fully supported by the HQ app builder.

  1. If you can edit your XForm directly, you can take advantage of Itemsets,
    which allow you to display the list of items in a select1 dynamically based
    on either an external data model synced to the phone, or based on the XML
    in the local form (which would work better for your case). The first case
    has instructions on the wiki
    https://confluence.dimagi.com/display/commcarepublic/Conditional+Select+Options
··· , but they're fairly easily adapted to using local XML if you're familiar with XForms, and I can provide guidance if so.

Either way, you will probably find it helpful to wrap your video playback
in a Repeat so the user can select to play an arbitrary number of videos.

-Clayton

On Thu, Oct 25, 2012 at 3:39 AM, yashseth yash@digitalgreen.org wrote:

I have a nodeset videos which has a field called ‘seen’ which is either
set to 0 or 1.
I want to display all the videos but put a constraint that the user can
only select it if the ‘seen’ attribute is 1.
If the user selects a video with ‘seen’ = 0, display a message to choose
another.
Can this be achieved using constraint ?
Thanks