Adding multiple (1000) quotas automatically, potentially with API and Python | XM Community
Skip to main content

Hello everyone,

I hope this message finds you well. Thanks a lot for your time in reading this.

My issue is the following:

General explanation: I have a qualtrics survey with 1403 blocks, each of them containing a matrix question. I would like to set a quota on each of these matrix questions automatically. Each matrix question shouldn't be answered more than 10 times, in other words by more than 10 different participants.

Detailed explanation: I don't want to set a quota manually for each matrix question, as it would be too long. Also, I receive feedback regularly from my co-authors, and it can happen that a new information/idea makes us change something within the questions/survey, that I would re-upload in qualtrics and re-do the quota process again. So an automatic way would fit better the iterative research collaboration approach. I tried to do it in a automatic way with Chat GPT and Python (with my little coding knowledge), but I don't manage to find a way in the end with the code. Would you have an approach to automate it for all the matrix questions of the 1403 blocks at the same time, without having to repeat an operation or a step for each block or each question, then avoiding 1403 repetitions of a step ? 

I put my workaround-Python-code below if you want to check or if you are interested by the attempt, even though it might not be the right approach/direction to resolve the problem in the end. 

Thanks a lot, and have a very good day,

Alex

import requests
import json

# Step 1: Retrieve survey
response = requests.get('https://sabancimanagement.eu.qualtrics.com/API/v3/surveys/SV_bJXjy9VuDeSZOgC', headers={'X-API-TOKEN': 'RbmFsJ3DnjichlJUmbi1fmkqamGCYBRhToWALOn3'})
survey = response.json()

# Step 2: Parse survey structure
matrix_questions = i]
for block in survey 'result']:
    if block 'Element'] == 'Question':
        if block'QuestionType'] == 'Matrix':
            matrix_questions.append(blocks'QuestionID'])

# Step 3: Modify survey definition
for question_id in matrix_questions:
    quota_block = {
        'Type': 'Quota',
        'QuestionID': question_id,
        'Quota': {
            'Total': 10
        }
    }
    survey 'result'].append(quota_block)

# Step 4: Update survey
response = requests.put('https://yourdatacenterid.qualtrics.com/API/v3/surveys/SV_bJXjy9VuDeSZOgC', headers={'X-API-TOKEN': 'RbmFsJ3DnjichlJUmbi1fmkqamGCYBRhToWALOn3'}, data=json.dumps(survey))

Be the first to reply!

Leave a Reply