Skip to content

Commit fcf843f

Browse files
author
“Carmel
committed
Button skip logic
1 parent b8421a0 commit fcf843f

11 files changed

Lines changed: 962 additions & 26 deletions

__pycache__/app.cpython-311.pyc

243 Bytes
Binary file not shown.

app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from new_ldot_workflows.b_2_send_links_to_ldot import send_links_to_ldot
1414
from new_ldot_workflows.b_3_get_incomplete_subjects import get_incomplete_subjects
1515
from new_ldot_workflows.b_4_get_individual_progress import get_individual_progress
16+
from new_ldot_workflows.b_4_send_progress_to_ldot import send_progress_to_ldot
1617
from new_ldot_workflows.logging_utils import QualtricsAPIError
1718

1819
app = Flask(__name__)
@@ -236,6 +237,13 @@ def button4():
236237
study_variables.embedded_data_field,
237238
study_variables.survey_id,
238239
)
240+
send_progress_to_ldot(
241+
ldot_client,
242+
study_variables.ldot_study_id,
243+
study_variables.eaid_survey_progress_completed,
244+
participant_to_progress_dict,
245+
)
246+
239247
except QualtricsAPIError as e:
240248
return jsonify({"success": False, "message": str(e)}), 502
241249
except Exception as e:

logs/api_calls.log

Lines changed: 282 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from new_ldot_workflows.logging_utils import logged_request
2+
import json
23

34
def get_incomplete_subjects(ldot_client, study_id: str, eaid_survey_invitation_completed: str = None, eaid_survey_progress_completed: str = None) -> list:
45
"""Get subjects that have not yet completed the survey by checking their event actions"""
@@ -17,11 +18,11 @@ def get_incomplete_subjects(ldot_client, study_id: str, eaid_survey_invitation_c
1718

1819
subjects_with_survey_invitation_completed = set()
1920

20-
# print(result.json())
21-
# for action in result.json().get("Data", {}).get("StudyEventActions", []):
22-
# subjects_with_survey_invitation_completed.add(action["SubjectGuid"])
21+
print(result.json())
22+
for action in result.json().get("Data", {}).get("StudyEventActions", []):
23+
subjects_with_survey_invitation_completed.add(action["SubjectGuid"])
2324

24-
# print(f"Subjects with survey invitation completed: {subjects_with_survey_invitation_completed}")
25+
print(f"Subjects with survey invitation completed: {subjects_with_survey_invitation_completed}")
2526

2627
result = logged_request(
2728
"GET",
@@ -33,19 +34,33 @@ def get_incomplete_subjects(ldot_client, study_id: str, eaid_survey_invitation_c
3334
)
3435
print(result.json())
3536

36-
# subjects_with_survey_progress_completed = set()
37-
# for action in result.json().get("Data", {}).get("StudyEventActions", []):
38-
# subjects_with_survey_progress_completed.add(action["SubjectGuid"])
37+
subjects_with_survey_progress_completed = set()
38+
for action in result.json().get("Data", {}).get("StudyEventActions", []):
39+
subjects_with_survey_progress_completed.add(action["SubjectGuid"])
3940

40-
# print(f"Subjects with survey progress completed: {subjects_with_survey_progress_completed}")
41+
print(f"Subjects with survey progress completed: {subjects_with_survey_progress_completed}")
4142

42-
# incomplete_subjects = subjects_with_survey_invitation_completed - subjects_with_survey_progress_completed
43-
# return list(incomplete_subjects)
43+
incomplete_subjects = subjects_with_survey_invitation_completed - subjects_with_survey_progress_completed
44+
return list(incomplete_subjects)
4445

4546
if __name__ == "__main__":
4647
# This would typically be initialized with the actual Ldot client
47-
ldot_client = None # Replace with actual Ldot client initialization
48-
ldot_study_id = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b"
49-
eaid_survey_invitation_completed = "337ecba2-3dd3-1141-8c38-6cffdcfbd7eb"
50-
eaid_survey_progress_completed = "120d298d-9aa9-084b-abc6-432148db0e10"
51-
print(get_incomplete_subjects(ldot_study_id, eaid_survey_invitation_completed, eaid_survey_progress_completed))
48+
with open("new_ldot_workflows/ldot_config.json") as f:
49+
config = json.load(f)
50+
LDOT_TOKEN_URL = config["LDOT_TOKEN_URL"]
51+
LDOT_API_URL = config["LDOT_API_URL"]
52+
CLIENT_ID = config["client_id"]
53+
CLIENT_SECRET = config["client_secret"]
54+
55+
# ldot_client = LdotClient(
56+
# token_url=LDOT_TOKEN_URL,
57+
# api_url=LDOT_API_URL,
58+
# client_id=CLIENT_ID,
59+
# client_secret=CLIENT_SECRET
60+
# )
61+
# # print(ldot_client.headers)
62+
63+
# ldot_study_id = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b"
64+
# eaid_survey_invitation_completed = "337ecba2-3dd3-1141-8c38-6cffdcfbd7eb"
65+
# eaid_survey_progress_completed = "120d298d-9aa9-084b-abc6-432148db0e10"
66+
# print(get_incomplete_subjects(ldot_client, ldot_study_id, eaid_survey_invitation_completed, eaid_survey_progress_completed))

new_ldot_workflows/b_4_get_individual_progress.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77

88
from new_ldot_workflows.logging_utils import QualtricsAPIError, logged_request
9+
# from ldot_client import LdotClient
910

1011
with open("new_ldot_workflows/qualtrics_config.json") as f:
1112
config = json.load(f)
@@ -232,19 +233,34 @@ def get_individual_progress(ldot_client, ldot_study_id: str, id_deelnemer_entity
232233
return participant_to_progress_dict
233234

234235
if __name__ == "__main__":
235-
# # Example usage
236-
survey_id="SV_efCMOg6wHU0T8ii"
237-
embedded_data_field = "study_id_child"
236+
with open("ldot_config.json") as f:
237+
config = json.load(f)
238+
LDOT_TOKEN_URL = config["LDOT_TOKEN_URL"]
239+
LDOT_API_URL = config["LDOT_API_URL"]
240+
CLIENT_ID = config["client_id"]
241+
CLIENT_SECRET = config["client_secret"]
238242

243+
ldot_client = LdotClient(
244+
token_url=LDOT_TOKEN_URL,
245+
api_url=LDOT_API_URL,
246+
client_id=CLIENT_ID,
247+
client_secret=CLIENT_SECRET
248+
)
249+
print(ldot_client.headers)
239250

240-
ldot_study_id = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b"
241-
subject_ids = ["352fb9d8-962f-4735-9fc7-7b4e18109a51"]
242-
id_deelnemer_entity = "7f61b810-00ed-1d41-8a33-4164f25ebad0"
243-
id_location = "427f304f-9d95-44f5-8f7b-d6a1ce1db293"
244-
embedded_data_field = "study_id_child"
251+
# # # Example usage
252+
# survey_id="SV_efCMOg6wHU0T8ii"
253+
# embedded_data_field = "study_id_child"
245254

246-
participant_to_progress_dict = get_individual_progress(ldot_study_id, id_deelnemer_entity, id_location, subject_ids, embedded_data_field, survey_id)
247-
print(participant_to_progress_dict)
248255

256+
# ldot_study_id = "5c9c6a47-c8d7-8142-a8c8-ccdcb8a8044b"
257+
# subject_ids = ["352fb9d8-962f-4735-9fc7-7b4e18109a51"]
258+
# id_deelnemer_entity = "7f61b810-00ed-1d41-8a33-4164f25ebad0"
259+
# id_location = "427f304f-9d95-44f5-8f7b-d6a1ce1db293"
260+
# embedded_data_field = "study_id_child"
249261

250-
# subject_id_to_study_identifier_dict = subject_id_to_study_identifier(ldot_study_id, id_deelnemer_entity, id_location, subject_ids)
262+
# participant_to_progress_dict = get_individual_progress(ldot_study_id, id_deelnemer_entity, id_location, subject_ids, embedded_data_field, survey_id)
263+
# print(participant_to_progress_dict)
264+
265+
266+
# # subject_id_to_study_identifier_dict = subject_id_to_study_identifier(ldot_study_id, id_deelnemer_entity, id_location, subject_ids)

0 commit comments

Comments
 (0)