Welcome, Guest
Username: Password: Remember me

TOPIC: Change Survey ID

Change Survey ID 3 years 1 week ago #63620

  • Pigeon
  • Pigeon's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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!
The administrator has disabled public write access.

Re: Change Survey ID 3 years 1 week ago #63624

  • greg_d
  • greg_d's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 47
  • Thank you received: 7
  • Karma: 4
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.
The administrator has disabled public write access.

Re: Change Survey ID 3 years 1 week ago #63626

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 6226
  • Thank you received: 792
  • Karma: 238
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 ...
The administrator has disabled public write access.

Re: Change Survey ID 3 years 1 week ago #63629

  • greg_d
  • greg_d's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 47
  • Thank you received: 7
  • Karma: 4
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.
The administrator has disabled public write access.

Re: Change Survey ID 3 years 1 week ago #63630

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 6226
  • Thank you received: 792
  • Karma: 238
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 :)
The administrator has disabled public write access.

Re: Change Survey ID 3 years 1 week ago #63643

  • Pigeon
  • Pigeon's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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:)
The administrator has disabled public write access.

Re: Change Survey ID 3 years 1 week ago #63646

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 6226
  • Thank you received: 792
  • Karma: 238
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.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.158 seconds
Donation Image