Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Paste code macro
languagexml
<exec>
api_params={
                "projectid":pipe.CS_ProjectID,
                "pageid":pipe.Shop_StartPage,
                "respondentid":uuid
}
      </exec>

      <logic label="api_CS" api:params="api_params" api:url=https://survey-api.conceptsauce.io/ uses="api.1">
        <title>API Integration</title></logic>
      <exec>
if api_CS.status == 200:
for question in api_CS.r['questions']:
   if question['questionTitle'] == 'q1':
  
    ShoppingTime.val = (datetime.datetime.strptime(question['duration'], '%Y-%m-%dT%H:%M:%S.%fZ') - datetime.datetime(1970,1,1)).total_seconds()
   
    for product in question['qResponseData']['basketContent']:
                try:
         P_QuantityPurchased.attr(product['userMeta']['UPC']).val = product['quantity']
        except:
               print "There is an error with a UPC %s" % product['userMeta']['UPC']
        
    for product in question['qResponseData']['productViewEvents']:
                try:
         P1_Items_ClickedOn.attr(product['userMeta']['UPC']).val = 1
        except:
               print "There is an error with a UPC %s" % product['userMeta']['UPC']
        
   if question['questionTitle'] == 'q2findability':
  
    FindTime.val = (datetime.datetime.strptime(question['duration'], '%Y-%m-%dT%H:%M:%S.%fZ') - datetime.datetime(1970,1,1)).total_seconds()
   
    for product in question['qResponseData']['basketContent']:
                try:
         ProdFound.attr(product['userMeta']['UPC']).val = 1
        except:
               print "There is an error with a UPC %s" % product['userMeta']['UPC']
      </exec>

Then each variable is mapped to either a Checkbox or a standard input/list further down the XML survey script.