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 form load time metadata to Form submissions #2767

Closed
wants to merge 1 commit into from

Conversation

avazirna
Copy link
Contributor

@avazirna avazirna commented Jun 24, 2024

Summary

This PR enhances the implementation of the XForms specification by adding support to xforms-model-construct-done events. The xforms-model-construct-done event is to be triggered when the form is fully loaded and ready to be used, which in conjuction with timeStarNumeric (computed during xforms-ready) will in turn be used to calculate form load time.

Changes in HQ

In order to add the formLoadTime metadata to form submissions, there are changes needed to the XForm model in HQ:

<model>
    <instance>
        <data>
            ...
            <orx:meta xmlns:cc="http://commcarehq.org/xforms">
                 ...
                 <cc:timeStartNumeric/>
                 <cc:formLoadTime/>
            </orx:meta>
        </data>
    </instance>
    ...
    <setvalue ref="/data/meta/timeStartNumeric" value="double(now())" event="xforms-ready"/>
    <setvalue ref="/data/meta/formLoadTime" value="int((double(now()) - /data/meta/timeStartNumeric)*24*60*60*10000)" event="xforms-model-construct-done"/>
</model>
...

Ticket: https://dimagi.atlassian.net/browse/SC-3590
cross-request: dimagi/commcare-core#1412

Note for reviewers

According to the XForms Specification, xforms-ready event is dispatched as part of xforms-model-contract-done, so the order of execution proposed by this PR is inconsistent with the specification. The main problem is that the current implementation dispatches xforms-ready at the beginning of the form initialization process, not when it's ready to be used and changing that would require changes to existing CommCare apps.

Safety Assurance

  • I have confidence that this PR will not introduce a regression for the reasons below

Safety story

This feature makes use of existing functionality to run the calculations and update the form submission with the resulting values.

@avazirna
Copy link
Contributor Author

@damagatchi retest this please

1 similar comment
@avazirna
Copy link
Contributor Author

@damagatchi retest this please

@shubham1g5 shubham1g5 closed this Jul 17, 2024
@shubham1g5 shubham1g5 deleted the add-form-loading-time-metadata branch July 17, 2024 13:05
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

Successfully merging this pull request may close these issues.

2 participants