Update app.py
Browse files
app.py
CHANGED
|
@@ -11,9 +11,11 @@ global parsed_input_data
|
|
| 11 |
global original_outputs, yaml_outputs
|
| 12 |
global survey_submission_ID
|
| 13 |
|
| 14 |
-
def process_survey(button_type
|
|
|
|
| 15 |
if button_type == 'data':
|
| 16 |
survey_id = "671fc52152e3225d7de349e6"
|
|
|
|
| 17 |
|
| 18 |
else:
|
| 19 |
survey_id = "671fe2d352e3225d7de34afc"
|
|
@@ -25,7 +27,7 @@ def process_survey(button_type, submission_id):
|
|
| 25 |
|
| 26 |
encoded_params = urlencode(params)
|
| 27 |
|
| 28 |
-
match_param = f'{{"_id": {{"$oid": "{
|
| 29 |
|
| 30 |
survey_url = f"{base_url}?{encoded_params}&match={match_param}"
|
| 31 |
|
|
@@ -69,12 +71,6 @@ def display_parameter_survey():
|
|
| 69 |
|
| 70 |
iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
|
| 71 |
return iframe_html
|
| 72 |
-
|
| 73 |
-
def process_submission():
|
| 74 |
-
global survey_submission_ID
|
| 75 |
-
submission_id = window.parent.gradio_app_submissionId
|
| 76 |
-
print("Submission ID from parent window:", submission_id)
|
| 77 |
-
survey_submission_ID = submission_id
|
| 78 |
|
| 79 |
def display_data_survey():
|
| 80 |
base_url = "https://app.surveystack.io/groups/"
|
|
@@ -128,7 +124,7 @@ with gr.Blocks() as app:
|
|
| 128 |
|
| 129 |
#survey_submission_ID = gr.Textbox(label="Before submitting your surveystack survey, PLEASE record your submission ID. Type it here.")
|
| 130 |
|
| 131 |
-
data_submit_button = gr.Button(
|
| 132 |
|
| 133 |
get_survey_back = gr.Textbox(label="Data from SurveyStack")
|
| 134 |
|
|
@@ -158,7 +154,7 @@ with gr.Blocks() as app:
|
|
| 158 |
|
| 159 |
data_submit_button.click(
|
| 160 |
lambda button_type: process_survey("data", button_type),
|
| 161 |
-
inputs=[
|
| 162 |
outputs=[get_survey_back, parameter_survey_output, data_survey_output, survey_submission_ID, data_submit_button, survey2_submission_ID, param_submit_button]
|
| 163 |
)
|
| 164 |
|
|
|
|
| 11 |
global original_outputs, yaml_outputs
|
| 12 |
global survey_submission_ID
|
| 13 |
|
| 14 |
+
def process_survey(button_type):
|
| 15 |
+
global survey_submission_ID
|
| 16 |
if button_type == 'data':
|
| 17 |
survey_id = "671fc52152e3225d7de349e6"
|
| 18 |
+
survey_submission_ID = window.parent.gradio_app_submissionId
|
| 19 |
|
| 20 |
else:
|
| 21 |
survey_id = "671fe2d352e3225d7de34afc"
|
|
|
|
| 27 |
|
| 28 |
encoded_params = urlencode(params)
|
| 29 |
|
| 30 |
+
match_param = f'{{"_id": {{"$oid": "{survey_submission_ID}"}}}}'
|
| 31 |
|
| 32 |
survey_url = f"{base_url}?{encoded_params}&match={match_param}"
|
| 33 |
|
|
|
|
| 71 |
|
| 72 |
iframe_html = f'<iframe src="{survey_url}" width="100%" height="600px"></iframe>'
|
| 73 |
return iframe_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
def display_data_survey():
|
| 76 |
base_url = "https://app.surveystack.io/groups/"
|
|
|
|
| 124 |
|
| 125 |
#survey_submission_ID = gr.Textbox(label="Before submitting your surveystack survey, PLEASE record your submission ID. Type it here.")
|
| 126 |
|
| 127 |
+
data_submit_button = gr.Button("Parse Data")
|
| 128 |
|
| 129 |
get_survey_back = gr.Textbox(label="Data from SurveyStack")
|
| 130 |
|
|
|
|
| 154 |
|
| 155 |
data_submit_button.click(
|
| 156 |
lambda button_type: process_survey("data", button_type),
|
| 157 |
+
inputs=[],
|
| 158 |
outputs=[get_survey_back, parameter_survey_output, data_survey_output, survey_submission_ID, data_submit_button, survey2_submission_ID, param_submit_button]
|
| 159 |
)
|
| 160 |
|