Check out the LimeSurvey source code on GitHub!

Change Survey ID

More
5 years 7 months ago #63620 by Pigeon
Hello,

I noticed that the survey ID for each survey is randomly generated.
I want either to choose my own ID or let limesurvey automatically generate an ID from the survey title.

The survey title always is a coursename followed by a coursecode.
i.e: Mahtematics (BAM12)

I want the survey ID to be the coursecode, so the bit between the brackets..

I found the sourcecode of the random generator for the survey ID, but i cant figure out how to do it.. can someone please help me to find the bit of code that wil do this for me?

do
{
$surveyid = sRandomChars(5,'123456789');
$isquery = "SELECT sid FROM ".db_table_name('surveys')." WHERE sid=$surveyid";
$isresult = db_execute_assoc($isquery); // Checked
}
while ($isresult->RecordCount()>0);


Thanks!

Please Log in to join the conversation.

More
5 years 7 months ago #63624 by greg_d
Survey ID is a numeric field - cannot contain any letters. Take a look into a database:
  `sid` int(11) NOT NULL,
is repeated almost in every database table, also in the source code this field is handled with assumption it will always be numeric.

If you really need this to use your coursecode in URL you may think about some redirection mechanism.

Please Log in to join the conversation.

More
5 years 7 months ago #63626 by DenisChenu
Hello,

Maybe you can trye to do some php string operation to find the BAM12 ( or use some $surveyid = $_POST to store first the survey id like you want ( and after change the name of the survey). But you can't update LS without do again your modification.

Other workaround to test: add one survey , don't add group or question ( or langage ). And change the sid in the database.

But you need to change the database because the sid are in int(11) and there are a lot of test is sid are integer or not.

.....

Another idea : if you want just some easy acces to survey, why not use your own phpscript ? redirect.php : make a table with your code and the real survey id and redirect to the real url ?

Less work, you can update LS like you want etc ...

Denis
Some work i think ...

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
5 years 7 months ago #63629 by greg_d
If you change the survey ID field to alphanumeric and start using letters in sid you will loose INSERTANS replacement functionality (this is the first that comes to my mind, Limesurvey may break in other places too). It uses sanitize_int function on every ID (survey, group, question) which removes everything but numbers from IDs.

Please Log in to join the conversation.

More
5 years 7 months ago #63630 by DenisChenu

greg_d wrote: If you change the survey ID field to alphanumeric and start using letters in sid you will loose INSERTANS replacement functionality (this is the first that comes to my mind, Limesurvey may break in other places too). It uses sanitize_int function on every ID (survey, group, question) which removes everything but numbers from IDs.

Yes your right ...

redirect.php is the best solution i think :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
5 years 7 months ago #63643 by Pigeon
Thank you very much everyone for the superfast response.

Im gonna try using a phpscript..
And use a table to redirect.. just like u said..

This one is solved:)

Please Log in to join the conversation.

More
5 years 7 months ago #63646 by DenisChenu
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form