- Posts: 25
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Automatically Generate Tokens
- d90
- Topic Author
- Offline
- Junior Member
Less
More
8 years 6 months ago #124769
by d90
Automatically Generate Tokens was created by d90
Is there any way to automatically generate tokens? I mean, I have to imagine since there is a button to generate tokens there should be a way to call that function on the back end without having to physically press it with the mouse. Is this possible?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11756
- Thank you received: 2753
8 years 6 months ago #124770
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Automatically Generate Tokens
You mean you want to create them via the API?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- gabrieljenik
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 272
- Thank you received: 45
8 years 6 months ago #124771
by gabrieljenik
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
Replied by gabrieljenik on topic Automatically Generate Tokens
You could do a loop calling the add_participant remote control function N times.
manual.limesurvey.org/RemoteControl_2_API#add_participants
manual.limesurvey.org/RemoteControl_2_API#add_participants
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
The topic has been locked.
- d90
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 2
8 years 6 months ago #124791
by d90
Replied by d90 on topic Automatically Generate Tokens
I guess I should have provided more info. I'm using 1 survey for customer satisfaction. I'm importing info into the tokens table from my company's completed orders database. I want limesurvey to create the tokens for those imports rather than me writing an rng for it. So i guess any way that I can automate that portion would be awesome. Full disclosure though: I don't know how to utilize an API. I'm not a programmer so this is new ground for me.
The topic has been locked.
- d90
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 2
8 years 6 months ago #124793
by d90
Replied by d90 on topic Automatically Generate Tokens
Can the add_participants remote control add _only_ the token to the table? I'm only looking for the unique id to be generated similarly to the 'generate tokens' button under token management.
The topic has been locked.
- mwooldri143
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
8 years 5 months ago #126177
by mwooldri143
Replied by mwooldri143 on topic Automatically Generate Tokens
How are you adding the tokens to the survey table? I'm using Limesurvey for a customer satisfaction survey too, and though I am not a professional programmer I did manage to write a bit of php code that takes our phone call log and directly generates invitations, along with a generated "token" (for me, each customer has an "account" number which I scramble a little bit) by putting entries directly into the mysql table. It wouldn't take much php code to generate a random number that could be used as a token.
If you're importing a .csv file, then at the bare minimum you're importing a file with three headers. It would be relatively trivial to open up the .csv file in excel and add a column titled "tokens" and use RANDBETWEEN(X,Y) to generate random numbers for all of the entries. Then save this new .csv file and use that instead.
I have no idea what LDAP is so I can't advise there.
If you're importing a .csv file, then at the bare minimum you're importing a file with three headers. It would be relatively trivial to open up the .csv file in excel and add a column titled "tokens" and use RANDBETWEEN(X,Y) to generate random numbers for all of the entries. Then save this new .csv file and use that instead.
I have no idea what LDAP is so I can't advise there.
The topic has been locked.
- d90
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 25
- Thank you received: 2
8 years 5 months ago - 8 years 5 months ago #126179
by d90
Replied by d90 on topic Automatically Generate Tokens
Well before I explain that, it would help to know how we're using Limesurvey. We're a Franchisor. Our franchisees purchase equipment from us. Every time they purchase equipment, they will fill out a short satisfaction survey. It's always the same survey.
I created a stored procedure in MS SQL 2008 R2 to pull some basic info about the franchisee's order into my survey's token table. The part about crypt_gen_random(10) as token gives me a value which is then converted for use as the actual token value. I then fire off all order survey emails. This occurs daily. I don't necessarily like this method (of generating the tokens) as I feel the limesurvey software does it better.
I created a stored procedure in MS SQL 2008 R2 to pull some basic info about the franchisee's order into my survey's token table. The part about crypt_gen_random(10) as token gives me a value which is then converted for use as the actual token value. I then fire off all order survey emails. This occurs daily. I don't necessarily like this method (of generating the tokens) as I feel the limesurvey software does it better.
Warning: Spoiler!
Code:
Insert INTO [Limesurvey].[dbo].[tokens_table] ([Limesurvey].[dbo].[tokens_table].firstname, [Limesurvey].[dbo].[tokens_table].token, [Limesurvey].[dbo].[tokens_table].email, [Limesurvey].[dbo].[tokens_table].emailstatus, [Limesurvey].[dbo].[tokens_table].language, [Limesurvey].[dbo].[tokens_table].remindersent, [Limesurvey].[dbo].[tokens_table].attribute_1, [Limesurvey].[dbo].[tokens_table].attribute_2) select location, cast( '' as xml ).value('xs:base64Binary(sql:column( "token" ) )', 'nvarchar(MAX)' ), email, emailstatus, [language], remindersent, attribute_1, attribute_2 from ( select RTRIM([[Closed_Orders_For_Survey].[Franchise Location]) location, crypt_gen_random(10) as token, [Closed_Orders_For_Survey].[Email] email, 'OK' emailstatus, 'en' [language], 'N' remindersent, [[Closed_Orders_For_Survey].[Order Number] attribute_1, CONVERT(VARCHAR(10), [[Closed_Orders_For_Survey].[Invoice Date],110) attribute_2 from [[Closed_Orders_For_Survey] where [[Closed_Orders_For_Survey].[Order Date] >= dateadd(DAY, -1, Convert(date, GETDATE())) ) as x END
Last edit: 8 years 5 months ago by d90.
The topic has been locked.