Update a case property when case is selected from a multiple choice list

Hi,

I am working on an attendance app. The app has two types of modules; one
that enrolls the student and another that records the class attendance.

In the class attendance module there is an attendance form that makes use
of a multiple choice checkbox with parent cases (from the enrolment module)
as list options. the teacher is then expected to select from the list
those students who are absent. In the parent case, there is a property
called days absent (calculate condition set to 0) - I want to be to +1 and
update that case property every time the teacher selects the student in the
child form from the multiple choice list with cases. Is this possible? and
if so how do i go about doing this?

Secondly, when setting up the multiple choice checklist with cases the
value is set to @case_id and the label set to case_name. Is it possible to
set the value to a case property like student_gender so that we are able to
count the number of girls absent and the number of boys absent when the
teacher completes the attendance register form with that multiple choice
case list question?

Kindly,
Ameera

Hi Ameera,

For your first query on marking the attendance per-case:
Unfortunately, the mechanism you'd need to use to update each case
individually isn't really possible to configure in CommCare HQ.

For your second query:

I'm assuming you followed this pattern:
https://confluence.dimagi.com/display/commcarepublic/Multiple+Choice+Questions+with+Cases+as+Choices

to create your form.

There is a way for you to determine the # of boys and # of girls who are
absent.

At the end of following that instruction set, you would have had a "case
query" expression that looked like

instance('casedb')/casedb/case[@case_type='your_type'][index/parent =
instance('commcaresession')/session/data/case_id]

I'll be assuming that your select question has the ID children_in_attendance

If you make a hidden value in the form you can copy and paste the text you
entered to the "Query Expression" box of the checkboxes question, and
then at the end you can add the following "filter"

[not(selected(#form/children_in_attendance, @case_id))]

which will filter all of the children who were chosen (which would mean
that the remaining children were displayed but not selected.

After that you can add a filter for the child's gender

[not(selected(#form/children_in_attendance, @case_id))][gender='male']

and then put all of that in a count()

so the final hidden value calculation would look like

count(instance('casedb')/casedb/case[@case_type='your_type'][index/parent =
instance('commcaresession')/session/data/case_id][not(selected(#form/children_in_attendance,
@case_id))][gender='male'])

-Clayton

ยทยทยท On Mon, Sep 4, 2017 at 9:58 AM, Ameera Hamid wrote:

Hi,

I am working on an attendance app. The app has two types of modules; one
that enrolls the student and another that records the class attendance.

In the class attendance module there is an attendance form that makes use
of a multiple choice checkbox with parent cases (from the enrolment module)
as list options. the teacher is then expected to select from the list
those students who are absent. In the parent case, there is a property
called days absent (calculate condition set to 0) - I want to be to +1 and
update that case property every time the teacher selects the student in the
child form from the multiple choice list with cases. Is this possible? and
if so how do i go about doing this?

Secondly, when setting up the multiple choice checklist with cases the
value is set to @case_id and the label set to case_name. Is it possible to
set the value to a case property like student_gender so that we are able to
count the number of girls absent and the number of boys absent when the
teacher completes the attendance register form with that multiple choice
case list question?

Kindly,
Ameera

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Clayton,

Is there any update or workaround on the first part of this question, about updating a case after multichoice selection?

Thanks
Toby