Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi

SUJET : Change Survey ID

Change Survey ID il y a 3 ans 2 mois #63620

  • Pigeon
  • Portrait de Pigeon
  • Hors ligne
  • Fresh Lemon
  • Messages : 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!
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Change Survey ID il y a 3 ans 2 mois #63624

  • greg_d
  • Portrait de greg_d
  • Hors ligne
  • Senior Lime
  • Messages : 47
  • Remerciements reçus 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.
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Change Survey ID il y a 3 ans 2 mois #63626

  • DenisChenu
  • Portrait de DenisChenu
  • Hors ligne
  • Moderator Lime
  • Messages : 6362
  • Remerciements reçus 827
  • Karma: 245
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 ...
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Change Survey ID il y a 3 ans 2 mois #63629

  • greg_d
  • Portrait de greg_d
  • Hors ligne
  • Senior Lime
  • Messages : 47
  • Remerciements reçus 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.
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Change Survey ID il y a 3 ans 2 mois #63630

  • DenisChenu
  • Portrait de DenisChenu
  • Hors ligne
  • Moderator Lime
  • Messages : 6362
  • Remerciements reçus 827
  • Karma: 245
greg_d écrit:
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 :)
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Change Survey ID il y a 3 ans 2 mois #63643

  • Pigeon
  • Portrait de Pigeon
  • Hors ligne
  • Fresh Lemon
  • Messages : 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:)
L'administrateur a désactivé l'accès en écriture pour le public.

Re: Change Survey ID il y a 3 ans 2 mois #63646

  • DenisChenu
  • Portrait de DenisChenu
  • Hors ligne
  • Moderator Lime
  • Messages : 6362
  • Remerciements reçus 827
  • Karma: 245
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.
L'administrateur a désactivé l'accès en écriture pour le public.
Modérateurs: ITEd
Temps de génération de la page : 0.182 secondes
Donation Image