Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: set_question_properties returns "No valid data" on nested attributes #1110

Open
soberhofer opened this issue Mar 3, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@soberhofer
Copy link

soberhofer commented Mar 3, 2024

Citric Version

1.0.0

Python Version

3.10

LimeSurvey Version

6.4.10

Backend database

Limesurvey Hosted

Operating System

Limesurvey Hosted

Description

I am trying to programmatically update the answer_order of all questions in a survey to random.

I have confirmed I can update other properties such as title using

props: types.QuestionProperties = {'title': 'test'}
client.set_question_properties(question['id'], language="en", **props)

but when I try

props: types.QuestionProperties = {'attributes': {'answer_order': 'random'}}
client.set_question_properties(question['id'], language="en", **props)

I get No valid Data

is setting nested properties not supported? I couldn't find anything in the documentation.

Code

No response

Permissions Matrix

No response

@soberhofer soberhofer added the bug Something isn't working label Mar 3, 2024
@edgarrmondragon
Copy link
Owner

Hi @soberhofer, thanks for filing!

Unfortunately, the RemoteControl API doesn't seem to support it: https://forums.limesurvey.org/forum/development/134557-rpc-api-set-attributes-with-set_question_properties#241626.

The workaround recommended in that thread is to use import_question1 with question files edited by other means:

with open("my_question_file.lsq", "rb") as file:
    client.import_question(file, survey_id=..., group_id=...)

For question types where it's relevant, you should be looking for a random_order attribute I think:

   <row>
    <qid><![CDATA[207]]></qid>
    <attribute><![CDATA[random_order]]></attribute>
    <value><![CDATA[1]]></value>
    <language/>
   </row>

Footnotes

  1. https://citric.readthedocs.io/en/stable/_api/citric/client/index.html#citric.client.Client.import_question

@edgarrmondragon
Copy link
Owner

edgarrmondragon commented Mar 3, 2024

And FWIW I've wanted to add features to this library to help programmatically construct XML for questions and surveys but it seems daunting since the schema is undocumented ... and it's XML 😅

@soberhofer
Copy link
Author

Thank you very much for your input. I guess i'll have to to programmatically edit the lsq or the lsg, and then import it that way.
Yeah, daunting is the right word. :D

@edgarrmondragon edgarrmondragon added question Further information is requested and removed bug Something isn't working labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants