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

Opening a form to a specific query thread on a non-last page for an item brings user to the following page of the form, not the requested query #36

Open
Apotischman opened this issue Apr 12, 2023 · 6 comments
Assignees
Milestone

Comments

@Apotischman
Copy link

Apotischman commented Apr 12, 2023

Describe the bug
If a form has more than 1 page, where any of the pages (except the last page) has a query, and the user tries to "view query within form", they are brought to the last page of the form instead of the location where the active query is.

To Reproduce
Use the attached XForm.
Add a query to the first item
Open a form to a specific query thread
You are brought to the last page of the form, not the page where the query exists

query_issue.txt

@Apotischman Apotischman added this to the Next milestone Apr 12, 2023
@Apotischman Apotischman changed the title Viewing query within record brings user to the last page of the form, not the requested query Opening a form to a specific query thread for an item brings user to the last page of the form, not the requested query Apr 12, 2023
@MartijnR
Copy link
Member

MartijnR commented Apr 26, 2023

regular form: http://localhost:8005/single/fs/i/QcnTqhg0?ecid=a

regular question when editing record (no issue):

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=query_issue&ecid=a&go_to=/data/Extra/Q1&instance=<data><Extra><Q1>bla</Q1></Extra></daa>&instance_id=aa" http://localhost:8005/oc/api/v1/instance/edit 

dn for question when editing a record (also no issue):

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=query_issue&ecid=a&go_to=/data/Extra/Q1_comment&instance=<data><Extra><Q1>bla</Q1></Extra></data>&instance_id=aa" http://localhost:8005/oc/api/v1/instance/edit

@MartijnR
Copy link
Member

MartijnR commented Apr 26, 2023

This issue may have something to do with how enketo's API is used.

@Apotischman, can you please share the URL of the Enketo form? I'm interested in the hash (#) part of the URL. It should be #%2Fdata%2FExtra%2FQ1_comment (or #%2F%2FQ1_comment), for the query on the last question, but you probably see something else.

Update: it might be related to going to a specific query thread.

@pbowen-oc
Copy link

@MartijnR - Our URLs for accessing a specific query thread have parameters like this:
#%2F%2Fpulse_comment%23e5da1ea2-6fd5-43e0-8eba-dc4c9a210d65

@MartijnR
Copy link
Member

MartijnR commented May 31, 2023

with thread id, single page form (cannot reproduce issue):

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=query_issue&ecid=a&go_to=/data/Extra/Q1&instance=<data><Extra><Q1>bla</Q1></Extra></daa>&instance_id=aa" http://localhost:8005/oc/api/v1/instance/edit 

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=language.test&ecid=a&instance=\
<data xmlns:OpenClinica=\"http://openclinica.com/odm\" xmlns:enk=\"http://enketo.org/xforms\" xmlns:jr=\"http://openrosa.org/javarosa\" xmlns:oc=\"http://openclinica.org/xforms\" xmlns:orx=\"http://openrosa.org/xforms\" id=\"language.test\" version=\"1\">\
<page1><locale_note/><yn1/><locale_note_comment oc:queryParent=\"locale_note\"/><yn1_comment oc:queryParent=\"yn1\">{\"queries\":[{\"type\":\"comment\",\"id\":\"1\",\"date_time\":\"2023-01-18 11:34:36.608 -05:00\",\"comment\":\"df\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"b\"},{\"type\":\"comment\",\"id\":\"2\",\"date_time\":\"2023-01-19 11:34:36.608 -05:00\",\"comment\":\"abc\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"a\"} ]}</yn1_comment></page1>\
<meta><instanceID>uuid:e1623dbf-bf87-4b2a-8a5a-85ae832f31f3</instanceID></meta></data>\
&instance_id=123&go_to=/data/page1/yn1_comment#a" http://localhost:8005/oc/api/v1/instance/edit

with thread_id, multi page form (can reproduce):

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=query_issue&ecid=a&go_to=/data/VS/VSHR_comment#a&instance=<data><VS><VSHR></VSHR><VSHR_comment>{\"queries\":[{\"type\":\"comment\",\"id\":\"1\",\"date_time\":\"2023-01-18 11:34:36.608 -05:00\",\"comment\":\"df\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"b\"},{\"type\":\"comment\",\"id\":\"2\",\"date_time\":\"2023-01-19 11:34:36.608 -05:00\",\"comment\":\"abc\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"a\"} ]}</VSHR_comment></VS><Extra><Q1>bla</Q1><Q1_comment></Q1_comment></Extra></data>&instance_id=aa" http://localhost:8005/oc/api/v1/instance/edit

just going to the query without a thread (same issue):

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=query_issue&ecid=a&go_to=/data/VS/VSHR_comment&instance=<data><VS><VSHR></VSHR><VSHR_comment>{\"queries\":[{\"type\":\"comment\",\"id\":\"1\",\"date_time\":\"2023-01-18 11:34:36.608 -05:00\",\"comment\":\"df\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"b\"},{\"type\":\"comment\",\"id\":\"2\",\"date_time\":\"2023-01-19 11:34:36.608 -05:00\",\"comment\":\"abc\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"a\"} ]}</VSHR_comment></VS><Extra><Q1>bla</Q1><Q1_comment></Q1_comment></Extra></data>&instance_id=aa" http://localhost:8005/oc/api/v1/instance/edit

just going to the question itself (same issue, when loading a record):

curl --user enketorules: -d "server_url=http://localhost:3000&form_id=query_issue&ecid=a&go_to=/data/VS/VSHR&instance=<data><VS><VSHR></VSHR><VSHR_comment>{\"queries\":[{\"type\":\"comment\",\"id\":\"1\",\"date_time\":\"2023-01-18 11:34:36.608 -05:00\",\"comment\":\"df\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"b\"},{\"type\":\"comment\",\"id\":\"2\",\"date_time\":\"2023-01-19 11:34:36.608 -05:00\",\"comment\":\"abc\",\"status\":\"new\",\"assigned_to\":\"\",\"notify\":false,\"thread_id\":\"a\"} ]}</VSHR_comment></VS><Extra><Q1>bla</Q1><Q1_comment></Q1_comment></Extra></data>&instance_id=aa" http://localhost:8005/oc/api/v1/instance/edit

@MartijnR
Copy link
Member

MartijnR commented May 31, 2023

I cannot reproduce the issue. Going to a specific thread works with the provided form (for Q1_comment).

  • do for dn on 1st page instead - Yes, I can reproduce now. I updated the script in the previous comment.

@MartijnR MartijnR changed the title Opening a form to a specific query thread for an item brings user to the last page of the form, not the requested query Opening a form to a specific query thread on a non-last page for an item brings user to the last page of the form, not the requested query May 31, 2023
@MartijnR
Copy link
Member

MartijnR commented May 31, 2023

I suspect this is because the page.next() function is called which has some asynchronous actions. After correctly going to the right question, the next() gets completed and goes to the wrong page.

Yes, the pages._setBranchHandler function (in Enketo Core) calls the next function. A branchChange (in Enketo Core) triggers the event in this handler.

  • figure out how to avoid calling page.next() in this case

@pbowen-oc pbowen-oc changed the title Opening a form to a specific query thread on a non-last page for an item brings user to the last page of the form, not the requested query Opening a form to a specific query thread on a non-last page for an item brings user to the following page of the form, not the requested query Oct 12, 2023
@MartijnR MartijnR transferred this issue from OpenClinica/enketo-express-oc May 22, 2024
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

3 participants