lindsay-stevens / limesurveyrc2api Goto Github PK
View Code? Open in Web Editor NEWLimeSurvey RC2 REST webservices client
License: MIT License
LimeSurvey RC2 REST webservices client
License: MIT License
Well I was trying to import surveys using .txt files and I had a huge problem, it broke lime.
After a while I tought I should share my solution. Well the problem is when you import a survey file it needs to be base64 encoded, and then python writes on the data to send to the server "b'yourEncodedText'", instead of "yourEncodedText". Also survey id and survey title are not mandatory arguments while in the api code it is. So I made this changes in the function import_survey:
def import_survey(self, idata, title=None, sid=None, type='lss'):
data = """{ "id": 1,
"method": "import_survey",
"params": { "sSessionKey": "%s",
"sImportData": "%s",
"sImportDataType": "%s",
"sNewSurveyName": "%s",
"DestSurveyID": %s } }"""
% (self.session_key, idata.decode('utf-8'), type, title if title else '', str(sid) if sid else '""')
return self._getJSON(data)['result']
Hello
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from limesurveyrc2api.limesurvey import LimeSurvey
2
3 url = "http://aredil.freeboxos.fr:8036/index.php/admin/remotecontrol"
4 username = "admin"
5 password = "password"
ModuleNotFoundError: No module named 'limesurveyrc2api.limesurvey'
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
I've installed the whole module
!pip install limesurveyrc2api
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting limesurveyrc2api
Downloading limesurveyrc2api-1.0.0-py3-none-any.whl (7.6 kB)
Requirement already satisfied: requests in /usr/local/lib/python3.8/dist-packages (from limesurveyrc2api) (2.25.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests->limesurveyrc2api) (2022.12.7)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests->limesurveyrc2api) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.8/dist-packages (from requests->limesurveyrc2api) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests->limesurveyrc2api) (1.26.14)
Installing collected packages: limesurveyrc2api
Successfully installed limesurveyrc2api-1.0.0
unfortunately, it doesn't help
could you please provide insight ?
Thank you
Calling python3.6 -m unittest
revealed the following error and fails:
======================================================================
ERROR: test_get_participant_properties_success (tests.test__token.TestTokensWithExisting)
Querying for a unique token should return its properties.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/elke/Dokumente/Uni/limesurveyrc2api/tests/test__token.py", line 222, in test_get_participant_properties_success
survey_id=self.survey_id, token_id=token0["tid"])
File "/home/elke/Dokumente/Uni/limesurveyrc2api/limesurveyrc2api/_token.py", line 139, in get_participant_properties
raise LimeSurveyError(method, status)
limesurveyrc2api.exceptions.LimeSurveyError: ('get_participant_properties', 'No valid Data')
======================================================================
FAIL: test_invite_participants_success (tests.test__token.TestTokens)
Sending invites for survey participants should relay all invites.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/elke/Dokumente/Uni/limesurveyrc2api/tests/test__token.py", line 102, in test_invite_participants_success
self.assertEqual(len(participants), len(cas.messages))
AssertionError: 3 != 0
======================================================================
FAIL: test_invite_participants_uninvited_success (tests.test__token.TestTokens)
Re-sending invites with uninvited_only=False should not re-send.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/elke/Dokumente/Uni/limesurveyrc2api/tests/test__token.py", line 142, in test_invite_participants_uninvited_success
self.assertEqual(len(participants), len(cas.messages))
AssertionError: 3 != 0
======================================================================
FAIL: test_get_summary_count_success (tests.test__token.TestTokensWithExisting)
Querying a survey for a token count should return accurate result.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/elke/Dokumente/Uni/limesurveyrc2api/tests/test__token.py", line 201, in test_get_summary_count_success
self.assertEqual(len(self.participants), int(result["token_count"]))
AssertionError: 3 != 10
----------------------------------------------------------------------
Ran 28 tests in 10.583s
FAILED (failures=3, errors=1)
The error might be related with the problem, that 'tid' is returned as string, but get_participant_properties wants an int. But simply doing a type conversion did not solve the problem.
Hello Lindsay,
Unsure if you are still following the work on your creation but I have run into an error trying to access through the example Python code.
Accessing LimeSurvey CE Version 5.0.7+210628
The following code produces an error:
from limesurveyrc2api import LimeSurvey
api = LimeSurvey(url="nothing", username="nothing")
print(api)
TypeError: init() got an unexpected keyword argument 'username'
Unfortunately I have yet to gain the level of knowledge to identify why this issue has arisen. Any assistance is greatly appreciated to help me solve the problem and fill in my lack of knowledge. Thank you.
method _Survey.list_surveys() uses key 'iSurveyID' to get survey list. According to REST-API, it shoud be 'sUsername'
Tested with:
limesurveyrc2ap master-commit: 866cf62
LimeSurvey Community Edition Version 6.4.7
Using the token.invite_participants function leads to an error containing the line:
"Unknown named parameter $aTokenIDs"
Renaming aTokenIDs
to aTokenIds
(<- with a small 'd') in line 205 of file _token.py fixed it for me.
Strange seem the naming of surveID with capital D and tokenIds with a small d. But its the ways its documented...
Thank you for the work so far!
ImportError: No module named 'limesurveyrc2api.limesurvey
when I run the test from the test folder at
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/limesurveyrc2api/tests
config.ini is setup right yet I get nothing at all
dtruss results:
`dtruss python3 tests.py ▸▸▸▸▸▸▸▸▸▸
SYSCALL(args) = return
madvise(0x100298000, 0x3000, 0x5) = 0 0
open("/dev/dtracehelper\0", 0x2, 0x7FFF5FBFE3E0) = 3 0
ioctl(0x3, 0x80086804, 0x7FFF5FBFE368) = 0 0
close(0x3) = 0 0
thread_selfid(0x3, 0x80086804, 0x7FFF5FBFE368) = 1151900 0
bsdthread_register(0x7FFFBFD80080, 0x7FFFBFD80070, 0x2000) = 1073741919 0
ulock_wake(0x1, 0x7FFF5FBFD9BC, 0x0) = -1 Err#2
issetugid(0x1, 0x7FFF5FBFD9BC, 0x0) = 0 0
mprotect(0x100352000, 0x88, 0x1) = 0 0
mprotect(0x100354000, 0x1000, 0x0) = 0 0
mprotect(0x10036A000, 0x1000, 0x0) = 0 0
mprotect(0x10036B000, 0x1000, 0x0) = 0 0
mprotect(0x100381000, 0x1000, 0x0) = 0 0
mprotect(0x100382000, 0x1000, 0x1) = 0 0
mprotect(0x100352000, 0x88, 0x3) = 0 0
mprotect(0x100352000, 0x88, 0x1) = 0 0
getpid(0x100352000, 0x88, 0x1) = 29121 0
stat64("/AppleInternal/XBS/.isChrooted\0", 0x7FFF5FBFD878, 0x1) = -1 Err#2
stat64("/AppleInternal\0", 0x7FFF5FBFD910, 0x1) = -1 Err#2
csops(0x71C1, 0x7, 0x7FFF5FBFD3A0) = -1 Err#22
sysctl([CTL_KERN, 14, 1, 29121, 0, 0] (4), 0x7FFF5FBFD4F8, 0x7FFF5FBFD4F0, 0x0, 0x0) = 0 0
ulock_wake(0x1, 0x7FFF5FBFD920, 0x0) = -1 Err#2
csops(0x71C1, 0x7, 0x7FFF5FBFCC80) = -1 Err#22
getuid(0x71C1, 0x7, 0x7FFF5FBFCC80) = 868336049 0
getuid(0x71C1, 0x7, 0x7FFF5FBFCC80) = 868336049 0
stat64("/\0", 0x7FFF5FBFD8C0, 0x7FFF5FBFCC80) = 0 0
getattrlist("/Library\0", 0x7FFFBFC24B04, 0x7FFF5FBFF1D0) = 0 0
getattrlist("/Library/Frameworks\0", 0x7FFFBFC24B04, 0x7FFF5FBFF1D0) = 0 0
getattrlist("/Library/Frameworks/Python.framework\0", 0x7FFFBFC24B04, 0x7FFF5FBFF1D0) = 0 0
getattrlist("/Library/Frameworks/Python.framework/Versions\0", 0x7FFFBFC24B04, 0x7FFF5FBFF1D0) = 0 0
getattrlist("/Library/Frameworks/Python.framework/Versions/3.5\0", 0x7FFFBFC24B04, 0x7FFF5FBFF1D0) = 0 0
getattrlist("/Library/Frameworks/Python.framework/Versions/3.5/bin\0", 0x7FFFBFC24B04, 0x7FFF5FBFF1D0) = 0 0`
any idea what might be going on?
to be honest I am new to Lime and Lime API's and would appreciate any guidance :-)
Hi folks.
I've an issue installing the cliente.
When I ran pip install limesurveyrc2api
to use it in my project, I received another versión where i have to use or instantiate from LimeSurveyRemoteControl2API
instead LimeSurvey
.
Are you planing to send the upgrade to the pypi repository?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.