Skip to content

Commit

Permalink
Qualtrics: Add interactive option #203 [ci skip]
Browse files Browse the repository at this point in the history
 - Update ReadmeClass with Qualtrics call
  • Loading branch information
astrochun committed May 5, 2021
1 parent d78d44e commit 3552389
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions ldcoolp/curation/api/qualtrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ class Qualtrics:
Generate URL with customized query strings based on Figshare metadata
"""

def __init__(self, qualtrics_dict=config_default_dict['qualtrics'], log=None):
def __init__(self, qualtrics_dict=config_default_dict['qualtrics'], log=None,
interactive=True):

self.interactive = interactive

self.dict = qualtrics_dict
self.token = self.dict['token']
self.data_center = self.dict['datacenter']
Expand Down Expand Up @@ -324,11 +328,16 @@ def retrieve_deposit_agreement(self, dn_dict=None, ResponseId=None, out_path='',
except ValueError:
self.log.warn("Error with retrieving ResponseId and SurveyId")
self.log.info("PROMPT: If you wish, you can manually enter ResponseId to retrieve.")
ResponseId = input("PROMPT: An EMPTY RETURN will generate a custom Qualtrics link to provide ... ")
self.log.info(f"RESPONSE: {ResponseId}")
self.log.info("PROMPT: If you wish, you can manually enter SurveyId to retrieve.")
SurveyId = input("PROMPT: An EMPTY RETURN will generate a custom Qualtrics link to provide ... ")
self.log.info(f"RESPONSE: {SurveyId}")
if self.interactive:
ResponseId = input("PROMPT: An EMPTY RETURN will generate a custom Qualtrics link to provide ... ")
self.log.info(f"RESPONSE: {ResponseId}")
self.log.info("PROMPT: If you wish, you can manually enter SurveyId to retrieve.")
SurveyId = input("PROMPT: An EMPTY RETURN will generate a custom Qualtrics link to provide ... ")
self.log.info(f"RESPONSE: {SurveyId}")
else:
self.log.info("Interactive mode disabled. Skipping manual input")
ResponseId = ''
SurveyId = ''

if ResponseId == '' or SurveyId == '':
custom_url = self.generate_url(dn_dict)
Expand Down Expand Up @@ -356,7 +365,10 @@ def retrieve_deposit_agreement(self, dn_dict=None, ResponseId=None, out_path='',

# Retrieve PDF via direct URL link
if out_path:
pdf_url = 'retrieve'
if self.interactive:
pdf_url = 'retrieve'
else:
pdf_url = ''
while pdf_url == 'retrieve':
pdf_url = input("To retrieve PDF via API, provide PDF URL here. Hit enter to skip : ")

Expand Down Expand Up @@ -539,8 +551,12 @@ def retrieve_qualtrics_readme(self, dn=None, ResponseId='', browser=True):
except ValueError:
self.log.warn("Error with retrieving ResponseId")
self.log.info("PROMPT: If you wish, you can manually enter ResponseId to retrieve.")
ResponseId = input("PROMPT: An EMPTY RETURN will generate a custom Qualtrics link to provide ... ")
self.log.info(f"RESPONSE: {ResponseId}")
if self.interactive:
ResponseId = input("PROMPT: An EMPTY RETURN will generate a custom Qualtrics link to provide ... ")
self.log.info(f"RESPONSE: {ResponseId}")
else:
self.log.info("Interactive mode disabled. Skipping manual input")
ResponseId = ''

if ResponseId:
response_df = self.get_survey_response(self.readme_survey_id, ResponseId)
Expand Down
2 changes: 1 addition & 1 deletion ldcoolp/curation/inspection/readme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, dn, config_dict=config_default_dict, update=False,
self.q = q
else:
self.q = Qualtrics(qualtrics_dict=self.config_dict['qualtrics'],
log=self.log)
interactive=interactive, log=self.log)

self.curation_dict = self.config_dict['curation']
self.root_directory_main = self.curation_dict[self.curation_dict['parent_dir']]
Expand Down

0 comments on commit 3552389

Please sign in to comment.